/* =========================================================
   SMART TASK MANAGER — "Drafting Table" design system
   Dark graphite table + cyanotype blueprint sheets + brass accents
   ========================================================= */

:root {
  --table: #10151d;

  --blue-900: #0e2c54;
  --blue-800: #123a6c;
  --blue-700: #17457f;
  --blue-line: rgba(234,242,255,0.22);
  --blue-line-strong: rgba(234,242,255,0.4);

  --paper: #eaf2ff;
  --paper-dim: #9fb7dc;
  --paper-faint: #6c85ac;

  --brass: #e3a53d;
  --brass-hi: #f2bd5e;
  --brass-ink: #2a1c05;

  --stamp-pending: #e2665a;
  --stamp-progress: #e3a53d;
  --stamp-done: #6fd3a3;

  --priority-low: #6fd3a3;
  --priority-medium: #e3a53d;
  --priority-high: #e2665a;

  --f-display: 'Space Grotesk', 'Segoe UI', sans-serif;
  --f-body: 'Inter', 'Segoe UI', sans-serif;
  --f-mono: 'IBM Plex Mono', 'Courier New', monospace;

  --radius-sheet: 3px;
  --shadow-lift: 0 18px 30px -14px rgba(0,0,0,0.55);
}

* { box-sizing: border-box; }

/* Guarantees the HTML `hidden` attribute always wins, even on elements
   whose class also sets an explicit `display` (e.g. .app, .fab,
   .auth-screen use display:flex/inline-flex — without this rule, that
   explicit display would silently override the browser's default
   [hidden]{display:none} and the element would stay visible). */
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse at 20% -10%, rgba(255,255,255,0.035), transparent 45%),
    var(--table);
  background-attachment: fixed;
  color: var(--paper);
  font-family: var(--f-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

button, input, textarea, select { font-family: inherit; color: inherit; }
a { color: var(--brass-hi); }

:focus-visible { outline: 2px solid var(--brass-hi); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

.muted { color: var(--paper-faint); font-size: 0.85rem; }

/* ============ FORM CONTROLS (shared) ============ */

.select, input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="search"], textarea {
  background: var(--blue-900);
  border: 1px solid var(--blue-line-strong);
  border-radius: 2px;
  color: var(--paper);
  padding: 9px 11px;
  font-size: 0.88rem;
  width: 100%;
}

input::placeholder, textarea::placeholder { color: var(--paper-faint); }

.field { display: block; margin-bottom: 16px; }
.field > span, .field legend {
  display: block;
  font-family: var(--f-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper-dim);
  margin-bottom: 6px;
}
.field em { color: var(--stamp-pending); font-style: normal; }
.field textarea { resize: vertical; min-height: 70px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.checkbox-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.checkbox-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--blue-line-strong);
  border-radius: 16px;
  padding: 5px 12px 5px 8px;
  font-size: 0.78rem;
  cursor: pointer;
}

.checkbox-chip input {
  accent-color: var(--brass);
  cursor: pointer;
}

.task-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.tag-chip {
  font-family: var(--f-mono);
  font-size: 0.62rem;
  letter-spacing: 0.03em;
  color: var(--paper-dim);
  border: 1px solid var(--blue-line-strong);
  border-radius: 10px;
  padding: 1px 7px;
}

