:root {
  color-scheme: dark;
  --bg: #090b0a;
  --panel: #121513;
  --panel-raised: #181c19;
  --panel-soft: #0f1210;
  --line: #2a302c;
  --line-strong: #3a433d;
  --text: #f0f2f0;
  --muted: #9ca39f;
  --muted-soft: #747c77;
  --yellow: #efd13f;
  --yellow-soft: rgba(239, 209, 63, .12);
  --green: #65d487;
  --red: #ff7d7d;
  --blue: #7fafff;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .24);
}

* { box-sizing: border-box; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-width: 280px;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 15% -10%, rgba(239, 209, 63, .08), transparent 32rem),
    linear-gradient(180deg, #0b0d0c 0, var(--bg) 24rem);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: break-word;
}

a { color: var(--yellow); text-underline-offset: 3px; }
a:hover { color: #ffe568; }

:focus-visible {
  outline: 3px solid rgba(239, 209, 63, .55);
  outline-offset: 3px;
}

.site-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px max(24px, calc((100vw - 1240px) / 2));
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: rgba(10, 12, 11, .9);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
}

.brand-mark {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #f6da51, #dcb923);
  color: #090a09;
  box-shadow: 0 8px 24px rgba(239, 209, 63, .16);
  font-weight: 850;
  letter-spacing: 1px;
}

.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: .1px; }
.brand small {
  margin-top: 1px;
  color: var(--muted-soft);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
}

.site-nav { display: flex; align-items: center; gap: 8px; }
.site-nav > a:not(.button) {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 8px;
  color: #b7bdb9;
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}
.site-nav > a:not(.button):hover { color: #fff; background: rgba(255, 255, 255, .05); }
.user-name {
  color: var(--muted-soft);
  font-size: 13px;
  padding: 0 12px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}

.page-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: clamp(32px, 5vw, 56px) 0 72px;
}

.page-heading { margin-bottom: 28px; }
.page-heading h1 {
  max-width: 18ch;
  margin: 4px 0 8px;
  color: #fff;
  font-size: clamp(30px, 4vw, 40px);
  font-weight: 520;
  line-height: 1.1;
  letter-spacing: -.7px;
}
.heading-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; }
.heading-row > div { min-width: 0; }
.eyebrow {
  margin: 0;
  color: var(--yellow);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1.6px;
  text-transform: uppercase;
}
.muted { max-width: 68ch; color: var(--muted); margin: 0; line-height: 1.6; }

