/* ============================================================
   Штаб-ТМ — design system v1
   Single-user task manager.  Минимализм в стиле Linear / Things.
   ============================================================ */

:root {
  /* ---- Palette ------------------------------------------------ */
  --c-bg:           #f7f8fa;
  --c-surface:      #ffffff;
  --c-surface-2:    #f1f3f5;
  --c-border:       #e4e6eb;
  --c-border-2:     #d0d4db;

  --c-text:         #0f172a;
  --c-text-2:       #475569;
  --c-text-3:       #94a3b8;

  --c-accent:       #2563eb;
  --c-accent-hover: #1d4ed8;
  --c-accent-soft:  #dbeafe;

  --c-success:      #15803d;
  --c-success-soft: #dcfce7;
  --c-warn:         #b45309;
  --c-warn-soft:    #fef3c7;
  --c-danger:       #b91c1c;
  --c-danger-soft:  #fee2e2;
  --c-muted:        #64748b;
  --c-muted-soft:   #f1f5f9;
  --c-violet:       #6d28d9;
  --c-violet-soft:  #ede9fe;

  /* ---- State pills (semantic mapping) ------------------------- */
  --st-idea-fg:     #1e40af;
  --st-idea-bg:     #dbeafe;
  --st-active-fg:   #166534;
  --st-active-bg:   #dcfce7;
  --st-waiting-fg:  #92400e;
  --st-waiting-bg:  #fef3c7;
  --st-done-fg:     #475569;
  --st-done-bg:     #e2e8f0;
  --st-abandoned-fg:#9f1239;
  --st-abandoned-bg:#fee2e2;

  /* ---- Typography -------------------------------------------- */
  --ff-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter",
             "Helvetica Neue", Arial, sans-serif;
  --ff-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", "JetBrains Mono",
             Menlo, Consolas, monospace;

  --fs-xs:   12px;
  --fs-sm:   13px;
  --fs-base: 14px;
  --fs-md:   16px;
  --fs-lg:   18px;
  --fs-xl:   22px;
  --fs-2xl:  28px;

  /* ---- Spacing scale ----------------------------------------- */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;

  /* ---- Radius / shadow / transitions ------------------------- */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;

  --sh-1: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --sh-2: 0 4px 12px rgba(15, 23, 42, 0.08);

  --t: 120ms ease-out;
}

@media (prefers-color-scheme: dark) {
  :root {
    --c-bg:           #0b0f17;
    --c-surface:      #131825;
    --c-surface-2:    #1a2030;
    --c-border:       #232a3a;
    --c-border-2:     #2f384c;

    --c-text:         #e6e9ef;
    --c-text-2:       #9ca3b1;
    --c-text-3:       #6c7689;

    --c-accent:       #3b82f6;
    --c-accent-hover: #60a5fa;
    --c-accent-soft:  #1e3a8a;

    --c-success-soft: #14532d;
    --c-warn-soft:    #78350f;
    --c-danger-soft:  #7f1d1d;
    --c-muted-soft:   #1e293b;
    --c-violet-soft:  #4c1d95;

    --st-idea-fg:     #93c5fd;
    --st-idea-bg:     #1e3a8a;
    --st-active-fg:   #86efac;
    --st-active-bg:   #14532d;
    --st-waiting-fg:  #fcd34d;
    --st-waiting-bg:  #78350f;
    --st-done-fg:     #cbd5e1;
    --st-done-bg:     #334155;
    --st-abandoned-fg:#fda4af;
    --st-abandoned-bg:#7f1d1d;

    --sh-1: 0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
    --sh-2: 0 4px 12px rgba(0, 0, 0, 0.5);
  }
}