.btn-icon {
  width: 30px; height: 30px; flex-shrink: 0;
  border-radius: 2px;
  border: 1px solid var(--blue-line-strong);
  background: transparent;
  color: var(--paper);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.btn-icon:hover { background: rgba(255,255,255,0.08); }
.btn-icon:active { transform: scale(0.94); }
.btn-icon[disabled] { opacity: 0.35; cursor: not-allowed; }

.btn {
  border-radius: 2px;
  padding: 9px 16px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.1s ease, background 0.15s ease, border-color 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn--block { width: 100%; }
.btn--primary { background: var(--brass); color: var(--brass-ink); }
.btn--primary:hover { background: var(--brass-hi); }
.btn--ghost { background: transparent; border-color: var(--blue-line-strong); color: var(--paper); }
.btn--ghost:hover { background: rgba(255,255,255,0.06); }
.btn--danger { background: transparent; border-color: var(--stamp-pending); color: var(--stamp-pending); }
.btn--danger:hover { background: rgba(226,102,90,0.12); }

/* ============ AUTH SCREEN ============ */

.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-image:
    linear-gradient(var(--blue-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--blue-line) 1px, transparent 1px);
  background-size: 34px 34px;
  background-position: center;
  background-color: var(--table);
  opacity: 1;
}

.auth-card {
  width: min(400px, 100%);
  background: var(--blue-800);
  border: 1px solid var(--blue-line-strong);
  border-radius: var(--radius-sheet);
  padding: 32px 28px;
  box-shadow: var(--shadow-lift);
  animation: sheet-in 0.4s ease both;
}

.auth-card__eyebrow {
  font-family: var(--f-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass-hi);
  margin: 0 0 8px;
}

.auth-card__title {
  font-family: var(--f-display);
  font-size: 1.5rem;
  margin: 0 0 22px;
}

.auth-tabs {
  display: flex;
  border: 1px solid var(--blue-line-strong);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 22px;
}

.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--paper-dim);
  padding: 10px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--f-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.auth-tab.is-active {
  background: var(--brass);
  color: var(--brass-ink);
}

.auth-error {
  color: var(--stamp-pending);
  font-size: 0.8rem;
  margin: -6px 0 14px;
}

.auth-settings {
  display: block;
  margin: 18px auto 0;
  background: none;
  border: none;
  color: var(--paper-faint);
  font-size: 0.74rem;
  text-decoration: underline;
  cursor: pointer;
}

/* ============ POPOVERS ============ */

.popover {
  position: fixed;
  top: 90px;
  right: 32px;
  z-index: 60;
  width: 300px;
  background: var(--blue-800);
  border: 1px solid var(--blue-line-strong);
  border-radius: var(--radius-sheet);
  padding: 18px;
  box-shadow: var(--shadow-lift);
  animation: pop-in 0.16s ease both;
}
.popover--center {
  top: 50%; left: 50%; right: auto;
  transform: translate(-50%, -50%);
}
.popover__title {
  margin: 0 0 12px;
  font-family: var(--f-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-dim);
}
.popover__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

/* ============ APP SHELL ============ */

.app { max-width: 1400px; margin: 0 auto; padding: 28px 32px 80px; }

.title-block {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: space-between;
  gap: 16px;
  background: var(--blue-800);
  border: 1px solid var(--blue-line);
  border-radius: var(--radius-sheet);
  padding: 20px 24px;
  box-shadow: var(--shadow-lift);
  position: relative;
  animation: sheet-in 0.5s ease both;
}

.title-block__id { position: relative; }
.title-block__name {
  font-family: var(--f-display);
  font-size: clamp(1.4rem, 2.2vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
}
.title-block__caption {
  margin: 0;
  font-family: var(--f-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--paper-dim);
}

.title-block__cells { display: flex; gap: 0; align-items: center; flex-wrap: wrap; }

.cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  padding: 4px 20px;
  border-left: 1px dashed var(--blue-line-strong);
  min-width: 120px;
}
.cell:first-child { border-left: none; }
.cell__label {
  font-family: var(--f-mono);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--paper-faint);
}
.cell__value { font-family: var(--f-mono); font-size: 0.88rem; color: var(--paper); }
.cell__link { text-decoration: none; }
.cell__link:hover { text-decoration: underline; }

.status-pill {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent;
  border: 1px solid var(--blue-line-strong);
  border-radius: 20px;
  padding: 7px 14px;
  cursor: pointer;
  font-family: var(--f-mono);
  font-size: 0.76rem;
  color: var(--paper);
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--paper-faint); transition: background 0.2s, box-shadow 0.2s; }
.status-dot--online { background: var(--stamp-done); box-shadow: 0 0 8px rgba(111,211,163,0.7); }
.status-dot--offline { background: var(--stamp-pending); box-shadow: 0 0 8px rgba(226,102,90,0.7); }

/* ============ DASHBOARD STAT ROW ============ */

