/* ==========================================================================
   MyDay design system
   Order: tokens -> reset -> layout -> primitives -> components -> utilities
   Rule: component styles never hardcode a colour. Add a token instead.
   ========================================================================== */

/* --- Tokens ------------------------------------------------------------- */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e7eaf3;
  --overlay: rgba(15, 23, 42, 0.45);

  --text: #16192b;
  --text-muted: #5d6480;
  --text-subtle: #868da6;
  --text-inverse: #ffffff;

  --border: #e2e5f0;
  --border-strong: #ccd1e3;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-text: #4338ca;

  --success: #0f9d6f;
  --success-soft: #e3f7ef;
  --warning: #c2820b;
  --warning-soft: #fdf3dd;
  --danger: #dc3a52;
  --danger-soft: #fdeaee;
  --info: #2a7fd4;
  --info-soft: #e7f1fd;

  --status-todo: #7c89a8;
  --status-in-progress: #2a7fd4;
  --status-blocked: #dc3a52;
  --status-done: #0f9d6f;
  --status-cancelled: #9aa1b8;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-full: 999px;

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

  --shadow-sm: 0 1px 2px rgba(19, 23, 44, 0.06);
  --shadow: 0 2px 8px rgba(19, 23, 44, 0.07);
  --shadow-lg: 0 12px 32px rgba(19, 23, 44, 0.14);

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

  --sidebar-w: 236px;
  --header-h: 60px;
  --transition: 140ms ease;
}

[data-theme="dark"] {
  --bg: #0e1119;
  --surface: #161a25;
  --surface-2: #1d2230;
  --surface-3: #262c3d;
  --overlay: rgba(0, 0, 0, 0.6);

  --text: #e9ecf5;
  --text-muted: #a2aac4;
  --text-subtle: #7b8399;
  --text-inverse: #0e1119;

  --border: #272d3d;
  --border-strong: #38405a;

  --accent: #7c74ff;
  --accent-hover: #8f88ff;
  --accent-soft: #23254a;
  --accent-text: #b3aeff;

  --success: #34d399;
  --success-soft: #15342a;
  --warning: #f4c15d;
  --warning-soft: #372d14;
  --danger: #f87f92;
  --danger-soft: #3a1d25;
  --info: #67aaf0;
  --info-soft: #152943;

  --status-todo: #8d97b2;
  --status-in-progress: #67aaf0;
  --status-blocked: #f87f92;
  --status-done: #34d399;
  --status-cancelled: #6b7386;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
}

/* --- Reset -------------------------------------------------------------- */

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

html,
body {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

h1 {
  font-size: 1.5rem;
}
h2 {
  font-size: 1.15rem;
}
h3 {
  font-size: 1rem;
}

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

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--accent-text);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

ul,
ol {
  margin: 0;
  padding-left: 1.25rem;
}

img,
svg {
  max-width: 100%;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

::selection {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* --- App shell ---------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-3);
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3) var(--space-4);
  color: var(--text);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(140deg, var(--accent), #8b5cf6);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  padding: var(--space-4) var(--space-3) var(--space-1);
  font-size: 0.68rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-subtle);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-weight: 520;
  font-size: 0.925rem;
  transition: background var(--transition), color var(--transition);
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}

.nav-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.nav-item svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.nav-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.nav-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: var(--header-h);
  padding: var(--space-3) var(--space-5);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar-title h1 {
  font-size: 1.2rem;
}

.topbar-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.content {
  flex: 1;
  padding: var(--space-5);
  max-width: 1400px;
  width: 100%;
}

.content-narrow {
  max-width: 820px;
}

/* --- Buttons ------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 550;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition),
    transform var(--transition), box-shadow var(--transition);
}

.btn:hover {
  background: var(--surface-2);
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  color: var(--danger);
  border-color: var(--border);
}

.btn-danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

.btn-sm {
  padding: 0.3rem 0.6rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn-icon {
  padding: 0.4rem;
  width: 32px;
  height: 32px;
}

.btn-block {
  width: 100%;
}

.btn-group {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
  gap: 2px;
}

.btn-group .btn {
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.btn-group .btn.is-active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* --- Forms -------------------------------------------------------------- */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.field:last-child {
  margin-bottom: 0;
}

