/* TRTactics Admin: the SFMS / website "Workbench" look, tuned for working screens (14px text,
   compact tables). Light by default; dark via data-theme on <html>. */

:root {
  --app-bg: #cdd4db;
  --window: #eaeef2;
  --content: #f2f4f7;
  --header: #e8ecf0;
  --header-bd: #b3bcc7;
  --card: #ffffff;
  --card-bd: #c3ccd5;
  --divider: #d8dee4;
  --elevated: #eef1f4;
  --elevated-bd: #b3bcc7;
  --input: #ffffff;
  --input-bd: #b3bcc7;

  --text: #1a2431;
  --muted: #55616f;
  --faint: #8792a0;

  --accent: #2c6da3;
  --on-accent: #ffffff;
  --accent-tint: rgba(44, 109, 163, 0.10);
  --hover-tint: rgba(20, 30, 45, 0.045);

  --ok: #1f7a46;
  --ok-tint: rgba(31, 122, 70, 0.12);
  --warn: #9a6200;
  --warn-tint: rgba(196, 128, 0, 0.14);
  --bad: #b3261e;
  --bad-tint: rgba(179, 38, 30, 0.10);
  --trial: #6a4fb3;
  --trial-tint: rgba(106, 79, 179, 0.12);

  --r: 2px;
  --t: .15s ease;
  --shadow: 0 10px 26px rgba(28, 40, 56, 0.18), 0 1px 2px rgba(28, 40, 56, 0.12);
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --display: "Space Grotesk", "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

:root[data-theme="dark"] {
  --app-bg: #14171b;
  --window: #232830;
  --content: #1a1e24;
  --header: #20252c;
  --header-bd: #333b45;
  --card: #262c34;
  --card-bd: #39424d;
  --divider: #2f363f;
  --elevated: #2b323b;
  --elevated-bd: #3d4650;
  --input: #1f242b;
  --input-bd: #3d4650;

  --text: #e5eaf0;
  --muted: #aab4bf;
  --faint: #6f7b88;

  --accent: #4a93d4;
  --accent-tint: rgba(74, 147, 212, 0.14);
  --hover-tint: rgba(255, 255, 255, 0.05);

  --ok: #5cc28a;
  --ok-tint: rgba(92, 194, 138, 0.14);
  --warn: #e0a94a;
  --warn-tint: rgba(224, 169, 74, 0.14);
  --bad: #f07a72;
  --bad-tint: rgba(240, 122, 114, 0.14);
  --trial: #a99be6;
  --trial-tint: rgba(169, 155, 230, 0.14);

  --shadow: 0 10px 26px rgba(0, 0, 0, 0.55), 0 1px 2px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--content);
  color: var(--text);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2 { font-family: var(--display); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 16px; }
p { margin: 0 0 10px; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---- header ---- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--header);
  border-bottom: 1px solid var(--header-bd);
}
.top-row {
  max-width: 1200px; margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); text-decoration: none !important; }