.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-top: 18px;
}

.stat-card {
  position: relative;
  background: var(--blue-800);
  border: 1px solid var(--blue-line);
  border-left: 3px solid var(--brass);
  border-radius: var(--radius-sheet);
  padding: 14px 16px;
  animation: sheet-in 0.5s ease 0.05s both;
}

.stat-card--pending { border-left-color: var(--stamp-progress); }
.stat-card--done { border-left-color: var(--stamp-done); }
.stat-card--high { border-left-color: var(--stamp-pending); }

.stat-card__label {
  display: block;
  font-family: var(--f-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper-faint);
  margin-bottom: 6px;
}

.stat-card__value {
  font-family: var(--f-display);
  font-size: 1.9rem;
  font-weight: 700;
}

/* ============ WORKSPACE ============ */

.workspace {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 20px;
  margin-top: 20px;
  align-items: start;
}

.layers-rail {
  background: var(--blue-800);
  border: 1px solid var(--blue-line);
  border-radius: var(--radius-sheet);
  padding: 18px;
  position: sticky;
  top: 20px;
  animation: sheet-in 0.5s ease 0.08s both;
}

.rail-heading { font-family: var(--f-display); font-size: 1rem; margin: 0 0 2px; }
.rail-sub { margin: 0 0 14px; font-size: 0.76rem; color: var(--paper-faint); }

.layer-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 4px; }

.layer-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border-radius: 2px;
  font-size: 0.84rem;
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  width: 100%;
  text-align: left;
  color: var(--paper);
}
.layer-item:hover { background: rgba(255,255,255,0.05); }
.layer-item.is-active { background: rgba(227,165,61,0.14); border-color: var(--brass); }

.layer-item__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-item__count {
  font-family: var(--f-mono);
  font-size: 0.68rem;
  color: var(--paper-faint);
  background: rgba(255,255,255,0.06);
  border-radius: 10px;
  padding: 1px 7px;
}

.layer-item__del {
  opacity: 0;
  background: none; border: none;
  color: var(--paper-faint);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  padding: 2px 4px;
  transition: opacity 0.12s ease, color 0.12s ease;
}
.layer-row { display: flex; align-items: center; width: 100%; }
.layer-row:hover .layer-item__del { opacity: 1; }
.layer-item__del:hover { color: var(--stamp-pending); }

.layer-add { display: flex; gap: 6px; border-top: 1px dashed var(--blue-line-strong); padding-top: 12px; }
.layer-add input { flex: 1; font-size: 0.8rem; padding: 7px 8px; }

.rail-divider { border-top: 1px dashed var(--blue-line-strong); margin: 18px 0 14px; }

/* ============ LEDGER (task table) ============ */

.ledger {
  background: var(--blue-800);
  border: 1px solid var(--blue-line);
  border-radius: var(--radius-sheet);
  padding: 16px;
  animation: sheet-in 0.5s ease 0.1s both;
}

.ledger__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.search-input { flex: 1; min-width: 180px; }
.select--auto { width: auto; min-width: 140px; }

.ledger__table-wrap {
  overflow-x: auto;
  border: 1px solid var(--blue-line);
  border-radius: 2px;
}

.ledger__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  min-width: 720px;
}

.ledger__table thead th {
  text-align: left;
  font-family: var(--f-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper-faint);
  padding: 10px 12px;
  border-bottom: 1px solid var(--blue-line-strong);
  background: rgba(255,255,255,0.03);
}

.ledger__table td {
  padding: 11px 12px;
  border-bottom: 1px dashed var(--blue-line);
  vertical-align: middle;
}

.ledger__table tbody tr:hover { background: rgba(255,255,255,0.03); }
.ledger__table tbody tr:last-child td { border-bottom: none; }

.col-num { width: 56px; font-family: var(--f-mono); color: var(--paper-faint); }
.col-actions { width: 110px; }

.task-title { font-weight: 600; }
.task-desc {
  display: block;
  font-size: 0.76rem;
  color: var(--paper-faint);
  margin-top: 2px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--f-mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 12px;
  border: 1px solid currentColor;
}

