/* ============================================================
   RegenRoots · design system
   ============================================================ */

:root {
  --font-display: 'Sora', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --bg: #f1f4ee;
  --surface: #ffffff;
  --surface-2: #f7f9f5;
  --line: #e3e8dd;
  --line-2: #d2dac9;

  --ink: #1a241c;
  --ink-2: #4e5e53;
  --ink-3: #7e8d81;

  --pine-deep: #0d1911;
  --pine: #122319;
  --pine-2: #1a3122;
  --pine-3: #23452f;
  --pine-line: rgba(255,255,255,.07);
  --pine-text: #aabfae;

  --green: #2f7d46;
  --green-d: #266239;
  --green-soft: #e4f1e7;
  --green-ring: rgba(47,125,70,.22);
  --lime: #8fd9a0;

  --gold: #a87f15;
  --gold-soft: #f6efd8;
  --red: #c2452f;
  --red-soft: #faeae6;
  --info: #2b6e86;
  --info-soft: #e4f0f4;

  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 9px;

  --shadow-s: 0 1px 2px rgba(20, 31, 23, .05);
  --shadow-m: 0 1px 2px rgba(20,31,23,.04), 0 8px 24px -12px rgba(20,31,23,.18);
  --shadow-l: 0 12px 28px -8px rgba(13,25,17,.22), 0 48px 80px -32px rgba(13,25,17,.3);

  --ease: cubic-bezier(.22,.8,.32,1);
  --ease-pop: cubic-bezier(.3,1.4,.46,1);
  --sidebar-w: 262px;
}

/* ---------- reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(143,217,160,.10), transparent 60%),
    radial-gradient(900px 420px at -10% 110%, rgba(176,148,33,.06), transparent 55%),
    var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
h1,h2,h3,h4 { margin: 0; font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--green); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg { display: block; flex-shrink: 0; }
::selection { background: rgba(47,125,70,.18); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: var(--ink-3); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; border-radius: 4px; }

.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 12px; }
.muted { color: var(--ink-3); }

/* ---------- keyframes ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes slide-r { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
@keyframes slide-l { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes pulse-dot { 0%,100% { box-shadow: 0 0 0 0 rgba(143,217,160,.5);} 60% { box-shadow: 0 0 0 5px rgba(143,217,160,0);} }
@keyframes shake { 10%,90% { transform: translateX(-1px);} 20%,80% { transform: translateX(2px);} 30%,50%,70% { transform: translateX(-3px);} 40%,60% { transform: translateX(3px);} }
@keyframes drift { from { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(-14px) rotate(4deg); } to { transform: translateY(0) rotate(0deg); } }

.anim-rise { animation: rise .45s var(--ease) both; }
.anim-pop { animation: pop .3s var(--ease) both; }
.shake { animation: shake .5s linear; }

.stagger > * { opacity: 0; animation: rise .5s var(--ease) forwards; }
.stagger > *:nth-child(1) { animation-delay: .02s; } .stagger > *:nth-child(2) { animation-delay: .07s; }
.stagger > *:nth-child(3) { animation-delay: .12s; } .stagger > *:nth-child(4) { animation-delay: .17s; }
.stagger > *:nth-child(5) { animation-delay: .22s; } .stagger > *:nth-child(6) { animation-delay: .27s; }
.stagger > *:nth-child(7) { animation-delay: .32s; } .stagger > *:nth-child(8) { animation-delay: .37s; }
.stagger > *:nth-child(n+9) { animation-delay: .42s; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: var(--r-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 13.5px; line-height: 1.2; white-space: nowrap;
  transition: background .18s, border-color .18s, color .18s, transform .12s, box-shadow .18s;
  user-select: none; position: relative;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--green); color: #fff; box-shadow: 0 1px 2px rgba(20,31,23,.2), inset 0 1px 0 rgba(255,255,255,.12); }
.btn-primary:hover { background: var(--green-d); }
.btn-dark { background: var(--pine-2); color: #e9f2ea; }
.btn-dark:hover { background: var(--pine-3); }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--ink-3); color: var(--ink); }
.btn-soft { background: var(--green-soft); color: var(--green-d); }
.btn-soft:hover { background: #d4e9da; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #a83a27; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; animation: spin .7s linear infinite;
}
.btn-ghost.is-loading::after, .btn-soft.is-loading::after { border-color: rgba(47,125,70,.25); border-top-color: var(--green); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: var(--r-sm); border: none; background: transparent;
  color: var(--ink-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }

/* ---------- forms ---------- */
.fld { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.fld > label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); letter-spacing: .01em; }
.fld-in { position: relative; display: flex; align-items: center; }
.fld-in > svg { position: absolute; left: 11px; color: var(--ink-3); pointer-events: none; }
.fld-in > svg + input { padding-left: 36px; }
input.in, select.in, textarea.in {
  width: 100%; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  padding: 9px 12px; font-size: 14px; background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s; outline: none; appearance: none;
}
textarea.in { resize: vertical; min-height: 74px; }
input.in:hover, select.in:hover, textarea.in:hover { border-color: var(--ink-3); }
input.in:focus, select.in:focus, textarea.in:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-ring); }
input.in::placeholder, textarea.in::placeholder { color: #a6b2a8; }
select.in {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237e8d81' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px;
}
.fld.has-error input.in, .fld.has-error select.in, .fld.has-error textarea.in { border-color: var(--red); box-shadow: 0 0 0 3px rgba(194,69,47,.14); }
.fld-err { font-size: 12px; color: var(--red); font-weight: 500; display: flex; gap: 5px; align-items: center; }
.fld-hint { font-size: 12px; color: var(--ink-3); }
.frm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.frm-grid .span2 { grid-column: span 2; }
@media (max-width: 640px) { .frm-grid { grid-template-columns: 1fr; } .frm-grid .span2 { grid-column: span 1; } }

.check { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; color: var(--ink-2); user-select: none; }
.check input { position: absolute; opacity: 0; width: 0; }
.check .box {
  width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line-2); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; transition: all .15s var(--ease-pop); color: #fff;
}
.check .box svg { opacity: 0; transform: scale(.4); transition: all .18s var(--ease-pop); }
.check input:checked + .box { background: var(--green); border-color: var(--green); }
.check input:checked + .box svg { opacity: 1; transform: none; }
.check input:focus-visible + .box { box-shadow: 0 0 0 3px var(--green-ring); }