/* ============================================================ */
/* Reset + base                                                  */
/* ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html { font-size: 16px; }

body {
  margin: 0;
  font-family: var(--ff-sans);
  font-size: var(--fs-base);
  line-height: 1.55;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 {
  margin: 0 0 var(--s-3);
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--c-text);
}
h1 { font-size: var(--fs-2xl); letter-spacing: -0.02em; }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

p { margin: 0 0 var(--s-3); }

small { font-size: var(--fs-sm); color: var(--c-text-2); }

code, pre {
  font-family: var(--ff-mono);
  font-size: 0.92em;
  background: var(--c-muted-soft);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  padding: 1px 6px;
}
pre {
  padding: var(--s-3) var(--s-4);
  overflow-x: auto;
}

a {
  color: var(--c-accent);
  text-decoration: none;
  transition: color var(--t);
}
a:hover { color: var(--c-accent-hover); text-decoration: underline; }

hr {
  border: none;
  border-top: 1px solid var(--c-border);
  margin: var(--s-6) 0;
}

/* ============================================================ */
/* Layout — top nav + container                                  */
/* ============================================================ */

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  backdrop-filter: saturate(160%) blur(8px);
}

.app-header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--s-6);
  padding: var(--s-3) var(--s-6);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-weight: 700;
  font-size: var(--fs-md);
  color: var(--c-text);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.brand:hover { color: var(--c-text); text-decoration: none; }
.brand-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--c-accent), var(--c-violet));
}

.app-nav {
  display: flex;
  gap: var(--s-1);
  flex: 1;
}
.app-nav a {
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  color: var(--c-text-2);
  font-weight: 500;
  font-size: var(--fs-sm);
  transition: background var(--t), color var(--t);
}
.app-nav a:hover {
  color: var(--c-text);
  background: var(--c-surface-2);
  text-decoration: none;
}
.app-nav a.is-active {
  color: var(--c-text);
  background: var(--c-surface-2);
}

.app-nav-end {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.app-nav-end a {
  color: var(--c-text-3);
  font-size: var(--fs-sm);
}

main.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--s-6);
}

.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--s-5);
  flex-wrap: wrap;
  gap: var(--s-3);
}
.page-header h1 { margin: 0; }
.page-meta { color: var(--c-text-2); font-size: var(--fs-sm); }

/* ============================================================ */
/* Buttons + forms                                               */
/* ============================================================ */

button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  line-height: 1.2;
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: all var(--t);
  text-decoration: none;
  white-space: nowrap;
}
button:hover, .btn:hover {
  background: var(--c-surface-2);
  border-color: var(--c-text-3);
  text-decoration: none;
}
button:active, .btn:active { transform: translateY(0.5px); }
button[disabled], .btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-primary, button[type="submit"] {
  color: white;
  background: var(--c-accent);
  border-color: var(--c-accent);
}
.btn-primary:hover, button[type="submit"]:hover {
  background: var(--c-accent-hover);
  border-color: var(--c-accent-hover);
  color: white;
}

.btn-ghost, button.secondary {
  color: var(--c-text-2);
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover, button.secondary:hover {
  background: var(--c-surface-2);
  color: var(--c-text);
  border-color: transparent;
}

label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--c-text-2);
  margin-bottom: var(--s-2);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
select,
textarea {
  display: block;
  width: 100%;
  padding: var(--s-2) var(--s-3);
  font-family: inherit;
  font-size: var(--fs-base);
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border-2);
  border-radius: var(--r-sm);
  transition: border-color var(--t), box-shadow var(--t);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px var(--c-accent-soft);
}
textarea { resize: vertical; min-height: 80px; font-family: inherit; }

form > * + * { margin-top: var(--s-3); }

/* ============================================================ */
/* Pills / badges                                                */
/* ============================================================ */

.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  font-size: var(--fs-xs);
  font-weight: 500;
  line-height: 1.5;
  border-radius: 999px;
  background: var(--c-muted-soft);
  color: var(--c-text-2);
  white-space: nowrap;
}
.pill-state-idea     { color: var(--st-idea-fg);     background: var(--st-idea-bg); }
.pill-state-active   { color: var(--st-active-fg);   background: var(--st-active-bg); }
.pill-state-waiting  { color: var(--st-waiting-fg);  background: var(--st-waiting-bg); }
.pill-state-done     { color: var(--st-done-fg);     background: var(--st-done-bg); }
.pill-state-abandoned{ color: var(--st-abandoned-fg);background: var(--st-abandoned-bg); }