.button {
  min-height: 44px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  border-radius: 9px;
  padding: 10px 16px;
  border: 1px solid var(--line-strong);
  text-decoration: none;
  font-family: inherit;
  font-size: 14px;
  font-weight: 750;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  white-space: normal;
}
.button-primary {
  color: #0a0b0a;
  background: linear-gradient(180deg, #f5d94d, #e7c52e);
  border-color: #f3d64a;
  box-shadow: 0 8px 20px rgba(239, 209, 63, .12);
}
.button-primary:hover { color: #050605; background: #f9dd50; transform: translateY(-1px); }
.button-quiet { color: #c8cdca; background: rgba(255, 255, 255, .04); }
.button-quiet:hover { color: #fff; background: rgba(255, 255, 255, .08); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}
.stat {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--panel-raised), var(--panel));
  box-shadow: var(--shadow);
}
.stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.stat strong { display: block; margin-top: 8px; color: #fff; font-size: 28px; font-weight: 520; line-height: 1.1; }

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(18, 21, 19, .92);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 22px;
}
.compact-panel { padding-bottom: 4px; }
.panel-heading {
  min-height: 62px;
  padding: 15px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}
.panel-heading h2 { margin: 0; color: #fff; font-size: 17px; line-height: 1.25; }
.panel-heading span, .panel-heading a { color: var(--muted-soft); font-size: 12px; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 12px 16px;
  color: var(--muted-soft);
  background: var(--panel-soft);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.1px;
  text-align: left;
  text-transform: uppercase;
}
td {
  padding: 16px;
  border-top: 1px solid #252a27;
  color: #b6bcb8;
  font-size: 13px;
  vertical-align: middle;
  overflow-wrap: anywhere;
}
tbody tr { transition: background .15s ease; }
tbody tr:hover { background: rgba(255, 255, 255, .025); }
td:first-child { min-width: 310px; width: 48%; }
.item-title { display: block; margin-bottom: 5px; color: #f2f4f2; font-size: 14px; font-weight: 720; line-height: 1.35; text-decoration: none; }
td small { display: block; color: var(--muted-soft); line-height: 1.45; }

.status-form { margin: 0; }
.status {
  width: auto;
  min-width: 116px;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  background: #202521;
  color: #e2e5e3;
  border-radius: 999px;
  padding: 7px 30px 7px 11px;
  font: inherit;
  font-size: 12px;
}
.status-ready, .status-verified, .status-done { border-color: #3d6849; color: #99e5aa; }
.status-in_progress, .status-review { border-color: #756832; color: #f4dc70; }
.status-blocked { border-color: #704040; color: #ff9a9a; }
.doc { display: inline-block; border-radius: 999px; padding: 5px 9px; background: #252a27; color: #bec3c0; font-size: 11px; }
.doc-current { color: #92e2a4; background: #193421; }
.doc-missing, .doc-stale { color: #ff9c9c; background: #381d1d; }
.doc-draft, .doc-review { color: #f0d979; background: #383319; }

.ticket-list {
  display: grid;
  gap: 12px;
  padding: 14px;
}
.ticket-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(290px, .46fr);
  grid-template-areas:
    "content controls"
    "meta controls";
  gap: 12px 24px;
}
.ticket-card:hover { border-color: var(--line-strong); background: #111512; }
.ticket-content { grid-area: content; min-width: 0; }
.ticket-kicker { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 7px; }
.ticket-kicker > a {
  color: var(--yellow);
  font-size: 13px;
  font-weight: 850;
  letter-spacing: .35px;
  text-decoration: none;
}
.priority { border-radius: 999px; padding: 3px 8px; background: #252a27; color: var(--muted); font-size: 10px; font-weight: 750; }
.priority-high { color: #ffaaaa; background: #381d1d; }
.priority-low { color: #aeb6b1; background: #202421; }
.ticket-card .item-title { display: inline; margin: 0; font-size: 17px; line-height: 1.35; }
.ticket-summary { margin: 8px 0 0; color: #aeb5b0; font-size: 14px; line-height: 1.5; white-space: pre-line; }
.ticket-summary-empty { color: var(--muted-soft); font-style: italic; }
.ticket-controls {
  grid-area: controls;
  min-width: 0;
  padding-left: 20px;
  border-left: 1px solid var(--line);
  display: grid;
  align-content: center;
  gap: 12px;
}
.status-form label, .control-label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted-soft);
  font-size: 9px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.ticket-controls .status { width: 100%; min-height: 44px; }
.move-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.move-buttons form { margin: 0; }
.move-button {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: #d7dbd8;
  background: #202521;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}
.move-button:hover:not(:disabled) { border-color: #70672f; color: #fff; background: #292a1d; }
.move-button:disabled { opacity: .35; cursor: not-allowed; }
.ticket-meta {
  grid-area: meta;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 18px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, .055);
}
.ticket-meta > span { min-width: 0; display: flex; align-items: center; gap: 6px; }
.ticket-meta small { color: var(--muted-soft); font-size: 9px; font-weight: 800; letter-spacing: .7px; text-transform: uppercase; }
.ticket-meta strong { min-width: 0; color: #bcc2be; font-size: 11px; font-weight: 650; overflow-wrap: anywhere; }
.ticket-meta .doc { font-size: 10px; }
.ticket-empty { margin: 0; padding: 24px 10px; text-align: center; }

.activity-list { padding: 6px 20px; }
.activity {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 15px 0;
  border-bottom: 1px solid #252a27;
  font-size: 13px;
}
.activity:last-child { border-bottom: 0; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 4px var(--yellow-soft); margin-top: 6px; }
.activity strong { color: #e2e5e3; }
.activity p { color: var(--muted); margin: 4px 0 0; overflow-wrap: anywhere; }
.activity small { color: var(--muted-soft); overflow-wrap: anywhere; }
.activity time { color: var(--muted-soft); font-size: 11px; white-space: nowrap; }
.full-history { padding: 10px 24px; }

.login-card {
  width: min(470px, 100%);
  margin: clamp(12px, 7vh, 72px) auto 0;
  padding: clamp(24px, 6vw, 38px);
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(25, 29, 26, .98), rgba(16, 19, 17, .98));
  border: 1px solid var(--line);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .38);
}
.login-card h1 { margin: 7px 0 10px; color: #fff; font-size: clamp(28px, 8vw, 34px); font-weight: 520; line-height: 1.15; letter-spacing: -.5px; }
.login-card .muted { margin-bottom: 28px; }

label { display: block; margin-bottom: 7px; color: #b7bdb9; font-size: 13px; font-weight: 680; }
input, textarea, select {
  width: 100%;
  max-width: 100%;
  min-height: 44px;
  color: #f2f4f2;
  background: #161a17;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 10px 11px;
  font: inherit;
  font-size: 16px;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(239, 209, 63, .13); }
.login-card .button { width: 100%; margin-top: 14px; }
.code-input { text-align: center; font-size: 25px; letter-spacing: 8px; }
.subtle-link { display: block; padding: 12px; text-align: center; margin-top: 8px; color: var(--muted); font-size: 12px; }
.alert { border-radius: 9px; padding: 11px 13px; margin: 12px 0; font-size: 13px; overflow-wrap: anywhere; }
.alert-error { color: #ffa0a0; border: 1px solid #6b3d3d; background: #2c1818; }

.form-panel { padding: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.field { min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field input[type=checkbox] { width: auto; min-height: auto; }
.field small { display: block; margin-top: 6px; color: var(--muted-soft); font-size: 12px; overflow-wrap: anywhere; }
.field-error { color: var(--red); font-size: 12px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); margin-top: 24px; padding-top: 20px; }

.health-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.health-card { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(145deg, var(--panel-raised), var(--panel)); box-shadow: var(--shadow); }
.health-card.health-ok { border-top: 3px solid var(--green); }
.health-card.health-bad { border-top: 3px solid var(--red); }
.health-title { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.health-title h2 { margin: 0; color: #fff; font-size: 17px; overflow-wrap: anywhere; }
.health-title span { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.health-card > a { display: block; margin: 10px 0 20px; color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.health-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.health-metrics div { min-width: 0; background: var(--panel-soft); border-radius: 8px; padding: 10px; }
.health-metrics small, .health-metrics strong { display: block; overflow-wrap: anywhere; }
.health-metrics small { min-height: 2.5em; color: var(--muted-soft); font-size: 9px; line-height: 1.25; text-transform: uppercase; }
.health-metrics strong { margin-top: 5px; font-size: 14px; }
.checked-at, .empty { color: var(--muted-soft); font-size: 12px; }
.checked-at { margin: 15px 0 0; }

@media (max-width: 900px) {
  .stats-grid, .health-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .site-header { position: static; align-items: flex-start; }
  .site-nav { flex-wrap: wrap; justify-content: flex-end; }
  .ticket-card { grid-template-columns: minmax(0, 1fr) minmax(250px, .58fr); gap: 12px 18px; }
}

@media (max-width: 720px) {
  .site-header {
    display: block;
    padding: 12px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  }
  .brand { width: max-content; max-width: 100%; }
  .brand small { display: none; }
  .site-nav {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 5px;
    margin-top: 10px;
    padding-top: 9px;
    border-top: 1px solid rgba(255, 255, 255, .07);
  }
  .site-nav > a:not(.button), .site-nav .button { min-width: 0; min-height: 42px; padding: 8px 5px; font-size: 12px; white-space: normal; text-align: center; }
  .site-nav > a:not(.button) { justify-content: center; }
  .user-name { display: none; }

  .page-shell {
    width: auto;
    margin: 0;
    padding: 28px max(12px, env(safe-area-inset-right)) calc(52px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  }
  .page-heading { margin-bottom: 22px; }
  .page-heading h1 { font-size: clamp(28px, 9vw, 36px); }
  .heading-row { align-items: stretch; flex-direction: column; gap: 18px; }
  .heading-row > .button, .heading-row > form, .heading-row > form .button { width: 100%; }

  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 15px; }
  .stat strong { font-size: 24px; }

  .panel { border-radius: 12px; }
  .panel-heading { min-height: 56px; padding: 13px 14px; }
  .panel-heading > * { min-width: 0; }

  .ticket-list { gap: 10px; padding: 10px; }
  .ticket-card {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 0;
  }
  .ticket-card .item-title { font-size: 17px; }
  .ticket-summary { font-size: 14px; line-height: 1.52; }
  .ticket-controls {
    padding: 12px 0 0;
    margin-top: 14px;
    border-left: 0;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
    gap: 10px;
  }
  .ticket-meta { order: 3; padding-top: 10px; margin-top: 10px; gap: 7px 12px; }
  .ticket-meta > span:last-child { flex-basis: 100%; }

  .table-wrap { overflow: visible; }
  table, tbody { display: block; width: 100%; }
  thead { display: none; }
  tbody { padding: 10px; }
  tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 16px;
    margin-bottom: 10px;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--panel-soft);
  }
  tbody tr:last-child { margin-bottom: 0; }
  td, td:first-child {
    display: block;
    min-width: 0;
    width: auto;
    padding: 10px 0 0;
    border: 0;
  }
  td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 5px;
    color: var(--muted-soft);
    font-size: 9px;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: 1px;
    text-transform: uppercase;
  }
  td.work-cell { grid-column: 1 / -1; padding: 0 0 9px; border-bottom: 1px solid var(--line); }
  td.work-cell::before { display: none; }
  .item-title { font-size: 15px; }
  .status { width: 100%; min-width: 0; min-height: 44px; }
  .empty { grid-column: 1 / -1; padding: 12px 4px; }
  .empty::before { display: none; }

  .activity-list, .full-history { padding: 4px 14px; }
  .activity { grid-template-columns: 10px minmax(0, 1fr); gap: 11px; }
  .activity time { grid-column: 2; white-space: normal; }

  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 17px; }
  .field-wide { grid-column: auto; }
  .form-panel { padding: 18px 14px; }
  .form-actions { display: grid; grid-template-columns: 1fr 1.4fr; }
  .form-actions .button { width: 100%; }

  .health-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .health-card { padding: 18px 16px; }

  .login-card { margin-top: 8px; padding: 24px; border-radius: 14px; }
}

@media (max-width: 380px) {
  .brand-mark { width: 42px; height: 42px; flex-basis: 42px; }
  .site-nav > a:not(.button), .site-nav .button { font-size: 11px; }
  .stats-grid { gap: 8px; }
  .stat { padding: 13px 12px; }
  .stat span { font-size: 10px; letter-spacing: .7px; }
  tbody tr { padding: 13px; }
  .ticket-card { padding: 14px 13px; }
  .move-button { font-size: 13px; }
  .form-actions { grid-template-columns: 1fr; }
  .health-metrics { gap: 5px; }
  .health-metrics div { padding: 9px 7px; }
  .login-card { padding: 22px 18px; }
}

@media (max-width: 340px) {
  .move-button span { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