.label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.label-hint {
  font-weight: 450;
  color: var(--text-subtle);
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.925rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-subtle);
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.input-lg {
  padding: 0.7rem 0.85rem;
  font-size: 1rem;
}

.textarea {
  resize: vertical;
  min-height: 84px;
  line-height: 1.5;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235d6480' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  padding-right: 2rem;
}

.help {
  font-size: 0.8rem;
  color: var(--text-subtle);
}

.error-text {
  font-size: 0.82rem;
  color: var(--danger);
}

.field-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-4);
}

.check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.9rem;
  cursor: pointer;
}

.check input[type="checkbox"],
.check input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.color-swatch {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-full);
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--transition);
}

.color-swatch:hover {
  transform: scale(1.12);
}

.color-swatch input {
  position: absolute;
  opacity: 0;
  inset: 0;
  cursor: pointer;
}

.color-swatch:has(input:checked) {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface) inset;
}

/* --- Cards and panels --------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-pad {
  padding: var(--space-5);
}

.card-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.card-header h2 {
  font-size: 1rem;
}

.card-header .spacer {
  margin-left: auto;
}

.card-body {
  padding: var(--space-5);
}

.card-title {
  font-weight: 620;
}

.section {
  margin-bottom: var(--space-6);
}

.section:last-child {
  margin-bottom: 0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  font-size: 0.78rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-subtle);
}

/* --- Stats -------------------------------------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.stat {
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.stat-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  margin-top: var(--space-1);
  font-size: 1.75rem;
  font-weight: 680;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.stat-meta {
  font-size: 0.82rem;
  color: var(--text-subtle);
}

/* --- Badges and pills --------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-blocked {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-cancelled {
  background: var(--surface-3);
  color: var(--text-subtle);
}

.badge-neutral {
  background: var(--surface-2);
  color: var(--text-muted);
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.badge-success {
  background: var(--success-soft);
  color: var(--success);
}

.badge-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-info {
  background: var(--info-soft);
  color: var(--info);
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--surface-2);
  font-size: 0.72rem;
  font-weight: 550;
  color: var(--text-muted);
}

.tag-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.priority-flag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 620;
}

.priority-urgent {
  color: var(--danger);
}
.priority-high {
  color: var(--warning);
}
.priority-medium {
  color: var(--text-muted);
}
.priority-low {
  color: var(--text-subtle);
}

.project-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
  display: inline-block;
}

/* --- Kanban board ------------------------------------------------------- */

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(280px, 1fr));
  gap: var(--space-4);
  align-items: start;
}

.board-column {
  display: flex;
  flex-direction: column;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  min-height: 180px;
  transition: background var(--transition), border-color var(--transition);
}

.board-column.is-drop-target {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.board-column-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: 0.8rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.board-column-head .count {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0;
}

.column-marker {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
}

.column-todo .column-marker {
  background: var(--status-todo);
}
.column-in_progress .column-marker {
  background: var(--status-in-progress);
}
.column-done .column-marker {
  background: var(--status-done);
}

.board-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: 0 var(--space-3) var(--space-3);
  min-height: 60px;
}

.task-card {
  position: relative;
  display: block;
  padding: var(--space-3) var(--space-4);
  padding-left: calc(var(--space-4) + 3px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  color: inherit;
  cursor: grab;
  transition: box-shadow var(--transition), transform var(--transition),
    border-color var(--transition);
}

.task-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
  text-decoration: none;
}

.task-card.is-dragging {
  opacity: 0.45;
  cursor: grabbing;
}

.task-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--card-color, var(--accent));
}

.task-card-title {
  font-weight: 560;
  font-size: 0.92rem;
  line-height: 1.4;
  margin-bottom: var(--space-2);
  overflow-wrap: anywhere;
}