.pwd-meter { display: flex; gap: 4px; margin-top: 2px; }
.pwd-meter span { height: 4px; flex: 1; border-radius: 2px; background: var(--line); transition: background .25s; }
.pwd-meter.s1 span:nth-child(1) { background: var(--red); }
.pwd-meter.s2 span:nth-child(-n+2) { background: var(--gold); }
.pwd-meter.s3 span:nth-child(-n+3) { background: #6aa84f; }
.pwd-meter.s4 span { background: var(--green); }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-s); }
.card-pad { padding: 20px; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.card-h2 { display:flex; flex-direction: column; gap: 1px; }
.card-title { font-size: 14.5px; font-weight: 700; font-family: var(--font-display); letter-spacing: -.005em; }
.card-sub { font-size: 12px; color: var(--ink-3); }
.card-body { padding: 16px 20px 20px; }
.card-h + .card-bd:not(.card-body) { margin-top: 14px; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1180px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .kpi-grid { grid-template-columns: 1fr; } }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 16px 18px; box-shadow: var(--shadow-s); position: relative; overflow: hidden;
  transition: box-shadow .25s, transform .25s, border-color .25s;
}
.kpi:hover { box-shadow: var(--shadow-m); transform: translateY(-2px); border-color: var(--line-2); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.kpi-ic {
  width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
}
.kpi-ic.tone-green { background: var(--green-soft); color: var(--green-d); }
.kpi-ic.tone-gold { background: var(--gold-soft); color: var(--gold); }
.kpi-ic.tone-red { background: var(--red-soft); color: var(--red); }
.kpi-ic.tone-slate { background: #edf0ea; color: var(--ink-2); }
.kpi-ic.tone-info { background: var(--info-soft); color: var(--info); }
.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--ink-3); letter-spacing: .015em; }
.kpi-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.delta { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 99px; }
.delta.up { background: var(--green-soft); color: var(--green-d); }
.delta.down { background: var(--red-soft); color: var(--red); }
.delta.flat { background: #eef0ec; color: var(--ink-3); }

/* ---------- pills / badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.pill-green { background: var(--green-soft); color: var(--green-d); }
.pill-gold { background: var(--gold-soft); color: var(--gold); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-slate { background: #edf0ea; color: var(--ink-2); }
.pill-info { background: var(--info-soft); color: var(--info); }
.pill-dark { background: var(--pine-2); color: #cfe6d4; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; border-radius: 0 0 var(--r-lg) var(--r-lg); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl thead th {
  text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase;
  color: var(--ink-3); padding: 10px 14px; border-bottom: 1px solid var(--line);
  background: var(--surface-2); position: sticky; top: 0; white-space: nowrap;
}
.tbl thead th:first-child { padding-left: 20px; } .tbl thead th:last-child { padding-right: 20px; }
.tbl tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody td:first-child { padding-left: 20px; } .tbl tbody td:last-child { padding-right: 20px; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl th.num { text-align: right; }
.tbl .cell-main { font-weight: 600; }
.tbl .cell-sub { font-size: 11.5px; color: var(--ink-3); font-weight: 400; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable .sort-ic { display: inline-block; margin-left: 4px; opacity: .55; vertical-align: -2px; }

/* ---------- progress bars ---------- */
.bar { height: 8px; background: #e9ede5; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--green); transform-origin: left; transition: width .9s var(--ease); }
.bar > i.low { background: var(--red); }
.bar > i.mid { background: var(--gold); }

/* ---------- empty state ---------- */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 44px 24px; gap: 6px; }
.empty .empty-ic {
  width: 52px; height: 52px; border-radius: 16px; background: var(--surface-2); border: 1px dashed var(--line-2);
  display: flex; align-items: center; justify-content: center; color: var(--ink-3); margin-bottom: 8px;
}
.empty h4 { font-size: 14.5px; }
.empty p { font-size: 12.5px; color: var(--ink-3); max-width: 320px; }
.empty .btn { margin-top: 12px; }

/* ---------- toasts ---------- */
.toast-stack { position: fixed; top: 18px; right: 18px; z-index: 300; display: flex; flex-direction: column; gap: 10px; width: min(360px, calc(100vw - 36px)); }
.toast {
  display: flex; gap: 11px; align-items: flex-start; background: var(--pine-deep); color: #eef5ee;
  border: 1px solid rgba(255,255,255,.08); padding: 13px 14px; border-radius: 13px; box-shadow: var(--shadow-l);
  animation: slide-r .35s var(--ease-pop); transition: opacity .3s, transform .3s;
}
.toast.bye { opacity: 0; transform: translateX(20px); }
.toast .t-ic { margin-top: 1px; }
.toast .t-ic.ok { color: var(--lime); } .toast .t-ic.err { color: #f1a08e; } .toast .t-ic.info { color: #9ccfe0; }
.toast b { display: block; font-size: 13.5px; font-weight: 600; }
.toast span { font-size: 12.5px; color: #b9c8bc; }
.toast .t-x { margin-left: auto; color: #8fa394; background: none; border: none; padding: 2px; border-radius: 6px; }
.toast .t-x:hover { color: #fff; background: rgba(255,255,255,.08); }

/* ---------- modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200; background: rgba(13,25,17,.45);
  backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center;
  padding: 7vh 18px 18px; overflow-y: auto; animation: fadein .2s ease;
}
.modal-backdrop.closing { opacity: 0; transition: opacity .18s; }
.modal {
  background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-l); width: 100%; max-width: 520px;
  animation: pop .28s var(--ease-pop); border: 1px solid var(--line);
}
.modal.closing { opacity: 0; transform: scale(.97); transition: all .18s; }
.modal-h { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 0; }
.modal-h h3 { font-size: 16.5px; }
.modal-b { padding: 16px 22px 22px; }
.modal-f { display: flex; justify-content: flex-end; gap: 10px; padding: 0 22px 20px; }

/* ---------- dropdown ---------- */
.dd { position: relative; }
.dd-menu {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 218px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow-m); padding: 6px; z-index: 120;
  animation: pop .18s var(--ease-pop); transform-origin: top right;
}
.dd-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 11px;
  border-radius: 8px; border: none; background: none; font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  transition: background .12s, color .12s;
}
.dd-item:hover { background: var(--surface-2); color: var(--ink); }
.dd-item.danger { color: var(--red); }
.dd-item.danger:hover { background: var(--red-soft); }
.dd-sep { height: 1px; background: var(--line); margin: 6px 8px; }
.dd-head { padding: 10px 11px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); position: relative; }
.tab {
  padding: 10px 16px 12px; border: none; background: none; font-size: 13.5px; font-weight: 600; color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 8px; position: relative; transition: color .15s;
}
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--green-d); }
.tab-ink { position: absolute; bottom: -1px; height: 2.5px; background: var(--green); border-radius: 3px 3px 0 0; transition: left .3s var(--ease), width .3s var(--ease); }

