/* ===== Kanban - dark theme ===== */
:root {
  --bg: #14121a;
  --surface: #1c1924;
  --column: #1f1c28;
  --card: #2a2635;
  --card-hover: #322d40;
  --border: #3a3448;
  --text: #ece9f3;
  --muted: #a29bb2;
  --accent: #a993d6;
  --accent-strong: #bba8e6;
  --accent-ink: #1a1424;

  --prio-high: #e5484d;
  --prio-med: #d9a441;
  --prio-low: #6f8fb8;

  --dl-orange: #f0973c;
  --dl-red: #ef5350;
  --dl-overdue-bg: #3d1214;
  --dl-overdue-border: #9b1c1f;
  --dl-overdue-badge: #8b1414;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.spacer { flex: 1; }

/* ----- Buttons & inputs ----- */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--text);
  background: transparent;
  white-space: nowrap;
}
.btn:disabled { opacity: .6; cursor: default; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); }
.btn-ghost { border-color: var(--border); }
.btn-ghost:hover { background: var(--card); }
.btn-danger { border-color: #6b2a2d; color: #ff8a8d; }
.btn-danger:hover { background: #3a1a1c; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input, select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }

.form-error { color: #ff8a8d; min-height: 1.2em; margin: 8px 0 0; font-size: 14px; }

/* ----- Screens ----- */
.screen.center { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-box {
  width: 100%; max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
}
.login-box .btn { width: 100%; margin-top: 18px; }
.brand { color: var(--accent); font-size: 20px; letter-spacing: .3px; }
.login-box .brand { margin-bottom: 8px; }

/* ----- Top bar ----- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.me-name { font-size: 14px; }

/* ----- Board ----- */
.board {
  display: flex;
  gap: 12px;
  padding: 16px;
  overflow-x: auto;
  align-items: flex-start;
  min-height: calc(100vh - 58px);
}
.column {
  flex: 1 0 250px;
  max-width: 360px;
  background: var(--column);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 90px);
}
.column-head {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px 8px;
}
.column-head h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.column-count {
  font-size: 12px; color: var(--muted);
  background: var(--card); border-radius: 999px; padding: 1px 8px;
}
.card-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 12px;
  min-height: 80px;            /* so empty columns still accept drops */
  display: flex; flex-direction: column; gap: 8px;
}

/* ----- Cards ----- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}
.card:hover { background: var(--card-hover); }
.card-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.card-title { font-size: 15px; font-weight: 600; word-break: break-word; }
.card-desc { color: var(--muted); font-size: 13px; margin: 4px 0 0; word-break: break-word; }
.card-hold {
  margin: 6px 0 0; font-size: 13px;
  background: rgba(169,147,214,.12); border-radius: 6px; padding: 4px 8px;
  word-break: break-word;
}
.card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; }

.chip {
  display: inline-block;
  font-size: 12px; font-weight: 600;
  padding: 1px 8px; border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
}
.chip-owner { color: var(--text); }
.chip-notes { font-weight: 500; }

/* Priority labels */
.prio { color: #fff; border: 0; }
.prio-high { background: var(--prio-high); }
.prio-med  { background: var(--prio-med); color: #23180a; }
.prio-low  { background: var(--prio-low); }

/* Deadline colours */
.dl-normal { color: var(--text); }
.dl-orange { color: var(--dl-orange); border-color: var(--dl-orange); }
.dl-red    { color: var(--dl-red);    border-color: var(--dl-red); }
.dl-overdue { color: #ffb3b3; border-color: var(--dl-overdue-border); }
.card.is-orange  { border-left-color: var(--dl-orange); }
.card.is-red     { border-left-color: var(--dl-red); }
.card.is-overdue { background: var(--dl-overdue-bg); border-color: var(--dl-overdue-border); border-left-color: var(--dl-overdue-border); }
.badge-overdue {
  background: var(--dl-overdue-badge); color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: .8px;
  padding: 1px 7px; border-radius: 4px;
}
.card.is-done { opacity: .75; }

/* Drag states (SortableJS) */
.card-ghost { opacity: .35; }
.card-chosen { box-shadow: 0 0 0 2px var(--accent); }
.card-drag { transform: rotate(1.5deg); }

/* ----- Dialogs ----- */
.dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}
.dialog-small { width: min(420px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(5,4,8,.7); }
.dialog h2 { font-size: 18px; margin-bottom: 4px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog-actions { display: flex; gap: 8px; margin-top: 16px; align-items: center; }

/* ----- Toast ----- */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: #3a1a1c; color: #ffd6d7;
  border: 1px solid #6b2a2d;
  padding: 10px 16px; border-radius: 10px;
  z-index: 50; box-shadow: 0 4px 16px rgba(0,0,0,.5);
}
.toast.ok { background: #1f2b22; color: #cdebd3; border-color: #2f5a3a; }

/* ----- Phone ----- */
@media (max-width: 700px) {
  body { font-size: 16px; }             /* avoids iOS zoom on inputs */
  .topbar { padding: 10px 12px; gap: 8px; flex-wrap: wrap; }
  .me-name { display: none; }
  .board {
    padding: 12px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  .column { flex: 0 0 86vw; max-width: none; scroll-snap-align: center; max-height: calc(100vh - 80px); }
  .row { grid-template-columns: 1fr; gap: 0; }
  .dialog { padding: 16px; }
}

/* ===== Phase 2 ===== */
.btn-small { padding: 4px 10px; font-size: 13px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hint { margin: 4px 0 0; }

/* Layout: board + activity panel side by side */
.layout { display: flex; align-items: stretch; }
.layout .board { flex: 1; min-width: 0; }

/* Scheduled cards: greyed out */
.card.is-scheduled { opacity: .6; filter: grayscale(.6); border-style: dashed; }
.card.is-scheduled:hover { opacity: .85; }
.card-activates { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

/* Activity panel */
.activity-panel {
  width: 340px; flex: 0 0 340px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 14px 16px;
  position: sticky; top: 58px;
  height: calc(100vh - 58px);
  overflow-y: auto;
}
.activity-head { display: flex; align-items: center; gap: 8px; }
.activity-head h2 { font-size: 16px; }
.activity-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.activity-item { border-left: 3px solid var(--border); padding: 2px 0 2px 10px; font-size: 14px; word-break: break-word; }
.activity-item.act-put_on_hold { border-left-color: var(--accent); }
.activity-item.act-deleted { border-left-color: var(--prio-high); }
.activity-item.act-auto_activated { border-left-color: var(--prio-low); }
.activity-item.act-overdue_acknowledged { border-left-color: var(--dl-orange); }
.activity-who { font-weight: 600; }
.activity-card { color: var(--accent-strong); }
.activity-detail { color: var(--muted); font-size: 13px; }
.activity-when { color: var(--muted); font-size: 12px; }

/* Column manager */
.columns-list { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.columns-row { display: flex; gap: 6px; align-items: center; }
.columns-row input { flex: 1; }
.columns-row .tag { font-size: 11px; color: var(--muted); width: 56px; text-align: center; }
.column-add { display: flex; gap: 8px; }
.column-add input { flex: 1; }

@media (max-width: 700px) {
  .activity-panel {
    position: fixed; inset: 0; top: 0; z-index: 20;
    width: auto; height: auto; border-left: 0;
  }
  .columns-row .tag { display: none; }
}

/* ===== Phase 2b ===== */
.chip-ack { color: #ffd9a8; border-color: #8a5a1c; }
.overdue-hint {
  margin: 12px 0 0; font-size: 13px;
  background: var(--dl-overdue-bg); border: 1px solid var(--dl-overdue-border);
  border-radius: 8px; padding: 8px 10px;
}

/* ===== Phase 3 ===== */
.filterbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.filterbar label { margin: 0; }
.filterbar select { width: auto; padding: 5px 8px; }
.filterbar.is-active { box-shadow: inset 0 -2px 0 var(--accent); }
.check { display: flex; align-items: flex-start; gap: 8px; color: var(--text); font-size: 14px; cursor: pointer; }
.check input { width: auto; margin-top: 3px; accent-color: var(--accent); }
.filterbar .check { align-items: center; }
.filterbar .check input { margin-top: 0; }
.check-spaced { margin-top: 14px; }

.tools-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.tool {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  text-align: left; font: inherit; color: var(--text);
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; cursor: pointer;
}
.tool:hover { background: var(--card-hover); border-color: var(--accent); }
.tool:disabled { opacity: .6; cursor: default; }
.tool span { color: var(--muted); font-size: 13px; }

.recurring-list { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-direction: column; gap: 8px; }
.recurring-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px;
}
.recurring-item.is-paused { opacity: .6; }
.recurring-main { flex: 1; min-width: 0; }
.recurring-title { font-weight: 600; word-break: break-word; }
.recurring-sub { color: var(--muted); font-size: 13px; }

.radio-group { border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px 12px; margin: 14px 0 0; }
.radio-group legend { color: var(--muted); font-size: 13px; padding: 0 4px; }
.radio-group .check { margin-top: 8px; }

@media (max-width: 700px) {
  .filterbar { padding: 8px 12px; }
  .topbar .btn { padding: 6px 10px; font-size: 14px; }
  .filterbar > label:not(.check) { display: none; }
  #filter-count { width: 100%; }
}
