/*
 * Mosaic Cloud, wearing Mosaic's own shell.
 *
 * A rail, a topbar and a body — the same anatomy and the same measurements as
 * the product, so moving between the two does not feel like moving between two
 * companies. The values are copied rather than imported: this console must
 * never be a reason the product's theme has to stay compatible with anything,
 * and four screens are not worth that coupling.
 *
 * Dark only. The product offers both because people live in it all day; this is
 * opened to issue a licence and closed again.
 */

:root {
  color-scheme: dark;

  /* Surfaces, from the product's dark palette. */
  --bg-app: #212121;
  --bg-rail: #1c1c1c;
  --bg-panel: #2a2a2a;
  --bg-raised: #303030;
  --bg-hover: rgba(255, 255, 255, 0.06);
  --bg-active: rgba(255, 255, 255, 0.1);

  --border: #383838;
  --border-strong: #4a4a4a;

  --text: #ededed;
  --text-dim: #a1a1a1;
  --text-muted: #7c7c7c;

  --accent: #ff6c37;
  --accent-brand: #ff6c37;
  --accent-subtle: rgba(255, 108, 55, 0.14);

  --ok: #3ecf8e;
  --ok-subtle: rgba(62, 207, 142, 0.16);
  --warn: #eea23e;
  --warn-subtle: rgba(238, 162, 62, 0.16);
  --err: #ed5b5b;
  --err-subtle: rgba(237, 91, 91, 0.16);

  --rail-width: 64px;
  --topbar-height: 54px;
  --radius: 4px;
  --radius-lg: 6px;

  --fs-xs: 11px;
  --fs-sm: 12.5px;
  --fs-md: 13.5px;
  --fs-lg: 15px;

  --mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg-app);
  color: var(--text);
  font:
    var(--fs-md) / 1.55 ui-sans-serif,
    system-ui,
    -apple-system,
    'Segoe UI',
    sans-serif;
  -webkit-font-smoothing: antialiased;
}

/*
 * `hidden` must actually hide.
 *
 * Any element given a `display` by a class outranks the user agent's own
 * `[hidden] { display: none }`, so the sign-in card went on being drawn above
 * the console it had supposedly handed over to. One rule, and the attribute
 * means what it says everywhere.
 */
[hidden] {
  display: none !important;
}

.muted {
  color: var(--text-muted);
}
.small {
  font-size: var(--fs-sm);
}
.spacer {
  flex: 1;
}
.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.error {
  margin: 0;
  color: var(--err);
  font-size: var(--fs-sm);
}

code {
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: var(--bg-app);
  font-family: var(--mono);
  font-size: 11px;
}

/* ---------------------------------------------------------------- brand ---- */

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 600;
}

.brand-lg {
  font-size: 17px;
}

.mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex: none;
  border-radius: 6px;
  background: var(--accent-brand);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  user-select: none;
}

/* -------------------------------------------------------------- sign in ---- */

.signin {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.signin-card {
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg-panel);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.4);
}

.signin-card > p {
  margin: -8px 0 4px;
}

/* ---------------------------------------------------------------- shell ---- */

.app {
  display: flex;
  height: 100%;
  overflow: hidden;
}

/* The rail, at the product's own width and with its own active marker. */
.rail {
  position: relative;
  flex: none;
  width: var(--rail-width);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0 6px 8px;
  border-right: 1px solid var(--border);
  background: var(--bg-rail);
}

.rail::after {
  content: '';
  position: absolute;
  top: var(--topbar-height);
  left: 0;
  right: 0;
  border-bottom: 1px solid var(--border);
}

.rail-logo {
  width: 20px;
  height: 20px;
  flex: none;
  margin: calc((var(--topbar-height) - 20px) / 2) 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--accent-brand);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  user-select: none;
}

.rail-logo + .rail-btn {
  margin-top: 8px;
}

.rail-btn {
  position: relative;
  width: 100%;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 5px 2px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  cursor: pointer;
}

.rail-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.rail-label {
  font-size: 9.5px;
  letter-spacing: 0.02em;
}

.rail-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.rail-btn.is-active {
  background: var(--accent-subtle);
  color: var(--accent);
}

/* Against the rail's own edge, which the button is inset from by its padding. */
.rail-btn.is-active::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  flex: none;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-panel);
}

.topbar h1 {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.account {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  color: var(--text-dim);
}

.body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg-app);
}