.task-card.is-cancelled .task-card-title {
  text-decoration: line-through;
  color: var(--text-subtle);
}

.task-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.75rem;
  color: var(--text-subtle);
}

.task-card-project {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 550;
  color: var(--text-muted);
}

.task-card-foot {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-2);
  border-top: 1px dashed var(--border);
  font-size: 0.74rem;
  color: var(--text-subtle);
}

.task-card-foot .spacer {
  margin-left: auto;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.meta-chip svg {
  width: 12px;
  height: 12px;
}

.meta-overdue {
  color: var(--danger);
  font-weight: 600;
}

.meta-due-soon {
  color: var(--warning);
  font-weight: 600;
}

.progress {
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent);
  transition: width 240ms ease;
}

/* --- Tables ------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.table th {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  font-size: 0.74rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: var(--surface-2);
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table tfoot td {
  padding: var(--space-3);
  font-weight: 650;
  border-top: 2px solid var(--border-strong);
}

.table-compact td,
.table-compact th {
  padding: var(--space-2) var(--space-3);
}

/* --- Weekly grid -------------------------------------------------------- */

.grid-cell-input {
  width: 62px;
  padding: 0.3rem 0.35rem;
  text-align: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--transition), background var(--transition);
}

.grid-cell-input:hover {
  border-color: var(--border-strong);
}

.grid-cell-input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.grid-cell-input.is-filled {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.grid-cell-input.is-saved {
  animation: cell-flash 700ms ease;
}

.col-today {
  background: color-mix(in srgb, var(--accent) 7%, transparent);
}

@keyframes cell-flash {
  0% {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 45%, transparent);
  }
  100% {
    box-shadow: 0 0 0 3px transparent;
  }
}

/* --- Flash messages ----------------------------------------------------- */

.flash-stack {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 380px;
}

.flash {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  animation: flash-in 220ms ease;
}

.flash-success {
  border-left: 3px solid var(--success);
}
.flash-error {
  border-left: 3px solid var(--danger);
}
.flash-info {
  border-left: 3px solid var(--info);
}

@keyframes flash-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.alert {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: var(--space-4);
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.alert-info {
  background: var(--info-soft);
  color: var(--info);
}

/* --- Empty states ------------------------------------------------------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-7) var(--space-5);
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  color: var(--text-subtle);
}

.empty-icon svg {
  width: 22px;
  height: 22px;
}

.empty h3 {
  color: var(--text);
}

.empty-sm {
  padding: var(--space-5) var(--space-3);
  font-size: 0.85rem;
}

/* --- Modal / drawer ----------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: var(--overlay);
  animation: fade-in 140ms ease;
}

.modal {
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modal-in 180ms ease;
}

.modal-head {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.modal-head .spacer {
  margin-left: auto;
}

.modal-body {
  padding: var(--space-5);
}

.modal-foot {
  display: flex;
  gap: var(--space-2);
  justify-content: flex-end;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --- Auth pages --------------------------------------------------------- */

.auth-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: var(--space-5);
  background: radial-gradient(
      1000px 520px at 50% -10%,
      color-mix(in srgb, var(--accent) 14%, transparent),
      transparent
    ),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.auth-head {
  text-align: center;
  margin-bottom: var(--space-5);
}

.auth-head .brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  margin: 0 auto var(--space-3);
  font-size: 1.05rem;
}

.auth-foot {
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* --- Reports ------------------------------------------------------------ */

.report {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}

.report-head {
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-5);
  border-bottom: 2px solid var(--border-strong);
}

.report-title {
  font-size: 1.4rem;
}

.report-subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.report-section {
  margin-bottom: var(--space-6);
}

.report-section:last-child {
  margin-bottom: 0;
}

.report-section > h2 {
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
  font-size: 1.02rem;
}

.report-totals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.report-total {
  padding: var(--space-3) var(--space-4);
  background: var(--surface-2);
  border-radius: var(--radius);
}

.report-total .k {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-subtle);
  font-weight: 600;
}

