/* =====================================================================
   Fate Ondaba — "Calm" design system (Sunsama-inspired warmth).
   MOBILE-FIRST base; desktop layered via min-width queries.
   Warm cream surfaces, soft rounded cards, gentle shadows, one muted
   indigo accent, low-contrast pastel status chips. Calm on the eye + mind.
   NOTE: --st-* variable names are preserved (views reference them inline).
   ===================================================================== */

:root {
  /* surfaces & ink (warm neutrals) */
  --bg:        #F6F3EE;   /* warm cream app background */
  --surface:   #FFFFFF;   /* cards */
  --surface-2: #FBF9F5;   /* soft panels */
  --ink:       #322E2B;   /* warm near-black text */
  --ink-soft:  #756B62;   /* muted warm grey */
  --line:      #ECE6DD;   /* soft warm border */

  /* accent (muted indigo) */
  --accent:        #5B62C9;
  --accent-strong: #474DB0;
  --accent-tint:   #ECEDFB;

  /* status stripe hues (used inline by views as var(--st-*)) */
  --st-assigned:       #A99E90;
  --st-submitted:      #5B62C9;
  --st-needs_revision: #C07A3E;
  --st-approved:       #3E9466;
  --st-overdue:        #CB5B56;
  --st-cancelled:      #B6ADA2;

  /* pill tints (soft bg) + ink (readable text) */
  --pill-assigned-bg: #F1ECE4; --pill-assigned-ink: #7C7368;
  --pill-submitted-bg:#E9EBFB; --pill-submitted-ink:#454CB5;
  --pill-revision-bg: #FAEDE1; --pill-revision-ink: #A65E29;
  --pill-approved-bg: #E6F4EC; --pill-approved-ink: #2C7A50;
  --pill-overdue-bg:  #FBE9E7; --pill-overdue-ink:  #B5413C;
  --pill-cancelled-bg:#EFEBE5; --pill-cancelled-ink:#8A8278;

  --font-display: "DM Sans", system-ui, sans-serif;
  --font-body:    "DM Sans", system-ui, sans-serif;
  --font-mono:    "IBM Plex Mono", ui-monospace, monospace;

  --radius:    14px;
  --radius-sm: 10px;
  --pill:      999px;
  --tap:       44px;
  --nav-h:     66px;

  --shadow:       0 1px 2px rgba(60,48,34,.04), 0 2px 10px rgba(60,48,34,.05);
  --shadow-hover: 0 8px 24px rgba(60,48,34,.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--bg);              /* flat warm cream — no blueprint grid */
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0));
}

h1, h2, h3 { font-family: var(--font-display); color: var(--ink); line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 1.4rem 0 .7rem; }
h3 { font-size: 1rem; font-weight: 600; margin: .9rem 0 .45rem; }

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

.mono { font-family: var(--font-mono); }
.muted { color: var(--ink-soft); }
.small { font-size: .85rem; }

/* --- Top bar (light, warm) ------------------------------------------ */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); color: var(--ink);
  padding: .7rem 1rem; min-height: 56px;
  padding-top: calc(.7rem + env(safe-area-inset-top, 0));
  border-bottom: 1px solid var(--line);
}
.topbar__brand { display: flex; align-items: center; gap: .55rem; }
.brand-mark {
  font-family: var(--font-mono); font-weight: 500;
  background: var(--accent-tint); color: var(--accent-strong); border-radius: 8px;
  padding: .2rem .45rem; letter-spacing: .06em; font-size: .9rem;
}
.brand-name { font-family: var(--font-display); font-weight: 700; }
.topbar__right { display: flex; align-items: center; gap: .35rem; }
.topbar__user { color: var(--ink-soft); margin-right: .4rem; display: none; }
.iconbtn {
  position: relative; color: var(--ink-soft); display: inline-flex;
  align-items: center; justify-content: center;
  min-width: var(--tap); min-height: var(--tap); font-size: 1.2rem; border-radius: 10px;
}
.iconbtn:hover { color: var(--accent); background: var(--surface-2); }
.badge {
  position: absolute; top: 6px; right: 6px;
  background: var(--st-overdue); color: #fff;
  font-size: .65rem; font-weight: 700; line-height: 1;
  padding: 2px 5px; border-radius: 999px; min-width: 16px; text-align: center;
}

/* --- Content --------------------------------------------------------- */
.content { padding: 1.1rem; max-width: 1100px; margin: 0 auto; }

