/* ===========================================================================
   Urban Food Systems — design system
   Palette taken from the NAVCDP mark: green leads, gold carries attention,
   brown grounds secondary data, teal is reserved for traceability.
   =========================================================================== */

:root {
  /* ---- NAVCDP brand ----------------------------------------------------- */
  --navcdp-green:       #3ca848;
  --navcdp-green-mid:   #2f8f3c;
  --navcdp-green-deep:  #1f6b2c;
  --navcdp-green-abyss: #11431c;
  --navcdp-gold:        #fcb40c;
  --navcdp-gold-deep:   #c98c05;
  --navcdp-brown:       #604830;
  --navcdp-brown-deep:  #42301d;

  /* ---- Extended ---------------------------------------------------------- */
  --ufs-teal:    #0e7490;
  --ufs-teal-dp: #0a5570;
  --ufs-red:     #c8322c;
  --ufs-red-dp:  #9b1c2a;

  /* ---- Tints ------------------------------------------------------------- */
  --tint-green:  #ecf7ed;
  --tint-green2: #d8eeda;
  --tint-gold:   #fff6e0;
  --tint-gold2:  #ffe9b8;
  --tint-teal:   #e4f3f8;
  --tint-red:    #fdeceb;
  --tint-brown:  #f5f0ea;

  /* ---- Semantic ---------------------------------------------------------- */
  --primary:        var(--navcdp-green);
  --primary-hover:  var(--navcdp-green-mid);
  --primary-deep:   var(--navcdp-green-deep);
  --accent:         var(--navcdp-gold);

  --ink:        #15241a;
  --ink-soft:   #3d4f44;
  --muted:      #6b7a70;
  --muted-soft: #93a19a;
  --line:       #e3eae5;
  --line-soft:  #eef3f0;
  --surface:    #f4f8f5;
  --surface-2:  #eaf1ec;
  --card:       #ffffff;

  --sidebar-top:    #2f8f3c;
  --sidebar-mid:    #1f6b2c;
  --sidebar-bottom: #11431c;

  /* ---- Shape and depth ---------------------------------------------------- */
  --r-sm: 8px;
  --r:    12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  --sh-xs: 0 1px 2px rgba(17, 67, 28, .06);
  --sh-sm: 0 2px 8px rgba(17, 67, 28, .07);
  --sh:    0 8px 24px rgba(17, 67, 28, .09);
  --sh-lg: 0 18px 44px rgba(17, 67, 28, .14);

  --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --sidebar-w: 264px;
  --topbar-h: 68px;
  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* Dark mode: opt-in via data-theme, or follow the system when unset. */
:root[data-theme="dark"],
:root[data-theme="auto"]:is(.dark-pref) {
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; }
}

:root[data-theme="dark"] { --theme-dark: 1; }

/* The dark palette is applied through one shared block so both the explicit
   and the system-preference paths stay identical. */
:root[data-theme="dark"],
:root:not([data-theme="light"]):not([data-theme="dark"]) {
  /* placeholder so the selector list below can be shared */
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink:        #e8f0ea;
    --ink-soft:   #c2d2c7;
    --muted:      #94a79b;
    --muted-soft: #6f8278;
    --line:       #24342a;
    --line-soft:  #1d2a22;
    --surface:    #0e1712;
    --surface-2:  #141f18;
    --card:       #16221b;

    --tint-green:  #16301c;
    --tint-green2: #1d4225;
    --tint-gold:   #332604;
    --tint-gold2:  #4a3708;
    --tint-teal:   #0c2b36;
    --tint-red:    #3a1513;
    --tint-brown:  #2a2118;

    --sh-xs: 0 1px 2px rgba(0, 0, 0, .4);
    --sh-sm: 0 2px 8px rgba(0, 0, 0, .45);
    --sh:    0 8px 24px rgba(0, 0, 0, .5);
    --sh-lg: 0 18px 44px rgba(0, 0, 0, .6);
  }
}