.tag-dir {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  font-size: var(--fs-xs);
  font-weight: 500;
  border-radius: var(--r-sm);
  color: var(--c-violet);
  background: var(--c-violet-soft);
}

/* ============================================================ */
/* Kanban board                                                  */
/* ============================================================ */

.kanban-toolbar {
  display: flex;
  gap: var(--s-3);
  align-items: end;
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
}
.kanban-toolbar label { margin: 0; }
.kanban-toolbar select { width: auto; min-width: 220px; }

/* 3 фикс-колонки на широком экране (idea / active / waiting).
   Mobile — стопкой. */
.kanban {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3);
}

@media (max-width: 900px) {
  .kanban { grid-template-columns: 1fr; }
}

.kanban-col {
  background: var(--c-surface-2);
  border-radius: var(--r-md);
  padding: var(--s-2);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  min-height: 320px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  scrollbar-width: thin;
}

/* coloured top stripe per column state */
.kanban-col-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-2) var(--s-3);
  margin: 0;
  background: var(--c-surface-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--c-text-2);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 2px solid var(--c-border-2);
}
.kanban-col-header .pill { font-size: 11px; padding: 1px 7px; }

.kanban-col-idea     .kanban-col-header { border-bottom-color: var(--st-idea-fg); }
.kanban-col-active   .kanban-col-header { border-bottom-color: var(--st-active-fg); }
.kanban-col-waiting  .kanban-col-header { border-bottom-color: var(--st-waiting-fg); }
.kanban-col-done     .kanban-col-header { border-bottom-color: var(--st-done-fg); }
.kanban-col-abandoned .kanban-col-header { border-bottom-color: var(--st-abandoned-fg); }

.kanban-collapsed {
  margin-top: var(--s-8);
  border-top: 1px solid var(--c-border);
  padding-top: var(--s-5);
}
.kanban-collapsed summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--c-text-2);
  margin-bottom: var(--s-4);
  list-style: none;
  padding: var(--s-1) 0;
}
.kanban-collapsed summary::-webkit-details-marker { display: none; }
.kanban-collapsed summary::before {
  content: "▸";
  display: inline-block;
  margin-right: var(--s-2);
  color: var(--c-text-3);
  transition: transform var(--t);
}
.kanban-collapsed[open] summary::before { transform: rotate(90deg); }

/* ============================================================ */
/* Card                                                          */
/* ============================================================ */

article.card {
  position: relative;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-border-2);
  border-radius: var(--r-sm);
  padding: var(--s-2) var(--s-3);
  box-shadow: var(--sh-1);
  transition: box-shadow var(--t), border-color var(--t), transform var(--t);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: var(--fs-sm);
}
article.card:hover {
  border-color: var(--c-border-2);
  border-left-color: var(--c-accent);
  box-shadow: var(--sh-2);
}

/* Direction-coloured left stripe — visual anchor */
article.card[data-direction="Абирег"]    { border-left-color: #2563eb; }
article.card[data-direction="АбирегPR"]  { border-left-color: #b45309; }
article.card[data-direction="Личное"]    { border-left-color: #15803d; }
article.card[data-direction="Команда"]   { border-left-color: #6d28d9; }
article.card[data-direction="Спецпроекты"] { border-left-color: #b91c1c; }

article.card header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--s-2);
  font-weight: 500;
}
article.card header strong {
  font-size: var(--fs-sm);
  line-height: 1.35;
  color: var(--c-text);
  font-weight: 600;
  word-break: break-word;
}
article.card .card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  font-size: var(--fs-xs);
  margin-top: 2px;
}
article.card .card-meta .pill,
article.card .card-meta .tag-dir {
  font-size: 10px;
  padding: 1px 6px;
  line-height: 1.4;
}
article.card p {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--c-text-2);
  line-height: 1.5;
}
article.card footer {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed var(--c-border);
  opacity: 0.7;
  transition: opacity var(--t);
}
article.card:hover footer { opacity: 1; }
article.card footer button {
  font-size: 11px;
  padding: 2px 7px;
  line-height: 1.4;
  border-color: transparent;
  color: var(--c-text-2);
}
article.card footer button:hover {
  background: var(--c-accent-soft);
  color: var(--c-accent-hover);
  border-color: transparent;
}

/* ============================================================ */
/* Tables                                                        */
/* ============================================================ */

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  overflow: hidden;
}
thead th {
  text-align: left;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c-text-3);
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border);
  padding: var(--s-2) var(--s-3);
}
tbody td {
  padding: var(--s-3);
  border-bottom: 1px solid var(--c-border);
  font-size: var(--fs-sm);
  color: var(--c-text);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--c-surface-2); }