/* --- Flash (auth pages) + Toasts ------------------------------------ */
.flash {
  border-radius: var(--radius-sm); padding: .75rem .9rem; margin-bottom: .8rem;
  border: 1px solid var(--line); font-size: .92rem; background: var(--surface-2);
}
.flash--success { background: var(--pill-approved-bg); border-color: #CDE9D8; color: var(--pill-approved-ink); }
.flash--error   { background: var(--pill-overdue-bg);  border-color: #F4D3D1; color: var(--pill-overdue-ink); }
.flash--info    { background: var(--surface-2); border-color: var(--line); color: var(--ink); }

.toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top, 0) + 64px); z-index: 50;
  width: calc(100% - 2rem); max-width: 460px; display: flex; flex-direction: column; gap: .5rem;
  pointer-events: none;
}
.toast {
  pointer-events: auto; border-radius: var(--radius); padding: .8rem 1rem; font-size: .92rem;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-hover);
  animation: toastIn .22s ease-out;
}
.toast--success { background: var(--pill-approved-bg); border-color: #CDE9D8; color: var(--pill-approved-ink); }
.toast--error   { background: var(--pill-overdue-bg);  border-color: #F4D3D1; color: var(--pill-overdue-ink); }
.toast--info    { background: var(--surface); border-color: var(--line); color: var(--ink); }
.toast.is-hiding { opacity: 0; transform: translateY(-6px); transition: .3s ease; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* --- Cards ----------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.15rem; margin-bottom: .85rem;
  box-shadow: var(--shadow);
}
.card--task { border-left: 4px solid var(--st-assigned); transition: box-shadow .15s ease, transform .15s ease; }
a.card--task:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: .7rem; }
.card__ref { font-family: var(--font-mono); font-size: .78rem; color: var(--ink-soft); }
.card__title { font-family: var(--font-display); font-weight: 600; color: var(--ink); margin: .2rem 0; }
.card__meta { font-size: .83rem; color: var(--ink-soft); display: flex; flex-wrap: wrap; gap: .3rem .9rem; }
.card.is-overdue { border-left-color: var(--st-overdue); background: #FFFAF8; }
.overdue-flag { color: var(--st-overdue); font-weight: 700; }

/* --- Status pills (soft pastel) ------------------------------------- */
.pill {
  display: inline-block; font-family: var(--font-mono); font-size: .72rem;
  font-weight: 500; padding: .2rem .6rem; border-radius: var(--pill);
  white-space: nowrap; letter-spacing: .01em;
  background: var(--pill-assigned-bg); color: var(--pill-assigned-ink);
}
.pill.st-assigned       { background: var(--pill-assigned-bg);  color: var(--pill-assigned-ink); }
.pill.st-submitted,
.pill.st-pending_review { background: var(--pill-submitted-bg); color: var(--pill-submitted-ink); }
.pill.st-needs_revision,
.pill.st-rejected       { background: var(--pill-revision-bg);  color: var(--pill-revision-ink); }
.pill.st-approved       { background: var(--pill-approved-bg);  color: var(--pill-approved-ink); }
.pill.st-cancelled      { background: var(--pill-cancelled-bg); color: var(--pill-cancelled-ink); }

/* --- Section groups -------------------------------------------------- */
.group { margin-bottom: 1.6rem; }
.group__label {
  font-family: var(--font-mono); font-size: .74rem; text-transform: uppercase;
  letter-spacing: .08em; color: var(--ink-soft); margin-bottom: .5rem;
}

/* --- Summary tiles --------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: .7rem; margin: 0 0 1.4rem; }
.tile {
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--st-assigned);
  border-radius: var(--radius); padding: .9rem 1rem; text-decoration: none; color: inherit;
  display: block; box-shadow: var(--shadow);
}
.tile:hover { box-shadow: var(--shadow-hover); color: inherit; }
.tile__num { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; color: var(--ink); line-height: 1; }
.tile__label { font-size: .8rem; color: var(--ink-soft); margin-top: .3rem; }
.tile--overdue { border-left-color: var(--st-overdue); } .tile--overdue .tile__num { color: var(--st-overdue); }
.tile--review  { border-left-color: var(--st-submitted); }
.tile--today   { border-left-color: var(--accent); }
.tile--ok      { border-left-color: var(--st-approved); }

/* --- Forms ----------------------------------------------------------- */
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; color: var(--ink); }
.input, .select, .textarea {
  width: 100%; font: inherit; color: var(--ink);
  padding: .7rem .8rem; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface); min-height: var(--tap);
}
.textarea { min-height: 100px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint);
}

