/* ============================================================
   Design tokens
   A utility/ops tool — restrained palette, one confident accent
   used only for interactive/primary elements, priority colour
   is a real structural signal (not decoration).
   ============================================================ */
:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --ink: #171A21;
  --ink-muted: #5B6270;
  --ink-faint: #8890A0;
  --border: #E1E4EA;
  --border-strong: #C7CBD4;

  --accent: #3A4CB2;
  --accent-ink: #FFFFFF;
  --accent-soft: #E8EAF7;

  --priority-low: #6B9080;
  --priority-medium: #C98A2B;
  --priority-high: #C1443C;
  --priority-urgent: #A61B29;

  --danger: #C1443C;
  --success: #2E7D5B;

  --radius: 6px;
  --radius-sm: 4px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161C;
    --surface: #1C1F27;
    --ink: #EDEFF3;
    --ink-muted: #9AA0AE;
    --ink-faint: #6A7080;
    --border: #2A2E38;
    --border-strong: #3A3F4B;
    --accent-soft: #232A4D;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161C;
  --surface: #1C1F27;
  --ink: #EDEFF3;
  --ink-muted: #9AA0AE;
  --ink-faint: #6A7080;
  --border: #2A2E38;
  --border-strong: #3A3F4B;
  --accent-soft: #232A4D;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
html { scroll-padding-top: env(safe-area-inset-top, 0px); }

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}
button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   PIN gate
   ============================================================ */
.pin-screen {
  height: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-5);
  text-align: center;
}
.pin-screen h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}
.pin-screen p {
  color: var(--ink-muted);
  margin: 0;
  max-width: 32ch;
}
.pin-dots {
  display: flex;
  gap: var(--space-2);
}
.pin-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  background: transparent;
  transition: background .12s ease, border-color .12s ease;
}
.pin-dot.filled {
  background: var(--accent);
  border-color: var(--accent);
}
.pin-dot.error {
  border-color: var(--danger);
  background: var(--danger);
}
.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 64px);
  gap: var(--space-3);
}
.pin-key {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 20px;
  color: var(--ink);
}
.pin-key:active { background: var(--accent-soft); }
.pin-key.pin-key--action {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 13px;
}
.pin-error-msg {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
}

/* ============================================================
   App shell
   ============================================================ */
.app-header {
  position: sticky;
  top: 0;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.app-header__row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}
.app-header__title {
  font-weight: 700;
  font-size: 16px;
  flex: 1;
}
.icon-btn {
  border: none;
  background: transparent;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-muted);
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }

.search-bar {
  padding: 0 var(--space-4) var(--space-3);
}
.search-bar input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}

/* Column tab strip (mobile) */
.column-tabs {
  display: flex;
  overflow-x: auto;
  gap: var(--space-1);
  padding: 0 var(--space-3) var(--space-2);
  scrollbar-width: none;
}
.column-tabs::-webkit-scrollbar { display: none; }
.column-tab {
  flex: none;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 600;
  padding: var(--space-2) var(--space-3);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.column-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.column-tab__count {
  color: var(--ink-faint);
  font-weight: 400;
  margin-left: 4px;
}

/* ============================================================
   Board
   ============================================================ */
.board {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  height: calc(100% - 1px);
  -webkit-overflow-scrolling: touch;
}
.column {
  flex: 0 0 100%;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: var(--space-3);
  overflow-y: auto;
}
@media (min-width: 900px) {
  .board { scroll-snap-type: none; }
  .column { flex: 1 1 280px; max-width: 340px; border-right: 1px solid var(--border); }
  .column-tabs { display: none; }
}

.column__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-1) var(--space-3);
}
.column__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.column__name {
  font-weight: 700;
  font-size: 14px;
  flex: 1;
}
.column__count {
  color: var(--ink-faint);
  font-size: 12px;
}
.column__wip-warning {
  color: var(--danger);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 40px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--priority-medium);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  cursor: grab;
}
.card.sortable-ghost { opacity: .4; }
.card.sortable-chosen { box-shadow: 0 2px 10px rgba(20,20,30,.12); }
.card[data-priority="low"] { border-left-color: var(--priority-low); }
.card[data-priority="medium"] { border-left-color: var(--priority-medium); }
.card[data-priority="high"] { border-left-color: var(--priority-high); }
.card[data-priority="urgent"] { border-left-color: var(--priority-urgent); }

.card__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
}
.card__code {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-faint);
}
.card__title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}
.card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}
.label-chip {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}
.avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--border-strong);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
}

.empty-column {
  color: var(--ink-faint);
  font-size: 13px;
  text-align: center;
  padding: var(--space-5) 0;
}

/* FAB */
.fab {
  position: fixed;
  right: var(--space-4);
  bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 26px;
  box-shadow: 0 4px 14px rgba(58,76,178,.35);
  z-index: 20;
}

/* ============================================================
   Ticket detail sheet
   ============================================================ */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10,10,15,.4);
  z-index: 30;
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-height: 88vh;
  background: var(--surface);
  border-radius: 16px 16px 0 0;
  padding: var(--space-4);
  padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
  overflow-y: auto;
  z-index: 31;
}
@media (min-width: 900px) {
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    transform: translate(-50%, -50%);
    width: 480px;
    max-height: 80vh;
    border-radius: var(--radius);
  }
}
.sheet__handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--border-strong);
  margin: 0 auto var(--space-4);
}
@media (min-width: 900px) { .sheet__handle { display: none; } }

.field {
  margin-bottom: var(--space-4);
}
.field label {
  display: block;
  font-size: 12px;
  color: var(--ink-muted);
  margin-bottom: var(--space-1);
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
}
.field-redacted {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  color: var(--ink-faint);
  font-size: 13px;
}

.move-to-list { display: flex; flex-direction: column; gap: var(--space-1); }
.move-to-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  border: none;
  background: transparent;
  text-align: left;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--ink);
}
.move-to-item:hover { background: var(--accent-soft); }
.move-to-item.current { color: var(--ink-faint); }

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  font-size: 14px;
}
.btn--primary { background: var(--accent); color: var(--accent-ink); width: 100%; }
.btn--ghost { background: transparent; color: var(--ink-muted); width: 100%; }
.btn--danger { background: transparent; color: var(--danger); }

.toast {
  position: fixed;
  bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--surface);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  font-size: 13px;
  z-index: 40;
  display: flex;
  gap: var(--space-3);
  align-items: center;
}
.toast button { background: none; border: none; color: var(--accent-soft); font-weight: 700; }

.offline-banner {
  background: #F4E3BF;
  color: #5A4008;
  font-size: 12px;
  text-align: center;
  padding: var(--space-1);
}

.settings-list { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); }
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