:root[data-theme="dark"] {
  --ink:        #e8f0ea;
  --ink-soft:   #c2d2c7;
  --muted:      #94a79b;
  --muted-soft: #6f8278;
  --line:       #24342a;
  --line-soft:  #1d2a22;
  --surface:    #0e1712;
  --surface-2:  #141f18;
  --card:       #16221b;

  --tint-green:  #16301c;
  --tint-green2: #1d4225;
  --tint-gold:   #332604;
  --tint-gold2:  #4a3708;
  --tint-teal:   #0c2b36;
  --tint-red:    #3a1513;
  --tint-brown:  #2a2118;

  --sh-xs: 0 1px 2px rgba(0, 0, 0, .4);
  --sh-sm: 0 2px 8px rgba(0, 0, 0, .45);
  --sh:    0 8px 24px rgba(0, 0, 0, .5);
  --sh-lg: 0 18px 44px rgba(0, 0, 0, .6);
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5 { margin: 0; font-weight: 700; line-height: 1.25; letter-spacing: -.011em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.22rem; }
h3 { font-size: 1.04rem; }
h4 { font-size: .94rem; }
p  { margin: 0 0 .9rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--primary-deep); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--primary); }

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

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

::selection { background: var(--tint-green2); color: var(--ink); }

.mono { font-family: var(--mono); font-size: .88em; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.tiny  { font-size: .74rem; }
.strong { font-weight: 700; }
.nowrap { white-space: nowrap; }
.center { text-align: center; }
.right  { text-align: right; }
.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.stack   { display: flex; flex-direction: column; gap: 1rem; }
.stack-sm { display: flex; flex-direction: column; gap: .5rem; }
.row     { display: flex; align-items: center; gap: .6rem; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.wrap    { flex-wrap: wrap; }
.grow    { flex: 1 1 auto; min-width: 0; }
.gap-sm  { gap: .4rem; }
.gap-lg  { gap: 1.4rem; }

/* ---------------------------------------------------------------------------
   Dashboard shell
   --------------------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(177deg, var(--sidebar-top) 0%, var(--sidebar-mid) 42%, var(--sidebar-bottom) 100%);
  color: #fff;
  padding: 1rem .75rem 1.2rem;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .25) transparent;
  z-index: 40;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .22); border-radius: 3px; }

.brand {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .4rem .5rem 1rem;
  margin-bottom: .75rem;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
}
.brand-mark {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  background: #fff;
  border-radius: 11px;
  padding: 5px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-text { min-width: 0; }
.brand-kicker {
  font-size: .62rem; font-weight: 800; letter-spacing: .13em;
  text-transform: uppercase; color: rgba(255, 255, 255, .62);
}
.brand-name {
  font-size: .98rem; font-weight: 800; color: #fff; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.nav-group { margin-bottom: .35rem; }
.nav-label {
  font-size: .63rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase;
  color: rgba(255, 255, 255, .45);
  padding: .9rem .75rem .4rem;
}
.nav-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .58rem .75rem;
  border-radius: 10px;
  color: rgba(255, 255, 255, .84);
  font-size: .875rem; font-weight: 600;
  transition: background .15s var(--ease), color .15s var(--ease);
  position: relative;
}
.nav-item:hover { background: rgba(255, 255, 255, .11); color: #fff; }
.nav-item.is-active { background: rgba(255, 255, 255, .17); color: #fff; }
.nav-item.is-active::before {
  content: ""; position: absolute; left: -.75rem; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--navcdp-gold);
}
.nav-item .ico { width: 18px; height: 18px; flex: 0 0 auto; opacity: .92; }
.nav-item .count {
  margin-left: auto; font-size: .7rem; font-weight: 800;
  background: rgba(255, 255, 255, .2); color: #fff;
  padding: .08rem .42rem; border-radius: var(--r-pill);
}
.nav-item.is-active .count { background: var(--navcdp-gold); color: var(--navcdp-brown-deep); }

.sidebar-foot {
  margin-top: auto;
  padding-top: .9rem;
  border-top: 1px solid rgba(255, 255, 255, .14);
}
.sidebar-user {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .55rem; border-radius: 10px;
  background: rgba(255, 255, 255, .09);
}
.sidebar-user .avatar { background: var(--navcdp-gold); color: var(--navcdp-brown-deep); }
.sidebar-user .who { min-width: 0; }
.sidebar-user .nm {
  font-size: .82rem; font-weight: 700; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user .rl { font-size: .68rem; color: rgba(255, 255, 255, .62); }

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

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.6rem;
  background: color-mix(in srgb, var(--card) 86%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.18rem; }
.topbar .sub { font-size: .78rem; color: var(--muted); margin-top: -1px; }

.burger {
  display: none;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink); cursor: pointer;
}

.content { padding: 1.5rem 1.6rem 3.5rem; flex: 1; }
.content-narrow { max-width: 920px; }

.page-head { margin-bottom: 1.25rem; }
.page-head h2 { margin-bottom: .2rem; }
.page-head .lead { color: var(--muted); font-size: .9rem; }

/* ---------------------------------------------------------------------------
   Cards, panels, tiles
   --------------------------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-xs);
}
.card-pad { padding: 1.15rem 1.25rem; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line-soft);
}
.card-head h3 { font-size: .98rem; }
.card-head .hint { font-size: .78rem; color: var(--muted); }
.card-body { padding: 1.15rem 1.25rem; }
.card-foot {
  padding: .85rem 1.25rem;
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }

/* ---- Stat tile ------------------------------------------------------------ */
.stat {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 1.05rem 1.15rem;
  box-shadow: var(--sh-xs);
  overflow: hidden;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--sh-sm); }
.stat::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--primary);
}
.stat.is-gold::after { background: var(--navcdp-gold); }
.stat.is-teal::after { background: var(--ufs-teal); }
.stat.is-brown::after { background: var(--navcdp-brown); }
.stat.is-red::after { background: var(--ufs-red); }