/* --- Buttons --------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; cursor: pointer;
  min-height: var(--tap); padding: .65rem 1.15rem; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: var(--accent); color: #fff;
  transition: filter .15s ease, box-shadow .15s ease;
}
.btn:hover { color: #fff; background: var(--accent-strong); box-shadow: var(--shadow); }
.btn--block { width: 100%; }
.btn--ghost { background: var(--surface); color: var(--accent); border-color: var(--accent); }
.btn--ghost:hover { background: var(--accent-tint); color: var(--accent-strong); }
.btn--muted { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn--muted:hover { background: var(--surface-2); color: var(--ink); }
.btn--danger  { background: #C8605C; } .btn--danger:hover  { background: #b14f4b; color:#fff; }
.btn--success { background: #2F8F5B; } .btn--success:hover { background: #287d4f; color:#fff; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { min-height: 36px; padding: .4rem .75rem; font-size: .85rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; }

/* Floating primary action (thumb-reachable, mobile) */
.fab {
  position: fixed; right: 1rem; bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom,0));
  z-index: 15; border-radius: var(--pill); box-shadow: var(--shadow-hover); padding: .9rem 1.25rem;
}

/* --- Bottom nav (mobile) -------------------------------------------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0));
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.bottomnav__item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--ink-soft); font-size: .68rem; font-weight: 600; text-decoration: none;
}
.bottomnav__item:hover { color: var(--accent); }
.bottomnav__item.is-active { color: var(--accent); }
.bottomnav__glyph { font-size: 1.15rem; line-height: 1; }
.bottomnav__item.is-accent .bottomnav__glyph {
  background: var(--accent); color: #fff; width: 34px; height: 34px; border-radius: var(--pill);
  display: flex; align-items: center; justify-content: center; margin-bottom: -2px;
}

/* --- Lists / tables -------------------------------------------------- */
.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem .9rem; font-size: .9rem; }
.kv dt { font-family: var(--font-mono); color: var(--ink-soft); }
.kv dd { margin: 0; }

.attlist { list-style: none; margin: .5rem 0 0; padding: 0; }
.attlist li {
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .6rem .7rem; margin-bottom: .45rem;
  background: var(--surface-2);
}
.attlist .att-name { font-size: .9rem; word-break: break-word; }

/* --- Version / comments --------------------------------------------- */
.version {
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: var(--radius); padding: .9rem; margin-bottom: .75rem; background: var(--surface);
  box-shadow: var(--shadow);
}
.version__head { display: flex; justify-content: space-between; align-items: center; }
.version__no { font-family: var(--font-mono); font-weight: 500; color: var(--ink); }
.comment { border-top: 1px solid var(--line); padding: .55rem 0; font-size: .9rem; }
.comment__who { font-weight: 600; color: var(--ink); }
.comment__who .role { font-family: var(--font-mono); font-size: .7rem; color: var(--ink-soft); }

/* --- Notifications --------------------------------------------------- */
.notif {
  display: flex; gap: .6rem; padding: .8rem; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--surface); margin-bottom: .55rem; box-shadow: var(--shadow);
}
.notif.is-unread { border-left: 4px solid var(--accent); background: #FCFBFF; }
.notif__body { flex: 1; }

/* --- Empty state ----------------------------------------------------- */
.empty { text-align: center; color: var(--ink-soft); padding: 2.4rem 1rem; }
.empty .blueprint { font-family: var(--font-mono); font-size: 2rem; color: var(--line); }

/* --- Auth screens ---------------------------------------------------- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.2rem; }
.auth-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.8rem; width: 100%; max-width: 390px; box-shadow: var(--shadow-hover);
}
.auth-card .brand { text-align: center; margin-bottom: 1.1rem; }
.auth-card .brand .brand-mark { font-size: 1.1rem; }

/* --- Filters bar ----------------------------------------------------- */
.filters { display: grid; grid-template-columns: 1fr; gap: .6rem; margin-bottom: 1rem; }

/* --- Wizard: cadence choice cards ----------------------------------- */
.choice-row { display: grid; grid-template-columns: 1fr; gap: .6rem; }
.choice {
  display: flex; gap: .65rem; align-items: flex-start; border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem; cursor: pointer; background: var(--surface);
}
.choice input { margin-top: .25rem; accent-color: var(--accent); }
.choice__body { display: block; }
.choice__title { font-weight: 600; color: var(--ink); display: block; }
.choice__desc { font-size: .85rem; color: var(--ink-soft); }
.choice:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); background: #FCFBFF; }