.chip::before {
  content: "";
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.chip--priority-low { color: var(--priority-low); }
.chip--priority-medium { color: var(--priority-medium); }
.chip--priority-high { color: var(--priority-high); }

.chip--status-todo { color: var(--paper-dim); }
.chip--status-in-progress { color: var(--stamp-progress); }
.chip--status-completed { color: var(--stamp-done); }

.due-cell { font-family: var(--f-mono); font-size: 0.78rem; color: var(--paper-dim); }
.due-cell--overdue { color: var(--stamp-pending); font-weight: 600; }

.row-actions { display: flex; gap: 4px; }
.row-actions button {
  background: none; border: none;
  color: var(--paper-faint);
  font-family: var(--f-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 2px;
}
.row-actions button:hover { color: var(--paper); background: rgba(255,255,255,0.08); }
.row-actions .row-del:hover { color: var(--stamp-pending); }

.ledger-empty {
  text-align: center;
  padding: 36px 12px;
  font-family: var(--f-mono);
  font-size: 0.8rem;
  color: var(--paper-faint);
}

.ledger__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.ledger__count { font-family: var(--f-mono); font-size: 0.76rem; color: var(--paper-faint); }

.pagination { display: flex; align-items: center; gap: 10px; }
.pagination__label { font-family: var(--f-mono); font-size: 0.78rem; color: var(--paper-dim); }

/* ============ FAB ============ */

.fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--brass);
  color: var(--brass-ink);
  border: none;
  border-radius: 30px;
  padding: 14px 22px 14px 16px;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  box-shadow: 0 12px 24px -8px rgba(227,165,61,0.55);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.fab:hover { transform: translateY(-2px); box-shadow: 0 16px 28px -8px rgba(227,165,61,0.65); }
.fab:active { transform: translateY(0) scale(0.97); }
.fab__plus { font-size: 1.15rem; line-height: 1; }
.fab[disabled] { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

/* ============ DRAWER ============ */

.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgba(4,8,14,0.55);
  backdrop-filter: blur(2px);
  z-index: 45;
  animation: fade-in 0.18s ease both;
}

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: min(420px, 92vw);
  background: var(--blue-800);
  border-left: 1px solid var(--blue-line-strong);
  z-index: 50;
  padding: 26px 24px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(.16,.84,.44,1);
}
.drawer.is-open { transform: translateX(0); }

.drawer__head { display: flex; flex-direction: column; position: relative; margin-bottom: 20px; }
.drawer__eyebrow {
  font-family: var(--f-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass-hi);
  margin: 0 0 4px;
}
.drawer__head h2 { font-family: var(--f-display); margin: 0; font-size: 1.3rem; }
.drawer__head .btn-icon { position: absolute; top: -4px; right: 0; }

.drawer__footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 24px; padding-top: 16px;
  border-top: 1px dashed var(--blue-line-strong);
}
.drawer__footer-right { display: flex; gap: 8px; margin-left: auto; }

/* ============ TOASTS ============ */

.toast-region {
  position: fixed; bottom: 24px; left: 24px; z-index: 70;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--blue-900);
  border: 1px solid var(--blue-line-strong);
  border-left: 3px solid var(--brass);
  border-radius: 2px;
  padding: 10px 16px;
  font-size: 0.82rem;
  max-width: 320px;
  box-shadow: var(--shadow-lift);
  animation: toast-in 0.2s ease both;
}
.toast--error { border-left-color: var(--stamp-pending); }
.toast--success { border-left-color: var(--stamp-done); }

/* ============ ANIMATIONS ============ */

@keyframes sheet-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ============ RESPONSIVE ============ */

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .layers-rail { position: static; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .title-block__cells { width: 100%; justify-content: space-between; }
  .cell { padding: 4px 12px; min-width: unset; }
}

@media (max-width: 520px) {
  .app { padding: 18px 14px 90px; }
  .title-block { padding: 16px; }
  .field-row { grid-template-columns: 1fr; }
  .popover:not(.popover--center) { left: 14px; right: 14px; width: auto; }
  .stat-row { grid-template-columns: 1fr; }
}