.view {
  max-width: 1120px;
  margin: 0 auto;
  padding: 26px 20px 60px;
}

.view-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.view-head h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.view-head p {
  margin: 3px 0 0;
  max-width: 60ch;
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.view-head .primary {
  margin-left: auto;
  flex: none;
}

/* ---------------------------------------------------------------- panel ---- */

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  overflow: hidden;
}

.scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: var(--fs-md);
}

th,
td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

thead th {
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover td {
  background: var(--bg-hover);
}

td.strong {
  font-weight: 500;
}

td.mono {
  font-family: var(--mono);
  font-size: var(--fs-sm);
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

td.right {
  text-align: right;
}

.empty {
  margin: 0;
  padding: 30px 16px;
  color: var(--text-muted);
  font-size: var(--fs-md);
  text-align: center;
}

/* An empty table draws a header over nothing, which reads as a failure. */
.panel:has(.empty:not([hidden])) .scroll {
  display: none;
}

/* ---------------------------------------------------------------- chips ---- */

.chip {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-active);
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.chip.is-current {
  background: var(--ok-subtle);
  color: var(--ok);
}
.chip.is-expired {
  background: var(--err-subtle);
  color: var(--err);
}
.chip.is-superseded {
  background: var(--bg-active);
  color: var(--text-muted);
}
.chip.is-admin {
  background: var(--accent-subtle);
  color: var(--accent);
}

/* ------------------------------------------------------------- controls ---- */

button {
  font: inherit;
  cursor: pointer;
}

.primary,
.ghost {
  padding: 6px 12px;
  border-radius: var(--radius);
  font-size: var(--fs-md);
}

.primary {
  border: 1px solid var(--accent-brand);
  background: var(--accent-brand);
  color: #fff;
  font-weight: 500;
}

.primary:hover {
  background: #ff835a;
  border-color: #ff835a;
}

.primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ghost {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
}

.ghost:hover {
  background: var(--bg-hover);
}

label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: var(--fs-sm);
  color: var(--text-dim);
}

input,
select,
textarea {
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-app);
  color: var(--text);
  font: inherit;
  font-size: var(--fs-md);
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.rail-btn:focus-visible {
  outline-offset: 1px;
}

textarea {
  resize: vertical;
  font-family: var(--mono);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

/* -------------------------------------------------------------- dialogs ---- */

dialog {
  width: min(540px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--bg-panel);
  color: var(--text);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

dialog form,
dialog > div {
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 22px 24px 20px;
}

dialog h2 {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 600;
}

dialog > form > p,
dialog > div > p {
  margin: -6px 0 2px;
  font-size: var(--fs-sm);
  line-height: 1.5;
}

fieldset {
  margin: 0;
  padding: 12px 14px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

legend {
  padding: 0 6px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

fieldset p {
  margin: 0 0 10px;
  line-height: 1.5;
}

.check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 9px;
  align-items: center;
  color: var(--text);
  font-size: var(--fs-md);
}

.check input {
  grid-row: span 2;
}

.check small {
  grid-column: 2;
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 9px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.grid label span {
  font-family: var(--mono);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

menu {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin: 6px 0 0;
  padding: 0;
}

@media (max-width: 620px) {
  .rail-label {
    display: none;
  }
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ---------------------------------------------------------------- packs ---- */

.packs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 14px;
}

.pack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
}

.pack h3 {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 600;
}

.pack p {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  line-height: 1.5;
}

.pack-holders {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.pack-holder {
  padding: 3px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: var(--fs-sm);
  color: var(--text-dim);
}

/* Nobody holding it is a fact worth stating, not an empty row to puzzle over. */
.pack-none {
  padding-top: 12px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}

/* ------------------------------------------------------- public pages ---- */

/*
 * Signup and confirmation, read by people who are not staff.
 *
 * Wider than the sign-in card because they carry prose and a licence key rather
 * than two fields, and the key is 600-odd characters that nobody should have to
 * scroll a 360px box to select.
 */
.public-card {
  width: min(480px, 100%);
}

.public-card form,
.public-card > div {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.public-card h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.public-card p {
  margin: 0;
  font-size: var(--fs-sm);
  line-height: 1.55;
}

.public-card textarea {
  width: 100%;
}

/* The download sits beside Copy as a peer, so it is styled as one rather than
   left as a bare link in a row of buttons. */
.public-card menu a.primary {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
