/* ==========================================================================
   ASAAN.TAX — Client Document Portal
   Brand system per D:\ASAAN.TAX\asaan-content-engine\BRAND.md (LOCKED)

     Ink          #0A0A0A   text, rules, dark chrome
     Asaan Green  #7AB82B   primary CTA, focus, active, emphasis
     Cream        #F6F4EF   page canvas / light surfaces

   Those three hex values are the only solid colours in this file. Every other
   value is a transparent tint of one of them, e.g. rgba(10,10,10,.13) or
   rgba(122,184,43,.14). No white, no sky blue, no indigo, no neon.

   Surface ladder, built from the tints alone:
     canvas  = Cream + 4% Ink wash + soft green bloom   (body)
     raised  = Cream                                     (.card, .panel)
     well    = Cream + 5.5% Ink                          (inputs, .item, .doc)
     action  = 8% Asaan Green                            (.toolbar)
     active  = 14–22% Asaan Green + solid green spine    (.item.active, .pill.firm)

   Cream-first light product UI — deliberately not dark mode. Mobile is the
   primary target (design width 375px).
   ========================================================================== */

:root {
  /* ── Locked brand tokens ───────────────────────────────────────── */
  --ink:   #0A0A0A;
  --green: #7AB82B;
  --cream: #F6F4EF;

  /* ── Tints derived only from the three tokens ──────────────────── */
  --ink-90:        rgba(10, 10, 10, .90);
  --ink-72:        rgba(10, 10, 10, .72);
  --ink-56:        rgba(10, 10, 10, .56); /* 5.6:1 on cream — AA body text */
  --ink-40:        rgba(10, 10, 10, .40);
  --ink-field:     rgba(10, 10, 10, .22); /* input borders */
  --ink-line:      rgba(10, 10, 10, .13);
  --ink-line-soft: rgba(10, 10, 10, .07);
  --ink-well:      rgba(10, 10, 10, .055);
  --ink-wash:      rgba(10, 10, 10, .04);
  --ink-veil:      rgba(10, 10, 10, .10); /* hover overlay on green fills */

  --green-08: rgba(122, 184, 43, .08);
  --green-14: rgba(122, 184, 43, .14);
  --green-22: rgba(122, 184, 43, .22);
  --green-40: rgba(122, 184, 43, .40);
  --green-ring: rgba(122, 184, 43, .32);

  /* Surfaces — cream all the way down; separation comes from ink tints */
  --surface: var(--cream);

  --shadow-sm: 0 1px 2px rgba(10, 10, 10, .05);
  --shadow-md: 0 2px 4px rgba(10, 10, 10, .04), 0 8px 24px rgba(10, 10, 10, .06);
  --shadow-lg: 0 4px 10px rgba(10, 10, 10, .05), 0 24px 60px rgba(10, 10, 10, .09);

  --radius:    14px;
  --radius-sm: 10px;
  --radius-lg: 20px;

  --font-sans:    "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Archivo Black", var(--font-sans);
  --font-mono:    "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-90);
  /* Cream canvas, faintly washed with Ink so cream cards read as raised,
     plus a soft Asaan Green bloom. The only decoration in the system. */
  background-color: var(--cream);
  background-image:
    radial-gradient(760px 420px at 92% -8%,   var(--green-14), transparent 62%),
    radial-gradient(620px 520px at -10% 108%, var(--green-08), transparent 60%),
    linear-gradient(var(--ink-wash), var(--ink-wash));
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3 { color: var(--ink); line-height: 1.25; letter-spacing: -.01em; }

/* Asaan Green fails contrast as body-size text on Cream (2.2:1), so links stay
   Ink and carry the brand through a green underline instead. */
a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-color: var(--green);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}
a:hover { text-decoration-thickness: 3px; }

img { max-width: 100%; height: auto; }

::selection { background: var(--green-40); color: var(--ink); }

/* Solid Asaan Green focus ring with a thin ink halo, so it stays legible
   against both the cream canvas and the green-tinted upload panel. */
:focus-visible {
  outline: 3px solid var(--green);
  outline-offset: 2px;
  box-shadow: 0 0 0 1px var(--ink-40);
}

/* ──────────────────────────────────────────────────────────────────
   Brand lockup
   ────────────────────────────────────────────────────────────────── */
.logo      { display: block; width: auto; }
.logo-lg   { height: 40px; }
.logo-sm   { height: 26px; }
.logo-mark { height: 30px; width: auto; display: none; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-56);
  margin: 0;
}

/* ──────────────────────────────────────────────────────────────────
   Login
   ────────────────────────────────────────────────────────────────── */
.auth {
  display: grid;
  place-items: center;
  padding: 24px 18px 40px;
  min-height: 100vh;
}

.auth-inner { width: min(430px, 100%); }

.card {
  background: var(--surface);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-lg);
  padding: 30px 26px 26px;
  box-shadow: var(--shadow-lg);
}

