/* Reset + base typography. Calm, generous, editorial-leaning. */

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}
body.no-scroll { overflow: hidden; }

/* Headings: weight and tight tracking carry the hierarchy, so size can do
   its job without shouting. Large type gets tight leading; the 1.6 body
   leading would leave display lines floating apart. */
h1, h2, h3, h4 {
  margin: 0; font-weight: var(--weight-bold); line-height: var(--leading-snug);
  letter-spacing: var(--tracking-title); text-wrap: balance;
}
h1 { font-size: var(--text-3xl); line-height: var(--leading-tight); letter-spacing: var(--tracking-display); }
h2 { font-size: var(--text-md); }
p { margin: 0; text-wrap: pretty; }
/* `hidden` always wins: the app shell and auth screens rely on it to stay
   truly invisible (P0), whatever display value a component rule sets. */
[hidden] { display: none !important; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: var(--text-sm); color: var(--color-text); }

ul, ol { margin: 0; padding: 0; list-style: none; }

svg { display: block; }

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: var(--radius-pill); border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

kbd {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border-strong);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ---- Focus ring — the single global rule that makes keyboard nav visible.
   Applied via :focus-visible so mouse clicks never show a ring, only real
   keyboard/AT focus does. ---- */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible,
textarea:focus-visible, [tabindex]:focus-visible, .task-card:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--radius-xs);
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-radius: inherit;
}

/* ---- Buttons: five tiers, each visibly lighter than the one above.
     Primary    .btn--primary              the one filled action per view
     Secondary  .btn--ghost / .btn--secondary  raised surface + hairline
     Ghost      .btn (no modifier)         text until hovered
     Danger     .btn--danger / --urgent    red text; filled when paired
                                           with --primary (destructive CTA)
     Text       .link-btn / .btn--text     inline, accent-coloured
   ".btn--ghost" is the legacy name for Secondary (26 call sites use it);
   ".btn--secondary" is its forward-looking alias. Every tier shares one
   height per size (--control-*) so mixed buttons line up on a row.
   Hover states are scoped to :not(:disabled) so a disabled button never
   pretends to respond. ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--control-md); padding: 9px var(--space-4);
  border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: var(--text-sm); font-weight: var(--weight-medium); line-height: var(--leading-control);
  cursor: pointer; white-space: nowrap; user-select: none; -webkit-user-select: none;
  background: transparent; color: var(--color-text-muted);
  transition: background-color var(--transition-fast), border-color var(--transition-fast),
              box-shadow var(--transition-fast), transform var(--transition-fast), color var(--transition-fast);
}
.btn:hover:not(:disabled) { color: var(--color-text); background-color: var(--color-surface-2); }
.btn:active:not(:disabled) { transform: scale(0.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

/* Primary: a faint top highlight gives the fill a pressed-glass edge; the
   accent-tinted shadow lifts slightly on hover (elevation, not movement). */
.btn--primary {
  background-color: var(--color-accent); color: var(--color-on-accent); font-weight: var(--weight-semibold);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16),
              0 1px 2px rgba(var(--color-accent-rgb), 0.20), 0 4px 12px rgba(var(--color-accent-rgb), 0.22);
}
.btn--primary:hover:not(:disabled) {
  background-color: var(--color-accent-hover); color: var(--color-on-accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18),
              0 2px 4px rgba(var(--color-accent-rgb), 0.24), 0 8px 20px rgba(var(--color-accent-rgb), 0.30);
}
.btn--primary:active:not(:disabled) { background-color: var(--color-accent-active); }

/* Secondary: reads as a real control against both the tinted canvas and a
   white card, without competing with the primary's fill. */
.btn--ghost, .btn--secondary {
  background-color: var(--color-surface); color: var(--color-text);
  border-color: var(--color-border); box-shadow: var(--shadow-xs);
}
.btn--ghost:hover:not(:disabled), .btn--secondary:hover:not(:disabled) {
  background-color: var(--color-surface); border-color: var(--color-border-strong); box-shadow: var(--shadow-sm);
}

