/* Neumorphic (soft UI) theme: everything is made of the same surface colour,
   lifted with a light top-left / dark bottom-right shadow, or pressed in with inset shadows. */

:root {
  --bg: #e4e9f1;
  --text: #2b3445;
  --muted: #5d6779;
  --hi: #ffffff;               /* light shadow */
  --lo: #b8c1cf;               /* dark shadow */
  --brand: #3a5bd9;
  --brand-2: #5b7cf0;
  --brand-ink: #2a45b0;
  --ok: #1d7a46;
  --ok-tint: #d5ecdf;
  --warn: #8a5a00;
  --warn-tint: #f5e7c4;
  --low: #b42318;
  --low-tint: #f6d9d6;
  --radius: 18px;
  --radius-sm: 12px;

  --raise: 7px 7px 16px var(--lo), -7px -7px 16px var(--hi);
  --raise-sm: 4px 4px 9px var(--lo), -4px -4px 9px var(--hi);
  --raise-xs: 2px 2px 5px var(--lo), -2px -2px 5px var(--hi);
  --press: inset 4px 4px 8px var(--lo), inset -4px -4px 8px var(--hi);
  --press-sm: inset 2px 2px 5px var(--lo), inset -2px -2px 5px var(--hi);

  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { font-size: 15px; line-height: 1.5; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
h1 { font-size: 1.4rem; margin: 0 0 .3rem; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .55rem; }
a { color: var(--brand-ink); }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.center { text-align: center; }
.pad { padding: 2.5rem 1rem; }
.small-text { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.topbar { background: var(--bg); position: sticky; top: 0; z-index: 20; box-shadow: 0 6px 14px rgba(160,172,190,.45), 0 -1px 0 var(--hi) inset; }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: .7rem 16px; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.brand { color: var(--brand-ink); font-weight: 800; text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; gap: .55rem; }
.brand::before { content: ""; width: 30px; height: 30px; border-radius: 10px; box-shadow: var(--raise-sm);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M9 16.5l4.5 4.5L23 11.5' stroke='white' stroke-width='3.2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / cover no-repeat,
              linear-gradient(145deg, var(--brand-2), var(--brand)); }
#nav { display: flex; gap: .5rem; flex-wrap: wrap; flex: 1; }
#nav a { color: var(--muted); text-decoration: none; padding: .42rem .95rem; border-radius: 999px; font-size: .92rem; font-weight: 600; box-shadow: var(--raise-xs); transition: box-shadow .15s, color .15s; }
#nav a:hover { color: var(--brand-ink); }
#nav a.active { color: var(--brand-ink); box-shadow: var(--press-sm); }
.who { display: flex; align-items: center; gap: .7rem; font-size: .88rem; color: var(--muted); }
.who .link { color: var(--brand-ink); font-weight: 600; text-decoration: none; }

/* ---------- layout ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 1.6rem 16px 8rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.card { background: var(--bg); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.4rem; box-shadow: var(--raise); }
.grid { display: grid; gap: 1.4rem; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); margin-bottom: 1rem; }
.tile { background: var(--bg); border-radius: var(--radius); padding: 1.15rem 1.2rem; text-decoration: none; color: inherit; display: block; box-shadow: var(--raise); transition: box-shadow .2s, transform .2s; }
.tile:hover { transform: translateY(-2px); box-shadow: 10px 10px 22px var(--lo), -10px -10px 22px var(--hi); }
.tile:active { box-shadow: var(--press); transform: none; }
.tile .title { font-weight: 700; font-size: 1.06rem; color: var(--text); }
.tile .meta { color: var(--muted); font-size: .86rem; margin-top: .4rem; }
.row { display: flex; gap: .8rem; flex-wrap: wrap; align-items: flex-end; }
.row > * { min-width: 0; }
.spacer { flex: 1; }

/* ---------- forms ---------- */
label.field { display: flex; flex-direction: column; gap: .35rem; font-size: .82rem; font-weight: 600; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: none; border-radius: var(--radius-sm);
  padding: .6rem .8rem; min-width: 0; box-shadow: var(--press-sm); outline: none; transition: box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #8a93a3; }
input:focus, select:focus, textarea:focus { box-shadow: var(--press-sm), 0 0 0 2px var(--brand-2); }
input[type="file"] { padding: .45rem .6rem; font-size: .85rem; max-width: 100%; }
input[type="file"]::file-selector-button { font: inherit; font-weight: 600; border: none; border-radius: 9px; padding: .35rem .8rem; margin-right: .6rem; background: var(--bg); color: var(--brand-ink); box-shadow: var(--raise-xs); cursor: pointer; }
input[type="checkbox"] { width: 1.15rem; height: 1.15rem; padding: 0; accent-color: var(--brand); box-shadow: none; }
select { cursor: pointer; padding-right: 2rem; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235d6779' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .75rem center; background-size: .7rem; }
textarea { width: 100%; min-height: 9rem; font-family: ui-monospace, Menlo, monospace; font-size: .85rem; }
input.invalid { box-shadow: var(--press-sm), 0 0 0 2px var(--low); background: var(--low-tint); }

.btn {
  font: inherit; font-weight: 700; border: none; cursor: pointer; white-space: nowrap; text-decoration: none; display: inline-block;
  padding: .62rem 1.15rem; border-radius: var(--radius-sm); color: #fff;
  background: linear-gradient(145deg, var(--brand-2), var(--brand));
  box-shadow: 5px 5px 11px var(--lo), -5px -5px 11px var(--hi);
  transition: box-shadow .15s, transform .1s;
}
.btn:hover { box-shadow: 6px 6px 14px var(--lo), -6px -6px 14px var(--hi); }
.btn:active { transform: translateY(1px); box-shadow: inset 3px 3px 7px rgba(20,35,110,.45), inset -2px -2px 6px rgba(255,255,255,.25); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn.secondary, .btn.ghost, .btn.danger { background: var(--bg); box-shadow: var(--raise-sm); }
.btn.secondary { color: var(--brand-ink); }
.btn.ghost { color: var(--muted); }
.btn.danger { color: var(--low); }
.btn.secondary:hover, .btn.ghost:hover, .btn.danger:hover { box-shadow: 5px 5px 11px var(--lo), -5px -5px 11px var(--hi); }
.btn.secondary:active, .btn.ghost:active, .btn.danger:active { box-shadow: var(--press-sm); }
.btn.small { padding: .32rem .7rem; font-size: .82rem; border-radius: 10px; box-shadow: var(--raise-xs); }
.btn.small:hover { box-shadow: 3px 3px 7px var(--lo), -3px -3px 7px var(--hi); }
.checkbox { display: inline-flex; align-items: center; gap: .45rem; font-size: .9rem; color: var(--text); padding: .5rem .2rem; cursor: pointer; }

/* ---------- login ---------- */
.login-wrap { max-width: 400px; margin: 7vh auto 0; }
.login-wrap .card { padding: 1.9rem 1.7rem; }
.login-wrap form { display: flex; flex-direction: column; gap: 1.05rem; }
.login-wrap h1 { text-align: center; color: var(--brand-ink); }
.login-wrap .btn { margin-top: .35rem; padding: .75rem; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); background: var(--bg); box-shadow: var(--raise); max-width: 100%; padding: .35rem; margin-bottom: 1rem; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .9rem; }
th, td { padding: .55rem .7rem; text-align: left; vertical-align: middle; }
thead th { position: sticky; top: 0; z-index: 1; background: var(--bg); font-weight: 700; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid #d3dae5; }
thead tr.sub th { text-transform: none; letter-spacing: 0; font-weight: 600; font-size: .82rem; border-bottom: 2px solid #d3dae5; }
tbody td { border-bottom: 1px solid #d6dce6; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #eaeef5; }
tr.low td { background: var(--low-tint); }
tbody tr.low:hover td { background: #f1cdc9; }
tr.low td.pct { color: var(--low); font-weight: 800; }
td.cell-low { color: var(--low); font-weight: 700; }
td.pct { font-weight: 700; }
.att-input { width: 5.4rem; text-align: right; font-weight: 600; }

/* ---------- chips / badges / stats ---------- */
.chips { display: flex; flex-wrap: wrap; gap: .9rem; margin-bottom: 1.4rem; }
.chip { background: var(--bg); border-radius: var(--radius-sm); padding: .6rem .85rem; font-size: .83rem; box-shadow: var(--raise-sm); border-left: 4px solid transparent; }
.chip b { display: block; font-size: .92rem; }
.chip.ok { border-left-color: var(--ok); }
.chip.pending { border-left-color: #d79a1d; }
a.chip:hover { box-shadow: 5px 5px 11px var(--lo), -5px -5px 11px var(--hi); }
.badge { display: inline-block; font-size: .74rem; font-weight: 700; padding: .18rem .6rem; border-radius: 999px; color: var(--muted); box-shadow: var(--press-sm); }
.badge.ok { color: var(--ok); background: var(--ok-tint); }
.badge.pending { color: var(--warn); background: var(--warn-tint); }
.badge.low { color: var(--low); background: var(--low-tint); }
.stats { display: flex; gap: .8rem; flex-wrap: wrap; font-size: .86rem; color: var(--muted); }
.stats > span { padding: .35rem .8rem; border-radius: 999px; box-shadow: var(--press-sm); }
.stats b { color: var(--text); font-size: 1rem; }

/* ---------- sticky save bar ---------- */
.savebar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); z-index: 15; box-shadow: 0 -6px 14px rgba(160,172,190,.45); }
.savebar-inner { max-width: 1280px; margin: 0 auto; padding: .8rem 16px; display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }

/* ---------- tabs (pressed track, raised active pill) ---------- */
.tabs { display: inline-flex; gap: .35rem; padding: .35rem; border-radius: 999px; box-shadow: var(--press); margin: .4rem 0 1.4rem; flex-wrap: wrap; max-width: 100%; }
.tabs a { padding: .45rem 1rem; text-decoration: none; color: var(--muted); font-weight: 700; font-size: .9rem; border-radius: 999px; transition: box-shadow .15s, color .15s; }
.tabs a.active { color: var(--brand-ink); background: var(--bg); box-shadow: var(--raise-sm); }

/* ---------- dialog ---------- */
dialog { border: none; border-radius: var(--radius); padding: 1.5rem; width: min(580px, calc(100vw - 32px)); background: var(--bg); color: var(--text);
  box-shadow: 14px 14px 32px rgba(120,132,150,.55), -10px -10px 26px rgba(255,255,255,.7); }
dialog::backdrop { background: rgba(60,72,92,.35); backdrop-filter: blur(2px); }
dialog .actions { display: flex; justify-content: flex-end; gap: .7rem; margin-top: 1.1rem; }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; width: calc(100vw - 32px); max-width: 540px; }
.toast-msg { background: var(--bg); color: var(--text); padding: .7rem 1.1rem; border-radius: var(--radius-sm); font-size: .9rem; font-weight: 600; box-shadow: 8px 8px 18px rgba(120,132,150,.6), -6px -6px 14px var(--hi); border-left: 4px solid var(--brand); }
.toast-msg.error { border-left-color: var(--low); color: var(--low); }
.toast-msg.success { border-left-color: var(--ok); color: var(--ok); }

/* ---------- notes ---------- */
.note { border-radius: var(--radius-sm); padding: .75rem 1rem; font-size: .88rem; margin-bottom: 1.4rem; box-shadow: var(--press-sm); color: var(--brand-ink); border-left: 4px solid var(--brand); }
.note.warn { color: var(--warn); border-left-color: #d79a1d; }
.legend-low { display: inline-block; width: .95rem; height: .95rem; background: var(--low-tint); border-radius: 4px; vertical-align: -2px; box-shadow: var(--press-sm); }

@media (max-width: 640px) {
  .topbar-inner { gap: .55rem; }
  .who #who-name { display: none; }
  .page-head { align-items: stretch; }
  th, td { padding: .45rem .5rem; }
  .card { padding: 1rem; }
  .grid { gap: 1rem; }
  .tabs { border-radius: var(--radius-sm); }
}