/* number-only cells */
td:first-child {
  color: var(--c-text-3);
  font-variant-numeric: tabular-nums;
  width: 48px;
}

/* inline number-input inside cells */
tbody td input[type="number"] {
  width: 64px;
  text-align: center;
  padding: 4px 6px;
}

/* ============================================================ */
/* Sections                                                      */
/* ============================================================ */

section + section { margin-top: var(--s-8); }
section > h2 { margin-bottom: var(--s-3); }

/* ============================================================ */
/* Login / Auth page                                             */
/* ============================================================ */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--s-6);
  background:
    radial-gradient(circle at 20% 10%, var(--c-accent-soft) 0, transparent 35%),
    radial-gradient(circle at 80% 90%, var(--c-violet-soft) 0, transparent 35%),
    var(--c-bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  padding: var(--s-8);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2);
}
.auth-card .brand { margin-bottom: var(--s-4); }
.auth-card h1 { font-size: var(--fs-xl); margin-bottom: var(--s-4); }
.auth-card ol { padding-left: 1.2em; }
.auth-card ol li { margin-bottom: var(--s-2); color: var(--c-text-2); }
.auth-card .cta {
  margin-top: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}
.auth-card .cta .btn-primary {
  justify-content: center;
  padding: var(--s-3) var(--s-4);
  font-size: var(--fs-base);
}
.auth-card .footnote { color: var(--c-text-3); font-size: var(--fs-xs); margin-top: var(--s-4); }

.alert {
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  margin-bottom: var(--s-3);
}
.alert-error { color: var(--c-danger); background: var(--c-danger-soft); }
.alert-info  { color: var(--c-text-2); background: var(--c-muted-soft); }

/* ============================================================ */
/* Modal (dialog)                                                */
/* ============================================================ */

dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  padding: 0;
  border: none;
  background: transparent;
  max-width: 480px;
  width: calc(100% - 32px);
  z-index: 50;
}
dialog::backdrop { background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(2px); }
dialog article {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  padding: var(--s-5);
  box-shadow: var(--sh-2);
}
dialog header h3 { margin-bottom: var(--s-3); }
dialog footer {
  display: flex;
  gap: var(--s-2);
  justify-content: flex-end;
  margin-top: var(--s-4);
}

/* ============================================================ */
/* HTMX indicator                                                */
/* ============================================================ */

.htmx-indicator { display: none; font-size: var(--fs-xs); color: var(--c-text-3); }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: inline-block; }

/* ============================================================ */
/* Mobile                                                        */
/* ============================================================ */

@media (max-width: 640px) {
  .app-header-inner { padding: var(--s-2) var(--s-3); gap: var(--s-3); }
  .app-nav { overflow-x: auto; }
  main.container { padding: var(--s-4) var(--s-3); }
  h1 { font-size: var(--fs-xl); }
  .kanban { gap: var(--s-3); }
  .kanban-col { padding: var(--s-2); }
  table { font-size: var(--fs-xs); }
  tbody td { padding: var(--s-2); }
  thead th { padding: var(--s-2); }
}

/* ============================================================ */
/* Utilities                                                     */
/* ============================================================ */

.text-muted { color: var(--c-text-3); }
.text-small { font-size: var(--fs-sm); }
.empty-state {
  padding: var(--s-8) var(--s-4);
  text-align: center;
  color: var(--c-text-3);
  background: var(--c-surface);
  border: 1px dashed var(--c-border-2);
  border-radius: var(--r-md);
}
.flex { display: flex; gap: var(--s-3); align-items: center; }
.flex-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