.stat-top { display: flex; align-items: center; justify-content: space-between; gap: .6rem; }
.stat-label {
  font-size: .72rem; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted);
}
.stat-ico {
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--tint-green); color: var(--primary-deep);
}
.stat.is-gold .stat-ico { background: var(--tint-gold); color: var(--navcdp-gold-deep); }
.stat.is-teal .stat-ico { background: var(--tint-teal); color: var(--ufs-teal); }
.stat.is-brown .stat-ico { background: var(--tint-brown); color: var(--navcdp-brown); }
.stat.is-red .stat-ico { background: var(--tint-red); color: var(--ufs-red); }

.stat-value {
  font-size: 1.85rem; font-weight: 800; letter-spacing: -.03em;
  line-height: 1.1; margin-top: .45rem;
  font-variant-numeric: tabular-nums;
}
.stat-meta { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.stat-delta { font-size: .76rem; font-weight: 700; }
.stat-delta.up { color: var(--primary-deep); }
.stat-delta.down { color: var(--ufs-red); }

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  min-height: 40px;
  padding: .5rem 1rem;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit; font-size: .875rem; font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s var(--ease), border-color .15s var(--ease),
              color .15s var(--ease), transform .08s var(--ease), box-shadow .15s var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn.is-disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn .ico { width: 17px; height: 17px; }

.btn-primary {
  background: var(--primary); color: #fff;
  box-shadow: 0 1px 2px rgba(17, 67, 28, .2);
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); color: #fff; }

.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }

.btn-soft { background: var(--tint-green); color: var(--primary-deep); }
.btn-soft:hover:not(:disabled) { background: var(--tint-green2); color: var(--primary-deep); }