/* Asaan Green hairline across the top of the login card */
.card::before {
  content: "";
  display: block;
  height: 3px;
  margin: -30px -26px 24px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: linear-gradient(90deg, var(--green), var(--green-22));
}

.brand { display: grid; gap: 12px; margin-bottom: 20px; }
.brand h1 { margin: 0; font-size: 1.5rem; font-family: var(--font-display); }

.lead { color: var(--ink-72); margin: 6px 0 4px; }

.fine { color: var(--ink-56); font-size: .8rem; margin-top: 16px; }

.auth-foot {
  text-align: center;
  color: var(--ink-40);
  font-family: var(--font-mono);
  font-size: .68rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin: 18px 0 0;
}

/* ──────────────────────────────────────────────────────────────────
   Forms
   ────────────────────────────────────────────────────────────────── */
label {
  display: grid;
  gap: 6px;
  margin: 14px 0;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-72);
}

input, select, textarea {
  font: inherit;
  font-size: .95rem;
  font-weight: 400;
  width: 100%;
  color: var(--ink);
  background: var(--cream);
  border: 1px solid var(--ink-field);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input::placeholder { color: var(--ink-40); }

input:hover, select:hover, textarea:hover { border-color: var(--ink-40); }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-ring);
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%230A0A0A' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' opacity='.55'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
}

input[type="file"] { padding: 7px 10px; }
input[type="file"]::file-selector-button {
  font: inherit;
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--green-14);
  border: 1px solid var(--green-40);
  border-radius: 8px;
  padding: 6px 12px;
  margin-right: 10px;
  cursor: pointer;
}
input[type="file"]::file-selector-button:hover { background: var(--green-22); }

input[type="date"] { min-height: 43px; }

/* ── Buttons ─────────────────────────────────────────────────────── */
button {
  font: inherit;
  font-size: .9rem;
  font-weight: 700;
  width: auto;
  cursor: pointer;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  /* Ink on Asaan Green — 8.2:1. White on green would only reach 2.4:1, so
     Ink is both the brand's own pairing and the legible one. */
  background-color: var(--green);
  color: var(--ink);
  transition: background-color .15s ease, box-shadow .15s ease, transform .05s ease;
}
button:hover  { background-image: linear-gradient(var(--ink-veil), var(--ink-veil)); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .55; cursor: not-allowed; background-image: none; }

button.secondary {
  background-color: transparent;
  border-color: var(--ink-field);
  color: var(--ink-90);
}
button.secondary:hover {
  background-image: none;
  background-color: var(--ink-wash);
  border-color: var(--ink-40);
}

/* Destructive stays in the Ink family — the palette is locked, so no red is
   introduced. Deletion is also confirm()-gated in app.js. */
button.danger {
  background-color: transparent;
  border-color: var(--ink-line);
  color: var(--ink-72);
}
button.danger:hover {
  background-image: none;
  background-color: var(--ink);
  border-color: var(--ink);
  color: var(--cream);
}

/* Block buttons: login, password gate, add-client */
.card form button,
.pw-panel form button,
.admin-box form button {
  width: 100%;
  margin-top: 10px;
  padding-block: 12px;
}

/* ── Inline feedback ─────────────────────────────────────────────────
   The locked palette has no red, so an error is marked by an icon, weight
   and a solid ink rule — never by colour alone. */
.err {
  display: flex;
  gap: 8px;
  font-size: .85rem;
  font-weight: 600;
  color: var(--ink);
  background: var(--ink-wash);
  border-left: 3px solid var(--ink);
  border-radius: 0 8px 8px 0;
  padding: 9px 12px;
  margin: 12px 0 0;
}
.err::before { content: "!"; font-family: var(--font-display); flex: none; }
.err[hidden] { display: none; }

/* ──────────────────────────────────────────────────────────────────
   App shell
   ────────────────────────────────────────────────────────────────── */
.shell { max-width: 1140px; margin: 0 auto; padding: 0 16px 56px; }

/* Full-bleed sticky bar; the row inside is constrained to the shell width so
   the brand lines up with the panels below it. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin-bottom: 20px;
  background: rgba(246, 244, 239, .92);
  backdrop-filter: saturate(150%) blur(10px);
  -webkit-backdrop-filter: saturate(150%) blur(10px);
  border-bottom: 1px solid var(--ink-line);
}
.topbar-inner {
  max-width: 1140px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.topbar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-brand .divider {
  width: 1px;
  height: 26px;
  background: var(--ink-line);
  flex: none;
}
.topbar h1 {
  margin: 0;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-72);
  white-space: nowrap;
}
.topbar .who {
  display: block;
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--ink-56);
  margin-top: 2px;
  overflow-wrap: anywhere;
}
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.topbar-actions button { padding: 8px 14px; font-size: .82rem; }

.grid { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .grid.staff { grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
  .grid.staff > aside { position: sticky; top: 78px; }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-md);
}
.panel h2 {
  margin: 0 0 14px;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 10px;
}
/* Asaan Green tick before every panel heading */
.panel h2::before {
  content: "";
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: var(--green);
  flex: none;
}