.report-total .v {
  font-size: 1.35rem;
  font-weight: 680;
  font-variant-numeric: tabular-nums;
}

.standup {
  max-width: 42rem;
  font-size: 1rem;
  line-height: 1.55;
}

.standup-date {
  margin: 0 0 var(--space-4);
}

.standup-block {
  margin-bottom: var(--space-4);
}

.standup-label {
  display: block;
  margin-bottom: var(--space-2);
}

.standup-list {
  margin: 0;
  padding-left: 1.35rem;
}

.standup-list li + li {
  margin-top: 0.35rem;
}

.standup-empty {
  margin: 0;
  color: var(--text-muted);
  font-style: italic;
}

.day-block {
  margin-bottom: var(--space-5);
}

.day-block-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
  font-weight: 620;
}

.day-block-head .total {
  margin-left: auto;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.chart {
  width: 100%;
  height: auto;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-3);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.markdown-output {
  width: 100%;
  min-height: 320px;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.6;
  resize: vertical;
}

/* --- Misc utilities ----------------------------------------------------- */

.muted {
  color: var(--text-muted);
}
.subtle {
  color: var(--text-subtle);
}
.small {
  font-size: 0.82rem;
}
.tiny {
  font-size: 0.74rem;
}
.strong {
  font-weight: 650;
}
.mono {
  font-family: var(--font-mono);
}
.nums {
  font-variant-numeric: tabular-nums;
}
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.row-wrap {
  flex-wrap: wrap;
}
.col {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.spacer {
  margin-left: auto;
}
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-4);
}
.mt-0 {
  margin-top: 0;
}
.mt-2 {
  margin-top: var(--space-2);
}
.mt-3 {
  margin-top: var(--space-3);
}
.mt-4 {
  margin-top: var(--space-4);
}
.mt-5 {
  margin-top: var(--space-5);
}
.mb-0 {
  margin-bottom: 0;
}
.mb-3 {
  margin-bottom: var(--space-3);
}
.mb-4 {
  margin-bottom: var(--space-4);
}
.mb-5 {
  margin-bottom: var(--space-5);
}
.hidden {
  display: none !important;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-4) 0;
}

.checklist {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.checklist li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
}

.checklist .done-text {
  text-decoration: line-through;
  color: var(--text-subtle);
}

.sidebar-toggle {
  display: none;
}

/* HTMX request feedback */
.htmx-request .htmx-indicator {
  opacity: 1;
}

.htmx-indicator {
  opacity: 0;
  transition: opacity 120ms ease;
}

.htmx-request.btn {
  opacity: 0.7;
  pointer-events: none;
}

/* --- Responsive --------------------------------------------------------- */

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

  .board-column {
    min-height: 0;
  }
}

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

  .sidebar {
    position: fixed;
    z-index: 40;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: var(--shadow-lg);
  }

  .app.nav-open .sidebar {
    transform: none;
  }

  .app.nav-open::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 30;
    background: var(--overlay);
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .content {
    padding: var(--space-4);
    padding-bottom: var(--space-7);
  }

  .topbar {
    padding: var(--space-3) var(--space-4);
  }

  .topbar-subtitle {
    display: none;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
  }

  .stat-value {
    font-size: 1.4rem;
  }

  .report {
    padding: var(--space-4);
  }

  .flash-stack {
    left: var(--space-3);
    right: var(--space-3);
    max-width: none;
  }

  .modal {
    max-height: 92vh;
  }
}

@media (max-width: 520px) {
  .field-row {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .btn-group {
    width: 100%;
  }

  .btn-group .btn {
    flex: 1;
  }
}

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

/* --- Print (also used by the PDF renderer) ------------------------------ */

@media print {
  .sidebar,
  .topbar,
  .flash-stack,
  .no-print {
    display: none !important;
  }

  .app {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 0;
    max-width: none;
  }

  .report {
    border: none;
    box-shadow: none;
    padding: 0;
  }

  .report-section {
    break-inside: avoid;
  }

  .table {
    font-size: 10pt;
  }

  body {
    background: #fff;
  }
}