.btn--outline { background-color: transparent; border-color: var(--color-border-strong); color: var(--color-text); }
.btn--outline:hover:not(:disabled) { background-color: var(--color-surface-2); border-color: var(--color-border-strong); }

/* Danger: red is reserved for destruction and genuine urgency. On its own
   it's quiet red text; the soft red wash only appears on hover. */
.btn--danger, .btn--urgent { color: var(--color-danger); }
.btn--danger:hover:not(:disabled), .btn--urgent:hover:not(:disabled) {
  background-color: var(--color-danger-soft); color: var(--color-danger); border-color: transparent;
}
/* Paired with primary it becomes the destructive/urgent filled CTA. */
.btn--primary.btn--urgent, .btn--primary.btn--danger {
  background-color: var(--color-danger); color: var(--color-on-accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 1px 2px rgba(214, 69, 69, 0.20), 0 4px 12px rgba(214, 69, 69, 0.22);
}
.btn--primary.btn--urgent:hover:not(:disabled), .btn--primary.btn--danger:hover:not(:disabled) {
  background-color: #c23a3a; color: var(--color-on-accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 2px 4px rgba(214, 69, 69, 0.24), 0 8px 20px rgba(214, 69, 69, 0.28);
}

/* Sizes: one exact height each, padding derived from it. */
.btn--large {
  min-height: var(--control-lg); padding: 13px var(--space-5);
  font-size: var(--text-md); font-weight: var(--weight-semibold); border-radius: var(--radius-md);
}
.btn--sm { min-height: var(--control-sm); padding: 5px var(--space-3); font-size: var(--text-xs); border-radius: var(--radius-xs); }
.btn--block { width: 100%; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--control-sm); height: var(--control-sm); border-radius: var(--radius-xs); border: none;
  background: transparent; color: var(--color-text-muted); cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}
.icon-btn:hover:not(:disabled) { background-color: var(--color-surface-2); color: var(--color-text); }
.icon-btn:active:not(:disabled) { transform: scale(0.94); }
.icon-btn svg { width: var(--icon-sm); height: var(--icon-sm); }

/* Text: the lightest tier, for inline actions inside copy or card footers. */
.link-btn, .btn--text {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; color: var(--color-accent); font-size: var(--text-sm); font-weight: var(--weight-medium);
  cursor: pointer; padding: var(--space-1) 0; min-height: 0; box-shadow: none;
  transition: color var(--transition-fast), gap var(--transition-fast);
}
.link-btn:hover, .btn--text:hover:not(:disabled) { color: var(--color-accent-hover); background: none; }

/* ---- Fields & inputs — filled, borderless at rest; border + soft ring on
   focus. This is what makes controls feel considered instead of "generic
   HTML form": the eye reads shape, not a grid of outlines. ---- */
.field { display: flex; flex-direction: column; gap: var(--space-2); flex: 1; }
.field--narrow { flex: 0 0 152px; }
.field__label {
  font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--color-text-muted);
  text-transform: none; letter-spacing: normal; line-height: var(--leading-control);
}
.field__hint { font-size: var(--text-xs); color: var(--color-text-faint); font-weight: var(--weight-regular); line-height: 1.5; }
.field-row { display: flex; gap: var(--space-4); }

/* One control vocabulary for every text-like field (email and password
   included: the sign-in form previously fell through to raw browser
   defaults). Filled at rest with a near-invisible hairline so the field
   reads as a shape, not an outline; the accent border and ring appear only
   on focus. Heights match buttons exactly (--control-md). Colour changes
   use background-color, never the `background` shorthand, so the select
   chevron below survives hover and focus. */
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="time"],
input[type="number"], input[type="search"], textarea, select {
  min-height: var(--control-md); padding: 9px var(--space-3); border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); background-color: var(--color-surface-2);
  color: var(--color-text); font-size: var(--text-sm); line-height: var(--leading-control);
  outline: none; width: 100%;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input[type="text"]::placeholder, input[type="email"]::placeholder, input[type="password"]::placeholder,