.btn-gold { background: var(--navcdp-gold); color: var(--navcdp-brown-deep); }
.btn-gold:hover:not(:disabled) { background: var(--navcdp-gold-deep); color: #fff; }

.btn-danger { background: var(--ufs-red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--ufs-red-dp); color: #fff; }

.btn-link { background: none; color: var(--primary-deep); border: 0; padding: .3rem .4rem; min-height: 0; }
.btn-link:hover { text-decoration: underline; }

.btn-sm { min-height: 32px; padding: .28rem .7rem; font-size: .8rem; border-radius: 8px; }
.btn-lg { min-height: 48px; padding: .7rem 1.4rem; font-size: .95rem; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-icon { width: 38px; min-height: 38px; padding: 0; }

.btn-group { display: inline-flex; gap: .45rem; flex-wrap: wrap; }

/* ---------------------------------------------------------------------------
   Badges and chips
   --------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .18rem .55rem;
  border-radius: var(--r-pill);
  font-size: .73rem; font-weight: 700; line-height: 1.5;
  white-space: nowrap;
}
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85;
}
.badge-plain::before { display: none; }

.badge-success { background: var(--tint-green);  color: var(--primary-deep); }
.badge-info    { background: var(--tint-teal);   color: var(--ufs-teal); }
.badge-warn    { background: var(--tint-gold);   color: var(--navcdp-gold-deep); }
.badge-danger  { background: var(--tint-red);    color: var(--ufs-red-dp); }
.badge-muted   { background: var(--surface-2);   color: var(--muted); }
.badge-brown   { background: var(--tint-brown);  color: var(--navcdp-brown); }

.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .7rem;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--card);
  font-size: .8rem; font-weight: 600; color: var(--ink-soft);
  cursor: pointer;
  transition: all .15s var(--ease);
}
.chip:hover { border-color: var(--primary); color: var(--primary-deep); }
.chip.is-on { background: var(--primary); border-color: var(--primary); color: #fff; }

.avatar {
  width: 36px; height: 36px; flex: 0 0 auto;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--tint-green); color: var(--primary-deep);
  font-size: .76rem; font-weight: 800; letter-spacing: .02em;
}
.avatar-lg { width: 56px; height: 56px; font-size: 1.05rem; }
.avatar-sm { width: 28px; height: 28px; font-size: .66rem; }

/* ---------------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------------- */
.field { margin-bottom: 1rem; }
.field:last-child { margin-bottom: 0; }

.label {
  display: block;
  font-size: .8rem; font-weight: 700; color: var(--ink-soft);
  margin-bottom: .32rem;
}
.label .req { color: var(--ufs-red); margin-left: .12rem; }
.help { font-size: .76rem; color: var(--muted); margin-top: .28rem; }
.error-text { font-size: .76rem; color: var(--ufs-red); margin-top: .28rem; font-weight: 600; }

.input, .select, .textarea {
  width: 100%;
  min-height: 44px;
  padding: .55rem .8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--ink);
  font: inherit; font-size: .9rem;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-soft); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--surface-2); color: var(--muted); cursor: not-allowed;
}
.input.is-error, .select.is-error { border-color: var(--ufs-red); }
.textarea { min-height: 92px; resize: vertical; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7a70' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2.2rem;
}

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-left: 2.35rem; }
.input-group .ico-left {
  position: absolute; left: .78rem; width: 17px; height: 17px;
  color: var(--muted); pointer-events: none;
}

.check {
  display: flex; align-items: flex-start; gap: .6rem;
  padding: .6rem .75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s var(--ease);
  background: var(--card);
}
.check:hover { border-color: var(--primary); background: var(--tint-green); }
.check input { margin-top: .18rem; width: 17px; height: 17px; accent-color: var(--primary); flex: 0 0 auto; }
.check.is-on { border-color: var(--primary); background: var(--tint-green); }
.check .ck-title { font-size: .87rem; font-weight: 600; }
.check .ck-sub { font-size: .76rem; color: var(--muted); }

/* Big tappable choice cards, used in the field app */
.choice-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .6rem; }
.choice {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem;
  min-height: 86px; padding: .8rem .5rem;
  border: 1.5px solid var(--line);
  border-radius: var(--r);
  background: var(--card);
  cursor: pointer; text-align: center;
  transition: all .15s var(--ease);
}
.choice .ico { width: 24px; height: 24px; color: var(--muted); }
.choice .t { font-size: .85rem; font-weight: 700; }
.choice .s { font-size: .72rem; color: var(--muted); }
.choice:hover { border-color: var(--primary); }
.choice.is-on { border-color: var(--primary); background: var(--tint-green); }
.choice.is-on .ico { color: var(--primary-deep); }
.choice input { display: none; }

.switch { display: inline-flex; align-items: center; gap: .6rem; cursor: pointer; }
.switch input { display: none; }
.switch .track {
  width: 44px; height: 25px; border-radius: var(--r-pill);
  background: var(--line); position: relative; transition: background .18s var(--ease);
  flex: 0 0 auto;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 19px; height: 19px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  transition: transform .18s var(--ease);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(19px); }