.mark { width: 40px; height: auto; }
.brand-name { font: 600 17px var(--display); }
.brand-name .tr { color: var(--accent); }
.brand-sub { color: var(--muted); font-weight: 500; }
.nav { display: flex; gap: 2px; flex-wrap: nowrap; overflow-x: auto; flex: 1; min-width: 0; }
.nav { scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 8px 12px; white-space: nowrap; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; text-decoration: none;
}
.nav a:hover { color: var(--text); background: var(--hover-tint); }
.nav a[aria-current] { color: var(--text); border-bottom-color: var(--accent); }
.top-end { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.who { color: var(--muted); font-size: 13px; }

/* Before signing in only the logo and the theme switch show. */
.signed-out .nav, .signed-out .who, .signed-out #signOut { display: none; }

/* ---- page ---- */
.page { max-width: 1200px; margin: 0 auto; padding: 22px 16px 60px; outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; }
.eyebrow { font: 600 11px var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 4px; }

.card {
  background: var(--card); border: 1px solid var(--card-bd); border-radius: var(--r);
  padding: 16px; margin-bottom: 16px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.empty { color: var(--muted); margin: 6px 0; }
.error { color: var(--bad); background: var(--bad-tint); border: 1px solid var(--bad); padding: 8px 12px; border-radius: var(--r); }
.sign-in { max-width: 420px; margin: 40px auto; }
.sign-in h1 { margin-bottom: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
code.key { font: 600 14px var(--mono); background: var(--elevated); padding: 2px 6px; border-radius: var(--r); white-space: nowrap; }
.notes { white-space: pre-wrap; margin: 12px 0 0; color: var(--muted); }
.link { font-weight: 500; }

/* ---- tiles ---- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile {
  background: var(--card); border: 1px solid var(--card-bd); border-top: 3px solid var(--accent);
  border-radius: var(--r); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
}
.tile.warn { border-top-color: var(--warn); }
.tile.bad { border-top-color: var(--bad); }
.tile-label { font: 600 11px var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.tile-value { font: 600 24px/1.2 var(--display); }
.tile-note { color: var(--muted); font-size: 12px; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font: 600 11px var(--sans); letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--card-bd); white-space: nowrap;
}
td { padding: 9px 10px; border-bottom: 1px solid var(--divider); vertical-align: top; }
tbody tr:hover { background: var(--hover-tint); }
.num { text-align: right; white-space: nowrap; }
.sub { color: var(--muted); font-size: 12px; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions > * + * { margin-left: 4px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: var(--r);
  font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent;
}
.s-active { color: var(--ok); background: var(--ok-tint); }
.s-due { color: var(--warn); background: var(--warn-tint); }
.s-overdue { color: var(--bad); background: var(--bad-tint); border-color: var(--bad); }
.s-trial { color: var(--trial); background: var(--trial-tint); }
.s-cancelled, .s-none { color: var(--muted); background: var(--elevated); }
.t-overdue { color: var(--bad); }
.t-due { color: var(--warn); }

.chips { justify-content: flex-start; }
.chip {
  font: 500 13px var(--sans); color: var(--muted); background: var(--elevated);
  border: 1px solid var(--elevated-bd); border-radius: var(--r); padding: 5px 10px; cursor: pointer;
}
.chip span { font-family: var(--mono); margin-left: 4px; }
.chip.on { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }

.search {
  width: min(420px, 100%); font: inherit; color: var(--text); background: var(--input);
  border: 1px solid var(--input-bd); border-radius: var(--r); padding: 7px 10px;
}

/* ---- details and timeline ---- */
.details { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 18px; margin: 0; }
.details dt { font: 600 11px var(--sans); letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.details dd { margin: 2px 0 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: grid; grid-template-columns: 110px 1fr auto auto; gap: 12px; align-items: baseline;
  padding: 8px 0; border-bottom: 1px solid var(--divider);
}
.timeline .when { color: var(--muted); font-size: 13px; white-space: nowrap; }
.timeline .what { white-space: pre-wrap; }
.timeline .by { color: var(--faint); font-size: 12px; }
.icon-btn { border: none; background: none; color: var(--faint); font-size: 18px; cursor: pointer; padding: 0 4px; }
.icon-btn:hover { color: var(--bad); }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 600 13px var(--sans); color: var(--text); background: var(--elevated);
  border: 1px solid var(--elevated-bd); border-radius: var(--r); padding: 8px 14px;
  cursor: pointer; text-decoration: none !important; transition: border-color var(--t), background var(--t);
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.primary { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: #fff; background: var(--bad); border-color: var(--bad); }
.btn.ghost-danger { color: var(--bad); background: transparent; }
.btn.ghost-danger:hover { border-color: var(--bad); background: var(--bad-tint); }

/* ---- forms and dialogs ---- */
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.wide, .grid > .wide { grid-column: 1 / -1; }
.field > span { font-weight: 600; font-size: 13px; }
.field small { color: var(--muted); font-size: 12px; }
.field input, .field select, .field textarea {
  font: inherit; color: var(--text); background: var(--input);
  border: 1px solid var(--input-bd); border-radius: var(--r); padding: 7px 9px; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus, .search:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}

dialog {
  width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow: auto;
  padding: 0; border: 1px solid var(--card-bd); border-radius: var(--r);
  background: var(--card); color: var(--text); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(10, 16, 24, 0.45); }
.dlg { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dlg-intro { color: var(--muted); margin: 0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 50; max-width: min(420px, calc(100vw - 32px));
  padding: 10px 14px; border-radius: var(--r); background: var(--text); color: var(--card);
  box-shadow: var(--shadow); font-weight: 500;
}
.toast.warn { background: var(--warn); color: #fff; }
.toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 760px) {
  .top-row { gap: 6px 12px; }
  .top-end { margin-left: auto; }
  /* The menu becomes one row under the logo that scrolls sideways, instead of a tall column. */
  .nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; }
  .nav a { white-space: nowrap; }
}

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .who { display: none; }
  .timeline li { grid-template-columns: 1fr auto; }
  .timeline .when, .timeline .by { grid-column: 1 / -1; }
  h1 { font-size: 22px; }
}