/* --- Wizard: day picker --------------------------------------------- */
.daypicker { display: flex; gap: .45rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.daypicker__day {
  position: relative; flex: 1 1 auto; min-width: 56px; text-align: center;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .65rem .3rem;
  background: var(--surface); color: var(--ink); font-family: var(--font-mono); font-size: .82rem; text-decoration: none;
}
.daypicker__day:hover { border-color: var(--accent); color: var(--accent); }
.daypicker__day.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.daypicker__count {
  position: absolute; top: -6px; right: -6px; background: var(--st-overdue); color: #fff;
  border-radius: var(--pill); font-size: .68rem; padding: 1px 6px; min-width: 16px;
}

/* --- Offline banner -------------------------------------------------- */
.offline-banner {
  display: none; background: var(--st-needs_revision); color: #fff;
  text-align: center; font-size: .85rem; padding: .45rem;
}
body.is-offline .offline-banner { display: block; }

/* =====================================================================
   DESKTOP — min-width queries only. Left sidebar; hide bottom nav.
   ===================================================================== */
@media (min-width: 768px) {
  .content { padding: 1.6rem 2rem; }
  .filters { grid-template-columns: repeat(4, 1fr); align-items: end; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .choice-row { grid-template-columns: 1fr 1fr; }
  .card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .85rem; }
  .card-grid .card { margin-bottom: 0; }
  h1 { font-size: 1.8rem; }
}

@media (min-width: 1024px) {
  .layout-2col { display: grid; grid-template-columns: 2fr 1fr; gap: 1.4rem; align-items: start; }
  .card-grid { grid-template-columns: repeat(3, 1fr); }
  .topbar__user { display: inline; }

  .shell { display: grid; grid-template-columns: 240px 1fr; max-width: 1200px; margin: 0 auto; }
  .sidebar {
    align-self: start; position: sticky; top: 0; height: 100vh;
    padding: 1.3rem .85rem; border-right: 1px solid var(--line); background: var(--surface);
  }
  .sidebar__nav { display: flex; flex-direction: column; gap: .25rem; }
  .sidebar__link {
    display: flex; align-items: center; gap: .7rem; padding: .7rem .85rem; border-radius: var(--radius-sm);
    color: var(--ink-soft); font-weight: 600; text-decoration: none;
  }
  .sidebar__link:hover { background: var(--surface-2); color: var(--ink); }
  .sidebar__link.is-active { background: var(--accent-tint); color: var(--accent-strong); }
  .sidebar__link.is-accent { color: var(--accent); }
  .sidebar__link.is-active.is-accent { color: var(--accent-strong); }
  .sidebar__glyph { width: 1.2rem; text-align: center; font-size: 1.05rem; }

  .content { padding: 1.8rem 2.2rem; }
  body { padding-bottom: 0; }
  .bottomnav { display: none; }
  .fab { display: none; }
}

/* base: sidebar hidden, shell single column (mobile) */
.shell { display: block; }
.sidebar { display: none; }
@media (min-width: 1024px) { .sidebar { display: block; } }

/* --- PWA install prompt --------------------------------------------- */
.install-prompt{
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 10px + env(safe-area-inset-bottom, 0)); z-index: 40;
  width: calc(100% - 1.5rem); max-width: 460px;
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-hover); padding: .8rem .9rem;
}
.install-prompt[hidden]{ display: none; }
.install-prompt__body{ display: flex; align-items: center; gap: .6rem; }
.install-prompt__actions{ display: flex; gap: .4rem; flex-shrink: 0; }
@media (min-width: 1024px){
  .install-prompt{ bottom: 16px; right: 16px; left: auto; transform: none; }
}

/* --- SVG icon sizing in nav + topbar -------------------------------- */
.iconbtn, .iconbtn__glyph { display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.iconbtn svg { width: 22px; height: 22px; display: block; }
.bottomnav__glyph { display: inline-flex; }
.bottomnav__glyph svg { width: 22px; height: 22px; display: block; }
.sidebar__glyph { display: inline-flex; align-items: center; justify-content: center; }
.sidebar__glyph svg { width: 20px; height: 20px; display: block; }
.bottomnav__item.is-accent .bottomnav__glyph svg { width: 20px; height: 20px; }