/* ── Client list ─────────────────────────────────────────────────── */
.list {
  display: grid;
  gap: 8px;
  max-height: 68vh;
  overflow: auto;
  scrollbar-color: var(--ink-line) transparent;
}
.item {
  position: relative;
  text-align: left;
  width: 100%;
  font-weight: 500;
  background-color: var(--ink-well);
  color: var(--ink-90);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  cursor: pointer;
  overflow: hidden;
}
.item:hover {
  background-image: none;
  background-color: var(--green-08);
  border-color: var(--green-40);
}
/* Selected client — Asaan Green tint plus a solid green spine */
.item.active {
  background-color: var(--green-14);
  border-color: var(--green);
  box-shadow: inset 3px 0 0 var(--green);
}
.item b { display: block; font-weight: 700; color: var(--ink); }
.item small {
  display: block;
  font-family: var(--font-mono);
  font-size: .7rem;
  color: var(--ink-56);
  margin-top: 3px;
  overflow-wrap: anywhere;
}

/* ── Upload toolbar — the primary action zone, tinted Asaan Green ── */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  background: var(--green-08);
  border: 1px solid var(--green-22);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.toolbar label { margin: 0; flex: 1 1 170px; min-width: 150px; }
/* the file field carries the longest native text ("No file chosen") */
.toolbar label:first-of-type { flex: 1.6 1 240px; }
.toolbar button { flex: 0 0 auto; }
.toolbar input, .toolbar select { background-color: var(--cream); }

/* ── Filters ─────────────────────────────────────────────────────── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  border-top: 1px solid var(--ink-line-soft);
  margin-top: 16px;
  padding-top: 14px;
}
.filters label { margin: 0; flex: 1 1 150px; min-width: 130px; max-width: 260px; }
.filters input, .filters select { padding: 9px 10px; font-size: .88rem; }
.filters button { flex: 0 0 auto; padding: 9px 14px; font-size: .82rem; }

.filter-count {
  font-family: var(--font-mono);
  font-size: .72rem;
  color: var(--ink-56);
  margin: 10px 0 12px;
}

/* ── Documents ───────────────────────────────────────────────────── */
.docs { display: grid; gap: 8px; }

.doc {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  background: var(--ink-well);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.doc:hover { border-color: var(--ink-40); box-shadow: var(--shadow-sm); }
.doc b { font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.doc .meta {
  font-family: var(--font-mono);
  font-size: .71rem;
  line-height: 1.5;
  color: var(--ink-56);
  margin-top: 5px;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .09em;
  padding: 3px 8px;
  border-radius: 999px;
  margin-right: 8px;
  vertical-align: 1px;
  white-space: nowrap;
}
/* FROM FIRM = green tinted · FROM CLIENT = muted ink */
.pill.firm   { background: var(--green-22); color: var(--ink);    border: 1px solid var(--green-40); }
.pill.client { background: var(--cream);    color: var(--ink-72); border: 1px solid var(--ink-field); }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions a, .actions button {
  width: auto;
  font-size: .8rem;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 8px;
  white-space: nowrap;
}
/* Download is the row's primary action — solid Asaan Green, Ink label */
.actions a {
  background: var(--green);
  color: var(--ink);
  text-decoration: none;
  border: 1px solid transparent;
}
.actions a:hover { background-image: linear-gradient(var(--ink-veil), var(--ink-veil)); }

.empty {
  color: var(--ink-56);
  background: var(--ink-wash);
  border: 1px dashed var(--ink-line);
  border-radius: var(--radius);
  padding: 30px 20px;
  text-align: center;
}

.hidden { display: none !important; }

/* ── Password gate ───────────────────────────────────────────────── */
.pw-panel { max-width: 470px; margin-inline: auto; }
.pw-panel .fine { margin-top: -6px; }

.admin-box {
  margin-top: 18px;
  border-top: 1px solid var(--ink-line-soft);
  padding-top: 14px;
}
.admin-box h3 {
  margin: 0 0 6px;
  font-size: .78rem;
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-56);
}

/* ──────────────────────────────────────────────────────────────────
   Phone (portal is used on a phone — 375px is the design target)
   ────────────────────────────────────────────────────────────────── */
@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .shell { padding-inline: 12px; }
  .topbar-inner { padding-inline: 12px; gap: 10px; }
  .topbar-actions { width: 100%; }
  .filters label { max-width: none; }
  .topbar-actions button { flex: 1 1 0; }

  /* full lockup gives way to the X mark so the topbar stays one line */
  .logo-sm   { display: none; }
  .logo-mark { display: block; }

  .card { padding: 26px 20px 22px; }
  .card::before { margin: -26px -20px 22px; }

  .panel { padding: 15px; }
  .toolbar { padding: 12px; }
  .toolbar label, .filters label { flex-basis: 100%; }
  .toolbar button, .filters button { width: 100%; }

  .doc { grid-template-columns: 1fr; }
  .actions { justify-content: flex-start; }
  .actions a, .actions button { flex: 1 1 0; text-align: center; }
}

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