input[type="search"]::placeholder, textarea::placeholder { color: var(--color-text-faint); opacity: 1; }
input[type="text"]:hover, input[type="email"]:hover, input[type="password"]:hover, input[type="date"]:hover,
input[type="time"]:hover, input[type="number"]:hover, input[type="search"]:hover, textarea:hover, select:hover {
  background-color: var(--color-surface-3);
}
input:focus, select:focus, textarea:focus {
  background-color: var(--color-surface); border-color: var(--color-accent); box-shadow: var(--shadow-focus);
}
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--color-danger); }
input:disabled, select:disabled, textarea:disabled { opacity: 0.55; cursor: not-allowed; }
textarea { resize: vertical; font-family: inherit; line-height: 1.5; min-height: 88px; }

/* Native select, native behaviour: only the platform arrow is swapped for
   a quieter chevron that matches the rest of the icon set. */
select {
  appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 36px;
  height: var(--control-md); /* selects ignore line-height for sizing; pin the height directly */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2376738a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.5 6.5 8 10l3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: var(--icon-sm);
}

input[type="checkbox"], input[type="radio"] { accent-color: var(--color-accent); width: var(--icon-sm); height: var(--icon-sm); cursor: pointer; }
input[type="range"] { accent-color: var(--color-accent); }

.search-input { width: 100%; max-width: 360px; margin-bottom: var(--space-4); }

.badge {
  display: inline-flex; align-items: center; padding: 1px var(--space-2); border-radius: var(--radius-pill);
  font-size: var(--text-2xs); font-weight: var(--weight-semibold); line-height: 20px; letter-spacing: 0.01em;
  background: var(--color-surface-2); color: var(--color-text-muted);
}
.badge--critical { background: var(--color-danger-soft); color: var(--color-critical); }
.badge--high { background: var(--color-warning-soft); color: var(--color-high); }
.badge--normal { background: var(--color-info-soft); color: var(--color-accent-soft-text); }
.badge--waiting { background: var(--color-warning-soft); color: var(--color-high); }
.badge--delegated { background: var(--color-info-soft); color: var(--color-text-muted); }
.badge--completed { background: var(--color-success-soft); color: var(--color-success); }
.badge--cancelled { background: var(--color-surface-2); color: var(--color-text-faint); }

.count-badge {
  font-size: var(--text-md); font-weight: 500; color: var(--color-text-faint); margin-left: 6px;
}

.section-title {
  font-size: var(--text-xs); font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--color-text-faint); margin: 0 0 var(--space-3);
}
.section-title__hint { text-transform: none; font-weight: 400; letter-spacing: normal; }

.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2);
  color: var(--color-text-faint); padding: var(--space-6) var(--space-4); font-size: var(--text-sm);
  text-align: center; border: 1px dashed var(--color-border-strong); border-radius: var(--radius-lg);
  background: var(--color-surface-2);
}
/* Quiet, single-line variant for repeated inline uses (an empty milestone,
   an empty day) — the dashed full-attention box is right for a whole
   screen being empty, but heavy when it might repeat a dozen times down
   one page. */
.empty-state--small {
  display: block; padding: var(--space-2) var(--space-1); border: none; background: none;
  text-align: left; font-size: var(--text-sm); color: var(--color-text-faint);
}
.empty-state__icon {
  width: 40px; height: 40px; border-radius: 50%; background: var(--color-surface); color: var(--color-text-faint);
  display: flex; align-items: center; justify-content: center; margin-bottom: 2px; box-shadow: var(--shadow-xs);
}
.empty-state__icon svg { width: 18px; height: 18px; }
.empty-state__title { font-size: var(--text-sm); font-weight: 600; color: var(--color-text-muted); }

.chip {
  border: 1px solid var(--color-border-strong); background: var(--color-surface); color: var(--color-text-muted);
  border-radius: var(--radius-pill); padding: 5px 12px; font-size: var(--text-xs); cursor: pointer;
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}
.chip:hover { border-color: var(--color-accent); color: var(--color-accent); }

/* Text for assistive technology only (a visible short label with a full
   spoken name, e.g. "Mon" / "Monday"). */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