fieldset { border: 0; margin: 0; padding: 0; }
.fieldset-title {
  font-size: .72rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); margin: 1.5rem 0 .75rem;
  padding-bottom: .4rem; border-bottom: 1px solid var(--line-soft);
}
.fieldset-title:first-child { margin-top: 0; }

/* ---------------------------------------------------------------------------
   Tables — collapse to cards on small screens
   --------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table thead th {
  position: sticky; top: 0; z-index: 1;
  text-align: left;
  padding: .7rem 1rem;
  font-size: .7rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table tbody td {
  padding: .78rem 1rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr:hover { background: var(--surface); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table a.cell-link { font-weight: 700; color: var(--ink); }
.table a.cell-link:hover { color: var(--primary-deep); }

.table-sortable th[data-sort] { cursor: pointer; user-select: none; }
.table-sortable th[data-sort]:hover { color: var(--ink); }
.table-sortable th .arrow { opacity: .35; margin-left: .25rem; }
.table-sortable th.is-sorted .arrow { opacity: 1; color: var(--primary); }

.cell-person { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.cell-person .nm { font-weight: 700; color: var(--ink); line-height: 1.25; }
.cell-person .sb { font-size: .76rem; color: var(--muted); }

/* ---- Toolbar above a table ------------------------------------------------ */
.toolbar {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--line-soft);
}
.toolbar .search { flex: 1 1 240px; max-width: 340px; }
.toolbar .select { width: auto; min-width: 140px; min-height: 38px; font-size: .84rem; }