.seg { display: inline-flex; flex-wrap: wrap; background: #e9ede4; padding: 4px; border-radius: 12px; gap: 2px; }
.seg button {
  border: none; background: none; padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--ink-2);
  border-radius: 9px; transition: all .18s var(--ease); display: inline-flex; gap: 7px; align-items: center;
}
.seg button:hover { color: var(--ink); }
.seg button.active { background: var(--surface); color: var(--green-d); box-shadow: 0 1px 3px rgba(20,31,23,.12); }

/* ---------- date-range filter ---------- */
.range-bar {
  display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 10px 14px; box-shadow: var(--shadow-s);
}
.range-bar-l { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.range-bar-cap { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; color: var(--ink-2); letter-spacing: .01em; }
.range-bar-cap svg { color: var(--ink-3); }
.range-bar-r { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.range-summary {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  background: var(--surface-2); border: 1px solid var(--line); padding: 7px 12px; border-radius: 99px;
}
.range-summary svg { color: var(--green-d); }
.range-bar-x {
  width: 100%; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: 10px; margin-top: 2px;
}
.range-bar-x .pen-seg { flex: 1; }
.range-custom { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.range-custom .in { width: auto; min-width: 148px; padding: 8px 11px; }
.range-custom .range-dash { color: var(--ink-3); display: inline-flex; }
@media (max-width: 720px) {
  .range-bar-l, .range-bar-r { width: 100%; }
  .range-bar-r { margin-left: 0; }
  .range-seg { width: 100%; }
  .range-seg button { flex: 1 1 auto; justify-content: center; }
  .range-custom { width: 100%; }
  .range-custom .in { flex: 1; min-width: 0; }
}

/* ---------- skeleton ---------- */
.skel { border-radius: 8px; background: linear-gradient(90deg, #e8ece4 25%, #f3f6f0 50%, #e8ece4 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }

/* ---------- alerts list ---------- */
.alert-row { display: flex; gap: 11px; padding: 11px 12px; border-radius: 11px; align-items: flex-start; }
.alert-row.red { background: var(--red-soft); } .alert-row.gold { background: var(--gold-soft); } .alert-row.info { background: var(--info-soft); }
.alert-row .a-ic { margin-top: 1px; }
.alert-row.red .a-ic { color: var(--red); } .alert-row.gold .a-ic { color: var(--gold); } .alert-row.info .a-ic { color: var(--info); }
.alert-row b { font-size: 13px; display: block; }
.alert-row span { font-size: 12px; color: var(--ink-2); }

/* ---------- timeline ---------- */
.tline { position: relative; padding-left: 22px; display: flex; flex-direction: column; gap: 16px; }
.tline::before { content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); border-radius: 2px; }
.tline-item { position: relative; }
.tline-item::before {
  content: ''; position: absolute; left: -21px; top: 4px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--green); box-shadow: 0 0 0 3px var(--surface);
}
.tline-item .tl-date { font-size: 11.5px; color: var(--ink-3); font-weight: 600; letter-spacing: .03em; text-transform: uppercase; }
.tline-item .tl-main { font-size: 13.5px; margin-top: 1px; }
.tline-item .tl-main b { font-weight: 600; }

.code-view {
  background: var(--pine-deep); color: #cfe0d2; border-radius: 13px; overflow: hidden;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.65; border: 1px solid var(--pine-2);
}
.code-view .cv-head { display: flex; align-items: center; gap: 9px; padding: 10px 14px; background: var(--pine); border-bottom: 1px solid var(--pine-2); color: #9db4a2; font-size: 12px; }
.code-view pre { margin: 0; padding: 14px 0; overflow: auto; max-height: 440px; }
.code-view .ln { display: flex; padding: 0 14px; white-space: pre; }
.code-view .ln:hover { background: rgba(255,255,255,.04); }
.code-view .ln i { width: 40px; flex-shrink: 0; color: #51695a; font-style: normal; user-select: none; text-align: right; padding-right: 14px; }
.code-view .ln.c { color: #7d967f; }
.code-view .ln .kw { color: #8fd9a0; }

/* ============================================================
   AUTH (setup wizard + login)
   ============================================================ */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(380px, 44%) 1fr; }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth-brand { display: none; } }
.auth-brand {
  position: relative; overflow: hidden; color: #eaf4ec; display: flex; flex-direction: column; justify-content: space-between;
  padding: 44px 48px; background:
    radial-gradient(800px 480px at 110% -20%, rgba(143,217,160,.16), transparent 55%),
    radial-gradient(700px 500px at -30% 115%, rgba(176,148,33,.14), transparent 50%),
    linear-gradient(160deg, #10231725 ,transparent),
    var(--pine-deep);
}
.auth-brand::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: radial-gradient(rgba(255,255,255,.045) 1px, transparent 1px); background-size: 22px 22px;
}
.auth-logo { display: flex; align-items: center; gap: 13px; z-index: 1; }
.auth-tagline { z-index: 1; max-width: 400px; }
.auth-tagline h2 { font-size: clamp(26px, 3vw, 34px); line-height: 1.18; letter-spacing: -.02em; color: #f4faf4; }
.auth-tagline p { margin-top: 14px; color: #a9bfae; font-size: 14.5px; line-height: 1.65; }
.auth-points { z-index: 1; display: flex; flex-direction: column; gap: 13px; }
.auth-point { display: flex; gap: 12px; align-items: center; color: #b9ccbd; font-size: 13.5px; }
.auth-point .pt-ic { width: 34px; height: 34px; border-radius: 10px; background: rgba(143,217,160,.1); border: 1px solid rgba(143,217,160,.18); display: flex; align-items: center; justify-content: center; color: var(--lime); }
.auth-orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: .5; animation: drift 9s ease-in-out infinite; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 460px; }
.auth-card.wide { max-width: 560px; }
.auth-head { margin-bottom: 26px; }
.auth-head h1 { font-size: 24px; letter-spacing: -.02em; }
.auth-head p { color: var(--ink-3); margin-top: 6px; font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-foot { margin-top: 26px; text-align: center; font-size: 12.5px; color: var(--ink-3); }

.logo-mark { width: 42px; height: 42px; border-radius: 13px; background: linear-gradient(145deg, #3c9457, #256238); display: flex; align-items: center; justify-content: center; color: #ecfcef; box-shadow: 0 6px 16px -6px rgba(47,125,70,.55), inset 0 1px 0 rgba(255,255,255,.25); }
.logo-type { font-family: var(--font-display); font-weight: 700; font-size: 17px; letter-spacing: -.01em; line-height: 1.1; }
.logo-type small { display: block; font-family: var(--font-body); font-weight: 500; font-size: 11px; color: var(--ink-3); letter-spacing: .04em; }
.auth-brand .logo-type { color: #f1f8f1; } .auth-brand .logo-type small { color: #93a899; }

/* stepper */
.stepper { display: flex; align-items: center; gap: 0; margin-bottom: 30px; }
.step { display: flex; align-items: center; gap: 9px; }
.step-dot {
  width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--line-2); background: var(--surface);
  display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700; color: var(--ink-3);
  transition: all .3s var(--ease); flex-shrink: 0;
}
.step.active .step-dot { border-color: var(--green); background: var(--green); color: #fff; box-shadow: 0 0 0 4px var(--green-ring); }
.step.done .step-dot { border-color: var(--green); background: var(--green-soft); color: var(--green-d); }
.step-label { font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.step.active .step-label { color: var(--ink); }
.step-line { flex: 1; height: 1.5px; background: var(--line-2); margin: 0 12px; min-width: 24px; position: relative; overflow: hidden; }
.step-line::after { content: ''; position: absolute; inset: 0; background: var(--green); transform: scaleX(0); transform-origin: left; transition: transform .45s var(--ease); }
.step-line.done::after { transform: scaleX(1); }

.conn-status { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; padding: 11px 13px; border-radius: 10px; animation: pop .25s var(--ease); }
.conn-status.ok { background: var(--green-soft); color: var(--green-d); }
.conn-status.err { background: var(--red-soft); color: var(--red); }
.conn-status.busy { background: var(--surface-2); color: var(--ink-2); }

.run-log { display: flex; flex-direction: column; gap: 4px; max-height: 300px; overflow-y: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.run-row { display: flex; align-items: center; gap: 9px; font-size: 12.5px; padding: 5px 7px; border-radius: 7px; animation: slide-l .25s var(--ease) both; }
.run-row .mono { color: var(--ink-2); }
.run-row .r-ok { color: var(--green); } .run-row .r-skip { color: var(--ink-3); } .run-row .r-err { color: var(--red); }
.run-row small { margin-left: auto; color: var(--ink-3); flex-shrink: 0; }

.big-check { width: 84px; height: 84px; margin: 0 auto 18px; border-radius: 50%; background: var(--green-soft); display: flex; align-items: center; justify-content: center; color: var(--green); animation: pop .5s var(--ease-pop); }
.big-check svg path { stroke-dasharray: 60; stroke-dashoffset: 60; animation: draw-check .55s .25s var(--ease) forwards; }
@keyframes draw-check { to { stroke-dashoffset: 0; } }

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--green); animation: spin .7s linear infinite; }

/* ============================================================
   APP SHELL
   ============================================================ */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; position: fixed; top: 0; bottom: 0; left: 0; z-index: 90;
  background: linear-gradient(180deg, var(--pine) 0%, var(--pine-deep) 100%);
  color: var(--pine-text); display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,.05);
  transition: transform .32s var(--ease);
}
.sb-brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 18px; border-bottom: 1px solid var(--pine-line); }
.sb-brand .logo-type { color: #f1f8f1; font-size: 16px; } .sb-brand .logo-type small { color: #8aa190; }
.sb-nav { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; }
.sb-nav::-webkit-scrollbar { width: 6px; }
.sb-nav::-webkit-scrollbar-thumb { background: var(--pine-3); }
.nav-label { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #5d7263; padding: 14px 10px 6px; }
.navlink {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 10px; border: none; background: none;
  color: #b4c6b8; font-size: 13.5px; font-weight: 500; width: 100%; text-align: left; position: relative;
  transition: background .15s, color .15s;
}
.navlink svg { color: #7e947f; transition: color .15s; }
.navlink:hover { background: rgba(255,255,255,.05); color: #e9f2ea; }
.navlink:hover svg { color: var(--lime); }
.navlink.active { background: linear-gradient(90deg, rgba(143,217,160,.14), rgba(143,217,160,.05)); color: #f1faf2; font-weight: 600; }
.navlink.active svg { color: var(--lime); }
.navlink.active::before {
  content: ''; position: absolute; left: -12px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--lime); animation: pop .3s var(--ease);
}
.sb-foot { padding: 14px 16px; border-top: 1px solid var(--pine-line); display: flex; flex-direction: column; gap: 12px; }
.sb-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #8fa896; }
.sb-status .dot { background: var(--lime); animation: pulse-dot 2.4s infinite; }
.sb-user { display: flex; align-items: center; gap: 10px; }
.sb-user .avatar { flex-shrink: 0; }
.sb-user-name { font-size: 13px; font-weight: 600; color: #e9f2ea; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-user-role { font-size: 11px; color: #87a08d; }
.sb-user .icon-btn { margin-left: auto; color: #87a08d; }
.sb-user .icon-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(145deg, #3c9457, #256238);
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700;
  letter-spacing: .02em; box-shadow: inset 0 1px 0 rgba(255,255,255,.22);
}

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 80; display: flex; align-items: center; gap: 14px;
  padding: 14px 28px; background: rgba(241,244,238,.82); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 19px; letter-spacing: -.015em; }
.topbar .tb-sub { font-size: 12.5px; color: var(--ink-3); margin-top: 1px; }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.tb-date { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); background: var(--surface); border: 1px solid var(--line); padding: 7px 13px; border-radius: 99px; box-shadow: var(--shadow-s); }
.tb-bell { position: relative; }
.tb-bell .bell-badge {
  position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px;
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg);
}
.menu-btn { display: none; }

.content { padding: 26px 28px 60px; max-width: 1480px; width: 100%; }
.view-grid { display: flex; flex-direction: column; gap: 16px; }
.cols { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-31 { grid-template-columns: 2fr 1fr; }
.cols-13 { grid-template-columns: 1fr 2fr; }
@media (max-width: 1080px) { .cols-2, .cols-31, .cols-13 { grid-template-columns: 1fr; } }

/* page header inside content */
.page-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* charts */
.chart-box { width: 100%; position: relative; }
.chart-box svg { width: 100%; height: auto; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; padding-top: 10px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-2); font-weight: 500; }
.chart-tip {
  position: fixed; z-index: 400; pointer-events: none; background: var(--pine-deep); color: #edf5ee;
  border-radius: 10px; padding: 9px 12px; font-size: 12px; box-shadow: var(--shadow-l); border: 1px solid rgba(255,255,255,.09);
  opacity: 0; transform: translateY(4px); transition: opacity .15s, transform .15s; max-width: 260px;
}
.chart-tip.show { opacity: 1; transform: none; }
.chart-tip .tip-t { font-weight: 700; margin-bottom: 4px; color: #fff; font-size: 12px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 7px; padding: 1.5px 0; }
.chart-tip .tip-row b { margin-left: auto; padding-left: 14px; font-variant-numeric: tabular-nums; }

/* callout */
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: 13px; border: 1px solid; align-items: flex-start; font-size: 13px; }
.callout.gold { background: var(--gold-soft); border-color: #ecd9a4; color: #6e5510; }
.callout.gold svg { color: var(--gold); }
.callout.info { background: var(--surface-2); border-color: var(--line); color: var(--ink-2); }
.callout.info svg { color: var(--green-d); flex: none; }
.callout b { font-weight: 700; }

/* settings layout */
.set-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.set-row { display: grid; grid-template-columns: 230px 1fr; gap: 20px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: none; }
.set-row h4 { font-size: 13.5px; } .set-row .set-desc { font-size: 12px; color: var(--ink-3); margin-top: 4px; line-height: 1.5; }
@media (max-width: 860px) { .set-row { grid-template-columns: 1fr; gap: 10px; } }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; background: var(--surface-2); border: 1px solid var(--line); padding: 6px 8px 6px 12px; border-radius: 99px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.chip button { border: none; background: none; color: var(--ink-3); display: flex; padding: 2px; border-radius: 50%; }
.chip button:hover { color: var(--red); background: var(--red-soft); }

.kv { display: flex; flex-direction: column; gap: 2px; }
.kv b { font-size: 13px; } .kv span { font-size: 11.5px; color: var(--ink-3); }

/* recent entries list (forms) */
.recent-list { display: flex; flex-direction: column; gap: 9px; max-height: 560px; overflow-y: auto; padding-right: 2px; }
.recent-item { border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; transition: border-color .15s, box-shadow .15s; animation: rise .3s var(--ease); }
.recent-item:hover { border-color: var(--line-2); box-shadow: var(--shadow-s); }
.recent-item .ri-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.recent-item .ri-top b { font-size: 13px; }
.recent-item .ri-top time { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.recent-item .ri-sub { font-size: 12px; color: var(--ink-2); margin-top: 3px; }
.recent-item .ri-note { font-size: 11.5px; color: var(--ink-3); font-style: italic; margin-top: 3px; }
/* deletable entry: content on the left, trash icon pinned on the right */
.recent-item--del { display: flex; align-items: flex-start; gap: 8px; }
.recent-item--del .ri-main { flex: 1 1 auto; min-width: 0; }
.recent-item .ri-del { flex: none; width: 30px; height: 30px; color: var(--ink-3); }
.recent-item .ri-del:hover { background: var(--surface-2); color: var(--red); }
/* pickable entry: the main block is a button that loads the row into the form */
.recent-item--pick .ri-main { cursor: pointer; border-radius: 8px; outline-offset: 2px; }
.recent-item--pick:hover { border-color: var(--green); box-shadow: var(--shadow-s); }
.recent-item--pick .ri-main:focus-visible { outline: 2px solid var(--green); }
.recent-item--pick .ri-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 7px; }
.recent-item--pick .ri-edit-hint { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: var(--ink-3); }
.recent-item--pick:hover .ri-edit-hint { color: var(--green-d); }
.recent-item--pick .ri-edit-hint svg { flex: none; }
.recent-item.is-editing { border-color: var(--green); background: var(--green-soft); box-shadow: 0 0 0 1px var(--green) inset; }
.recent-item.is-editing .ri-edit-hint { color: var(--green-d); }

/* edit banner — sits atop the intake form while editing an existing group */
.edit-banner { display: flex; align-items: center; gap: 11px; padding: 11px 13px; margin-bottom: 4px;
  border: 1px solid #cfe6d5; border-radius: 12px; background: var(--green-soft); }
.edit-banner .eb-ic { flex: none; width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; background: var(--surface); color: var(--green-d); }
.edit-banner .eb-txt { display: flex; flex-direction: column; gap: 1px; flex: 1 1 auto; min-width: 0; }
.edit-banner .eb-title { font-size: 13px; color: var(--green-d); }
.edit-banner .eb-title b { font-weight: 700; }
.edit-banner .eb-sub { font-size: 11.5px; color: #5d7a64; }
.edit-banner .eb-cancel { flex: none; color: var(--green-d); }
.edit-banner .eb-cancel:hover { background: rgba(38,98,57,.1); }

/* splash */
.splash { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.splash .logo-mark { width: 56px; height: 56px; border-radius: 17px; animation: pop .5s var(--ease-pop); }
.splash p { color: var(--ink-3); font-size: 13px; animation: fadein .6s .2s both; }

/* error screen */
.fatal { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.fatal .card { max-width: 460px; padding: 34px; text-align: center; }
.fatal .empty-ic { margin: 0 auto 14px; width: 56px; height: 56px; color: var(--red); background: var(--red-soft); border: none; border-radius: 17px; display:flex; align-items:center; justify-content:center; }
.fatal h2 { font-size: 19px; margin-bottom: 8px; }
.fatal p { color: var(--ink-2); font-size: 13.5px; line-height: 1.6; }

/* ---------- responsive shell ---------- */
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-l); }
  .main { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .content { padding: 20px 16px 48px; }
  .topbar { padding: 12px 16px; }
  .sb-overlay { position: fixed; inset: 0; background: rgba(13,25,17,.45); z-index: 85; animation: fadein .25s; }
}
@media (max-width: 640px) { .tb-date { display: none; } }

/* ---------- mobile (the farm captures data on phones) ---------- */
/* 16px inputs stop iOS/Android auto-zooming on focus. */
@media (max-width: 640px) {
  input.in, select.in, textarea.in { font-size: 16px; }
  .auth-main { padding: 28px 16px; }
  .auth-head h1 { font-size: 22px; }
  .modal-backdrop { padding: 16px 12px 12px; }
}
/* ---------- print ---------- */
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .no-print, .toast-stack { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
  .stagger > * { opacity: 1; animation: none; }
}

/* ---------- inline table action link ---------- */
.inv-link {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  background: none; border: 0; padding: 0;
  cursor: pointer; color: var(--green-d); font-weight: 600; font-size: 12.5px;
}
.inv-link:hover { text-decoration: underline; }

/* ---------- attachment uploader ---------- */
.slip-up { border: 1px dashed var(--line-2); border-radius: var(--r-sm); padding: 12px; background: var(--surface-2); }
.slip-up-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.slip-up-label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: inline-flex; align-items: center; gap: 6px; }
.slip-up-label svg { color: var(--ink-3); }
.slip-empty { font-size: 12px; color: var(--ink-3); margin-top: 10px; }
.slip-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.slip-thumbs:empty { margin-top: 0; }
.slip-thumb-up { position: relative; width: 74px; height: 74px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.slip-thumb-up img { width: 100%; height: 100%; object-fit: cover; }
.slip-rm { position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; border: none; background: rgba(13,25,17,.62); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0; }
.slip-rm:hover { background: var(--red); }

.slip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.slip-thumb { display: block; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.slip-thumb img { width: 100%; height: auto; display: block; }

/* non-image attachment chip (in the uploader) */
.slip-file { display: inline-flex; align-items: center; gap: 8px; padding: 7px 8px 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; max-width: 220px; }
.slip-file .sf-ic { color: var(--ink-3); display: inline-flex; flex-shrink: 0; }
.slip-file .sf-name { font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slip-file .sf-rm { border: none; background: transparent; color: var(--ink-3); cursor: pointer; display: inline-flex; padding: 2px; border-radius: 4px; flex-shrink: 0; }
.slip-file .sf-rm:hover { color: var(--red); background: var(--red-soft); }

/* non-image attachments in the viewer */
.file-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink-2); text-decoration: none; background: #fff; }
.file-row:hover { border-color: var(--ink-3); background: var(--surface-2); }
.file-row > span { flex: 1; font-size: 13px; word-break: break-all; }

/* ---------- pen move timeline ---------- */
.pen-timeline { display: flex; flex-direction: column; }
.pen-tl-row { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.pen-tl-row::before { content: ''; position: absolute; left: 5px; top: 14px; bottom: -2px; width: 2px; background: var(--line); }
.pen-tl-row:last-child::before { display: none; }
.pen-tl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--line-2); flex-shrink: 0; margin-top: 3px; z-index: 1; }
.pen-tl-row.current .pen-tl-dot { background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.pen-tl-body { flex: 1; min-width: 0; }
.pen-tl-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.pen-tl-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ---------- satellite map ---------- */
.rrmap { position: relative; overflow: hidden; background: #b9c3cd; touch-action: none; user-select: none; cursor: grab; }
.rrmap-tiles { position: absolute; inset: 0; cursor: grab; }
.rrmap-tiles:active { cursor: grabbing; }
.rrmap-tile { position: absolute; width: 256px; height: 256px; pointer-events: none; user-select: none; }
.rrmap-tile.err { visibility: hidden; }
.rrmap-overlay { position: absolute; inset: 0; pointer-events: none; }
.rrmap-pen { position: absolute; box-sizing: border-box; border: 2px solid #b8d233; background: rgba(184,210,51,.2); border-radius: 3px; display: flex; align-items: center; justify-content: center; }
.rrmap-pen.clickable { pointer-events: auto; cursor: pointer; }
.rrmap-pen.drag { pointer-events: auto; cursor: grab; border-color: #b8d233; background: rgba(184,210,51,.32); box-shadow: 0 0 0 2px rgba(0,0,0,.25); }
.rrmap-pen.drag.grabbing { cursor: grabbing; }
.rrmap-pen-lbl { font-size: 10px; font-weight: 700; color: #fff; background: rgba(15,91,86,.85); padding: 1px 5px; border-radius: 4px; white-space: nowrap; pointer-events: none; }
/* pen move-history overlay (trail + past spots) */
.rrmap-pen.ghost { border-style: dashed; }
.rrmap-pen.ghost .rrmap-pen-lbl { background: rgba(180,118,8,.92); }
.rrmap-pen.current { box-shadow: 0 0 0 2px rgba(184,210,51,.5); }
.rrmap-pen-seq { position: absolute; top: -9px; left: -9px; width: 18px; height: 18px; border-radius: 50%; background: #b45309; color: #fff; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,.35); pointer-events: none; }
.rrmap-pen.current .rrmap-pen-seq { background: #4d7c0f; }
.rrmap-trail { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.rrmap-trail polyline { fill: none; stroke: #b8d233; stroke-width: 2.5; stroke-dasharray: 7 6; stroke-linecap: round; stroke-linejoin: round; filter: drop-shadow(0 1px 2px rgba(0,0,0,.5)); }
.rrmap-trail circle { fill: #f59e0b; stroke: #fff; stroke-width: 1.5; }
.rrmap-trail circle.cur { fill: #b8d233; }
.map-hist-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.mhb-info { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; }
.mhb-info b { font-weight: 700; }
.rrmap-ctrls { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 4px; }
.rrmap-ctrls button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line-2); background: #fff; color: var(--ink); display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.rrmap-ctrls button:hover { background: var(--surface-2); }
.rrmap-attrib { position: absolute; right: 0; bottom: 0; font-size: 10px; color: #1f2937; background: rgba(255,255,255,.7); padding: 1px 6px; border-radius: 6px 0 0 0; pointer-events: none; }

.farm-map-canvas { height: 60vh; min-height: 360px; border-radius: 0 0 var(--r-lg) var(--r-lg); }
.pen-map-wrap { display: flex; flex-direction: column; gap: 12px; }
.pen-map-canvas { height: 52vh; min-height: 320px; border-radius: var(--r-sm); border: 1px solid var(--line); }
.pen-map-ctrls { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.pmc-fld { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.pmc-fld .in { width: 110px; }
.pmc-fld input[type=range] { width: 150px; }
.pen-map-pos { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-3); }
.pen-map-hint { font-size: 12px; color: var(--ink-3); }

.pen-loc-list { display: flex; flex-direction: column; gap: 8px; }
.pen-loc-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; }
.pen-loc-row .cell-main { font-weight: 600; font-size: 13.5px; }
.pen-loc-row .cell-sub { font-size: 12px; color: var(--ink-3); }

@media (max-width: 640px) {
  .farm-map-canvas { height: 56vh; }
  .pen-map-ctrls { gap: 10px; }
  .pmc-fld .in, .pmc-fld input[type=range] { width: 100%; }
  .pen-map-pos { margin-left: 0; }
}

/* ---------- feed mix builder ---------- */
.mix-build { border: 1px dashed var(--line-2); border-radius: var(--r-sm); padding: 12px; background: var(--surface-2); }
.mix-build-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.mix-rows { display: flex; flex-direction: column; gap: 8px; }
.mix-row { display: flex; gap: 8px; align-items: center; }
.mix-row .mix-feed { flex: 1; min-width: 0; width: auto; }
.mix-row .mix-kg { width: 92px; flex: none; }
.mix-total { margin-top: 12px; }
.mix-total-row { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; }
.mix-total-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 3px; }
.mix-acts { display: flex; gap: 6px; margin-top: 9px; }

/* feed mixes listed on the Feed Management page */
/* ---------- silo & feed-on-hand stock rows ---------- */
.stock-list { display: flex; flex-direction: column; gap: 20px; }
.stock-row + .stock-row { border-top: 1px solid var(--line); padding-top: 18px; }
.stock-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 7px; }
.stock-name { font-weight: 600; font-size: 13.5px; }
.stock-val { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.stock-val.is-low { color: var(--red); font-weight: 700; }
.stock-meta { font-size: 11px; color: var(--ink-3); margin-top: 5px; }
.stock-acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.mix-chip.is-short { background: var(--red-soft); border-color: #f0c9c4; color: var(--red); }
.mix-chip.is-short svg { vertical-align: -1px; }

.fmr-recipe { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.mix-chip { font-size: 11.5px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }
.mix-chip b { font-weight: 700; }

/* ============================================================
   DRiVE · value-add dashboard
   ============================================================ */
.drive { display: flex; flex-direction: column; gap: 18px; }

/* perf colour helpers (shared) */
.is-green { color: var(--green-d); }
.is-orange { color: var(--gold); }
.is-red { color: var(--red); }

/* auto / manual tags */
.drive-tag { display: inline-flex; align-items: center; font-size: 10.5px; font-weight: 700; letter-spacing: .02em; padding: 2px 8px; border-radius: 99px; text-transform: uppercase; }
.drive-tag--auto { background: var(--info-soft); color: var(--info); }
.drive-tag--manual { background: var(--gold-soft); color: var(--gold); }

/* intro / explainer */
.drive-intro { display: flex; gap: 14px; align-items: flex-start; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-s); }
.drive-intro-ic { flex-shrink: 0; width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; background: var(--green-soft); color: var(--green-d); }
.drive-intro b { font-family: var(--font-display); font-size: 14.5px; }
.drive-intro p { font-size: 12.5px; color: var(--ink-2); line-height: 1.6; margin-top: 4px; }
.drive-intro p .drive-tag { vertical-align: 1px; margin: 0 1px; }

/* ---------- scoreboard ---------- */
.drive-score-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 1180px) { .drive-score-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .drive-score-grid { grid-template-columns: 1fr; } }
.dsc { position: relative; overflow: hidden; padding: 18px; border-radius: var(--r-lg); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow-s); }
.dsc-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dsc-ic { width: 36px; height: 36px; border-radius: 11px; display: flex; align-items: center; justify-content: center; }
.dsc-pill { font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 3px 9px; border-radius: 99px; background: rgba(255,255,255,.16); color: #d8ead9; }
.dsc-label { font-size: 12.5px; font-weight: 600; color: var(--ink-3); letter-spacing: .015em; }
.dsc-val { font-family: var(--font-display); font-size: 27px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; margin-top: 2px; }
.dsc-sub { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.dsc--profit .dsc-ic { background: var(--green-soft); color: var(--green-d); }
.dsc--cost .dsc-ic { background: var(--info-soft); color: var(--info); }
.dsc--time .dsc-ic { background: var(--gold-soft); color: var(--gold); }
/* grand total = hero card */
.dsc--grand { color: #eaf4ec; border-color: transparent; background:
  radial-gradient(420px 220px at 110% -30%, rgba(143,217,160,.22), transparent 60%),
  linear-gradient(160deg, var(--pine-2), var(--pine-deep)); box-shadow: var(--shadow-m); }
.dsc--grand .dsc-ic { background: rgba(143,217,160,.16); color: var(--lime); }
.dsc--grand .dsc-label { color: #9db4a2; }
.dsc--grand .dsc-val { color: #fff; }
.dsc--grand .dsc-sub { color: #9db4a2; }

/* ---------- section heading ---------- */
.drive-sec { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; margin: 2px 0 -4px; }
.drive-sec-t { font-size: 15.5px; font-weight: 700; font-family: var(--font-display); }
.drive-sec-s { font-size: 12px; color: var(--ink-3); font-weight: 500; }

/* ---------- value-add grid ---------- */
.drive-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.dva { text-align: left; display: flex; flex-direction: column; padding: 16px 17px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--shadow-s); transition: box-shadow .22s, transform .22s, border-color .22s; }
.dva:hover { box-shadow: var(--shadow-m); transform: translateY(-2px); border-color: var(--line-2); }
.dva.is-active { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-ring), var(--shadow-m); }
.dva-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.dva-ic { width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.dva.is-active .dva-ic { background: var(--green-soft); color: var(--green-d); border-color: transparent; }
.dva-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line-2); }
.dva-dot.is-green { background: var(--green); } .dva-dot.is-orange { background: var(--gold); } .dva-dot.is-red { background: var(--red); }
.dva-name { font-size: 14.5px; font-weight: 700; font-family: var(--font-display); letter-spacing: -.01em; }
.dva-blurb { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; line-height: 1.45; }
.dva-bar { height: 7px; border-radius: 99px; background: #e9ede5; overflow: hidden; margin: 13px 0; }
.dva-bar i { display: block; height: 100%; width: 3%; border-radius: 99px; background: var(--green); transition: width .8s var(--ease), background .3s; }
.dva-bar i.is-orange { background: var(--gold); } .dva-bar i.is-red { background: var(--red); }
.dva-pillars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.dva-pillar { display: flex; flex-direction: column; gap: 1px; padding: 8px 9px; border-radius: 10px; background: var(--surface-2); border-left: 2.5px solid var(--line-2); }
.dva-pillar--profit { border-left-color: var(--green); } .dva-pillar--cost { border-left-color: var(--info); } .dva-pillar--time { border-left-color: var(--gold); }
.dva-pillar-l { font-size: 10.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.dva-pillar-v { font-size: 13px; font-weight: 700; color: var(--ink); }
.dva-foot { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--line); }
.dva-total { font-family: var(--font-display); font-size: 19px; font-weight: 700; letter-spacing: -.01em; }
.dva-foot-l { display: inline-flex; align-items: center; gap: 3px; font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.dva-foot-l svg { transition: transform .2s; }
.dva:hover .dva-foot-l svg { transform: translateX(3px); }

/* ---------- detail panel ---------- */
.drive-detail-wrap:empty { display: none; }
.drive-detail { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-m); overflow: hidden; animation: rise .35s var(--ease) both; }
.drive-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.ddh-title { display: flex; align-items: center; gap: 13px; min-width: 0; }
.ddh-ic { flex-shrink: 0; width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--green-soft); color: var(--green-d); }
.ddh-name { font-size: 16.5px; font-weight: 700; font-family: var(--font-display); letter-spacing: -.01em; }
.ddh-sub { font-size: 12px; color: var(--ink-3); margin-top: 1px; }
.ddh-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 14px 18px 0; }
.ddh-tab { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); transition: border-color .15s, background .15s, box-shadow .15s; }
.ddh-tab:hover { border-color: var(--line-2); }
.ddh-tab-amt { font-family: var(--font-display); font-size: 17px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.ddh-tab-l { font-size: 11.5px; font-weight: 600; color: var(--ink-3); }
.ddh-tab.is-active { background: var(--surface); box-shadow: inset 0 0 0 1.5px var(--green); border-color: transparent; }
.ddh-tab--profit.is-active { box-shadow: inset 0 0 0 1.5px var(--green); }
.ddh-tab--cost.is-active { box-shadow: inset 0 0 0 1.5px var(--info); }
.ddh-tab--time.is-active { box-shadow: inset 0 0 0 1.5px var(--gold); }
.ddh-panes { padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }

.dsub { border: 1px solid var(--line); border-radius: 13px; overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.dsub.is-open { border-color: var(--line-2); box-shadow: var(--shadow-s); }
.dsub-head { display: flex; align-items: center; gap: 13px; width: 100%; text-align: left; padding: 13px 15px; background: none; border: none; }
.dsub-head:hover { background: var(--surface-2); }
.dsub-perf { flex-shrink: 0; width: 4px; align-self: stretch; border-radius: 99px; background: var(--line-2); }
.dsub-perf.is-green { background: var(--green); } .dsub-perf.is-orange { background: var(--gold); } .dsub-perf.is-red { background: var(--red); }
.dsub-left { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dsub-name { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.dsub-desc { font-size: 12px; color: var(--ink-3); line-height: 1.45; }
.dsub-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.dsub-val { font-family: var(--font-display); font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.dsub-chev { display: inline-flex; color: var(--ink-3); transition: transform .25s var(--ease); }
.dsub.is-open .dsub-chev { transform: rotate(180deg); }
@media (max-width: 560px) { .dsub-desc { display: none; } }

.dsub-body { padding: 4px 15px 16px; border-top: 1px solid var(--line); animation: fadein .25s ease; }
.dsub-block { margin-top: 13px; }
.dsub-block-l { display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); margin-bottom: 7px; }
.dsub-formula { display: block; font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; }
.dsub-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.dinput { display: flex; flex-direction: column; gap: 5px; }
.dinput-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.dinput-l { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.dinput-field { position: relative; display: flex; align-items: center; }
.dinput-in { padding-right: 52px; }
.dinput-in.is-auto { background: var(--info-soft); border-color: transparent; color: var(--info); font-weight: 600; cursor: not-allowed; }
.dinput-unit { position: absolute; right: 11px; font-size: 11.5px; font-weight: 600; color: var(--ink-3); pointer-events: none; }

.dsub-result { margin-top: 15px; padding: 14px 15px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.dsub-result-main { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.dsub-result-l { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.dsub-result-v { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.dsub-result-meta { display: flex; flex-wrap: wrap; gap: 7px 16px; margin-top: 9px; font-size: 11.5px; color: var(--ink-3); }
.dsub-result-meta b { color: var(--ink-2); font-weight: 700; }
.dsub-perf-note { display: inline-flex; align-items: center; gap: 6px; }
.dsub-perf-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.dsub-perf-dot.is-green { background: var(--green); } .dsub-perf-dot.is-orange { background: var(--gold); } .dsub-perf-dot.is-red { background: var(--red); }

.ddh-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line); border-top: 1px solid var(--line); }
.ddh-sum { display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; background: var(--surface); }
.ddh-sum-l { font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.ddh-sum-v { font-family: var(--font-display); font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.ddh-sum--profit .ddh-sum-v { color: var(--green-d); }
.ddh-sum--cost .ddh-sum-v { color: var(--info); }
.ddh-sum--time .ddh-sum-v { color: var(--gold); }
@media (max-width: 560px) { .ddh-summary { grid-template-columns: 1fr; } }

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