.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .8rem 1.25rem;
  border-top: 1px solid var(--line-soft);
  font-size: .82rem; color: var(--muted);
}
.pager .pages { display: flex; gap: .3rem; }
.pager button {
  min-width: 32px; height: 32px; padding: 0 .5rem;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); color: var(--ink);
  font: inherit; font-size: .82rem; font-weight: 600; cursor: pointer;
}
.pager button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary-deep); }
.pager button.is-on { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------------------------------------------------------------------------
   States: empty, loading, offline
   --------------------------------------------------------------------------- */
.empty { padding: 3rem 1.5rem; text-align: center; color: var(--muted); }
.empty .ico {
  width: 52px; height: 52px; margin: 0 auto .8rem;
  display: grid; place-items: center;
  border-radius: 14px; background: var(--surface-2); color: var(--muted-soft);
}
.empty h4 { color: var(--ink); margin-bottom: .3rem; }
.empty p { font-size: .87rem; max-width: 380px; margin: 0 auto .9rem; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line-soft) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: 6px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.sk-line { height: 12px; margin-bottom: .55rem; }
.sk-line:last-child { width: 60%; }

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

.spinner {
  width: 17px; height: 17px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------------------
   Progress and meters
   --------------------------------------------------------------------------- */
.meter { height: 7px; border-radius: var(--r-pill); background: var(--surface-2); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width .4s var(--ease); }
.meter.is-gold > span { background: var(--navcdp-gold); }
.meter.is-teal > span { background: var(--ufs-teal); }
.meter.is-red  > span { background: var(--ufs-red); }

.bar-row { display: grid; grid-template-columns: 1fr auto; gap: .35rem .8rem; align-items: center; margin-bottom: .75rem; }
.bar-row:last-child { margin-bottom: 0; }
.bar-row .nm { font-size: .84rem; font-weight: 600; }
.bar-row .vl { font-size: .82rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-row .meter { grid-column: 1 / -1; }

/* ---------------------------------------------------------------------------
   Timeline — the traceability chain of custody
   --------------------------------------------------------------------------- */
.timeline { position: relative; padding-left: 1.9rem; }
.timeline::before {
  content: ""; position: absolute; left: 11px; top: 8px; bottom: 8px;
  width: 2px; background: var(--line);
}
.tl-item { position: relative; padding-bottom: 1.3rem; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -1.9rem; top: 1px;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--card);
  border: 2px solid var(--line);
  color: var(--muted);
  z-index: 1;
}
.tl-dot .ico { width: 12px; height: 12px; }
.tl-item.is-done .tl-dot { border-color: var(--primary); background: var(--primary); color: #fff; }
.tl-item.is-current .tl-dot { border-color: var(--navcdp-gold); background: var(--navcdp-gold); color: var(--navcdp-brown-deep); }
.tl-title { font-size: .89rem; font-weight: 700; }
.tl-meta { font-size: .78rem; color: var(--muted); }
.tl-note { font-size: .8rem; color: var(--ink-soft); margin-top: .22rem; }

/* ---------------------------------------------------------------------------
   Modal and toast
   --------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(10, 30, 16, .5);
  backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  animation: fade .18s var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  width: 100%; max-width: 560px;
  max-height: calc(100vh - 2rem);
  display: flex; flex-direction: column;
  background: var(--card);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-lg);
  animation: pop .2s var(--ease);
  overflow: hidden;
}
.modal-lg { max-width: 820px; }
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }

.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1.1rem 1.35rem;
  border-bottom: 1px solid var(--line-soft);
}
.modal-body { padding: 1.35rem; overflow-y: auto; }
.modal-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: .6rem;
  padding: 1rem 1.35rem;
  border-top: 1px solid var(--line-soft);
  background: var(--surface);
}
.modal-close {
  width: 34px; height: 34px; border: 0; border-radius: 9px;
  background: var(--surface-2); color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
}
.modal-close:hover { background: var(--line); color: var(--ink); }

.toast-host {
  position: fixed; z-index: 100; bottom: 1.2rem; right: 1.2rem;
  display: flex; flex-direction: column; gap: .5rem;
  max-width: min(380px, calc(100vw - 2rem));
}
.toast {
  display: flex; align-items: flex-start; gap: .65rem;
  padding: .8rem 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: var(--r);
  box-shadow: var(--sh);
  animation: slide-in .22s var(--ease);
  font-size: .86rem;
}
.toast.is-error { border-left-color: var(--ufs-red); }
.toast.is-warn  { border-left-color: var(--navcdp-gold); }
.toast .ico { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; color: var(--primary); }
.toast.is-error .ico { color: var(--ufs-red); }
.toast.is-warn .ico  { color: var(--navcdp-gold-deep); }
.toast .tt { font-weight: 700; }
@keyframes slide-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------------------
   Tabs
   --------------------------------------------------------------------------- */
.tabs {
  display: flex; gap: .2rem;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: .65rem .95rem;
  border: 0; border-bottom: 2px solid transparent;
  background: none; color: var(--muted);
  font: inherit; font-size: .865rem; font-weight: 700;
  cursor: pointer; white-space: nowrap;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.tab:hover { color: var(--ink); }
.tab.is-on { color: var(--primary-deep); border-bottom-color: var(--primary); }
.tab-panel { padding-top: 1.2rem; }

/* ---------------------------------------------------------------------------
   Definition list, used on detail pages
   --------------------------------------------------------------------------- */
.dl { display: grid; grid-template-columns: 150px 1fr; gap: .55rem 1rem; font-size: .875rem; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; font-weight: 600; color: var(--ink); word-break: break-word; }

.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem 1.4rem; }
.kv .k { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kv .v { font-size: .94rem; font-weight: 700; margin-top: .12rem; }

/* ---------------------------------------------------------------------------
   Auth pages
   --------------------------------------------------------------------------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
.auth-art {
  position: relative;
  background:
    radial-gradient(1000px 500px at 15% 10%, rgba(252, 180, 12, .18), transparent 55%),
    linear-gradient(160deg, var(--navcdp-green) 0%, var(--navcdp-green-deep) 45%, var(--navcdp-green-abyss) 100%);
  color: #fff;
  padding: 3rem;
  display: flex; flex-direction: column; justify-content: space-between;
  overflow: hidden;
}
.auth-art::after {
  content: ""; position: absolute; right: -120px; bottom: -120px;
  width: 420px; height: 420px; border-radius: 50%;
  background: rgba(255, 255, 255, .06);
}
.auth-art h2 { font-size: 2.05rem; line-height: 1.18; max-width: 15ch; margin-bottom: .8rem; }
.auth-art p { color: rgba(255, 255, 255, .82); max-width: 44ch; font-size: .95rem; }
.auth-points { display: flex; flex-direction: column; gap: .7rem; margin-top: 1.6rem; position: relative; }
.auth-point { display: flex; gap: .7rem; align-items: flex-start; font-size: .89rem; color: rgba(255, 255, 255, .92); }
.auth-point .ico {
  width: 22px; height: 22px; flex: 0 0 auto;
  border-radius: 6px; background: rgba(255, 255, 255, .16);
  display: grid; place-items: center; padding: 4px;
}

.auth-form {
  display: flex; align-items: center; justify-content: center;
  padding: 2.5rem 2rem;
  background: var(--card);
}
.auth-box { width: 100%; max-width: 388px; }
.auth-logo { width: 72px; margin-bottom: 1.4rem; }
.auth-box h1 { font-size: 1.6rem; margin-bottom: .3rem; }
.auth-box .lead { color: var(--muted); font-size: .9rem; margin-bottom: 1.6rem; }

.demo-creds {
  margin-top: 1.5rem; padding: .9rem 1rem;
  background: var(--surface); border: 1px dashed var(--line);
  border-radius: var(--r); font-size: .78rem;
}
.demo-creds h5 { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: .5rem; }
.demo-creds button {
  display: flex; width: 100%; justify-content: space-between; gap: .6rem; align-items: center;
  padding: .32rem .45rem; margin: 0 -.45rem;
  border: 0; border-radius: 7px; background: none;
  font: inherit; font-size: .78rem; color: var(--ink-soft); cursor: pointer; text-align: left;
}
.demo-creds button:hover { background: var(--tint-green); color: var(--primary-deep); }
.demo-creds .r { color: var(--muted); font-size: .72rem; }

.alert {
  display: flex; gap: .6rem; align-items: flex-start;
  padding: .75rem .9rem;
  border-radius: var(--r);
  font-size: .85rem; font-weight: 600;
  margin-bottom: 1rem;
}
.alert .ico { width: 18px; height: 18px; flex: 0 0 auto; margin-top: 1px; }
.alert-error { background: var(--tint-red); color: var(--ufs-red-dp); }
.alert-ok    { background: var(--tint-green); color: var(--primary-deep); }
.alert-warn  { background: var(--tint-gold); color: var(--navcdp-gold-deep); }
.alert-info  { background: var(--tint-teal); color: var(--ufs-teal); }

/* ---------------------------------------------------------------------------
   Responsive dashboard
   --------------------------------------------------------------------------- */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-sidebar { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1024px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: 280px;
    transform: translateX(-100%);
    transition: transform .25s var(--ease);
    box-shadow: var(--sh-lg);
  }
  .sidebar.is-open { transform: none; }
  .burger { display: flex; }
  .scrim {
    position: fixed; inset: 0; z-index: 39;
    background: rgba(10, 30, 16, .45);
    animation: fade .2s var(--ease);
  }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  .content { padding: 1.1rem 1rem 4rem; }
  .topbar { padding: 0 1rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .dl { grid-template-columns: 1fr; gap: .1rem 0; }
  .dl dt { margin-top: .6rem; }
  .stat-value { font-size: 1.6rem; }

  /* Tables become cards */
  .table-cards thead { display: none; }
  .table-cards tbody tr {
    display: block;
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--line-soft);
  }
  .table-cards tbody td {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .22rem 0; border: 0;
  }
  .table-cards tbody td::before {
    content: attr(data-label);
    font-size: .72rem; font-weight: 700; letter-spacing: .05em;
    text-transform: uppercase; color: var(--muted);
    flex: 0 0 auto;
  }
  .table-cards tbody td.cell-wide { display: block; }
  .table-cards tbody td.cell-wide::before { display: block; margin-bottom: .3rem; }
  .table-cards .num { text-align: left; }
}

/* ---------------------------------------------------------------------------
   Print — attendance registers and batch labels
   --------------------------------------------------------------------------- */
@media print {
  .sidebar, .topbar, .no-print, .toast-host { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .content { padding: 0; }
  .card { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}
