/* Tokens follow exploix.com: navy surfaces, teal accent, pill buttons, Rajdhani eyebrows and a faint grid.
   Two themes share every component; only the variables below change. */
:root, :root[data-theme="dark"] {
  --bg: #0A1626;
  --bg-2: #0F2036;
  --surface: #142A45;
  --surface-2: #1B3557;
  --field: #0D1C30;
  --glass: rgba(10, 22, 38, 0.88);
  --ink: #EEF5FF;
  --ink-strong: #FFFFFF;
  --dim: #C0D3E8;
  --muted: #9AB0CA;
  --line: rgba(255, 255, 255, 0.10);
  --line-2: rgba(255, 255, 255, 0.18);
  --line-accent: rgba(43, 227, 194, 0.35);
  --accent: #2BE3C2;
  --accent-2: #1FA89A;
  --accent-soft: rgba(43, 227, 194, 0.12);
  --hover: rgba(43, 227, 194, 0.07);
  --warn: #FF6B86;
  --warn-soft: rgba(255, 107, 134, 0.12);
  --amber: #FFBE5C;
  --scrim: rgba(3, 8, 16, 0.7);
  --shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.7);
  --grid: rgba(43, 227, 194, 0.035);
  --glow: rgba(43, 227, 194, 0.10);
  --c-sale: #B4C7DC;
  --c-quote: #FFBE5C;
  --c-test: #5FD3F5;
  --c-report: #C3ABFF;
  --c-retest: #FFA677;
  --c-done: #2BE3C2;
  --c-closed: #93A6BD;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #F3F6FA;
  --bg-2: #E8EEF6;
  --surface: #FFFFFF;
  --surface-2: #EEF3F9;
  --field: #FFFFFF;
  --glass: rgba(255, 255, 255, 0.9);
  --ink: #13243A;
  --ink-strong: #071426;
  --dim: #34506F;
  --muted: #566F8D;
  --line: rgba(10, 30, 60, 0.10);
  --line-2: rgba(10, 30, 60, 0.18);
  --line-accent: rgba(11, 140, 120, 0.40);
  --accent: #0A8571;
  --accent-2: #087060;
  --accent-soft: rgba(11, 140, 120, 0.10);
  --hover: rgba(11, 140, 120, 0.06);
  --warn: #C8243F;
  --warn-soft: rgba(200, 36, 63, 0.08);
  --amber: #A35F00;
  --scrim: rgba(15, 30, 50, 0.45);
  --shadow: 0 24px 60px -28px rgba(15, 40, 70, 0.35);
  --grid: rgba(11, 140, 120, 0.05);
  --glow: rgba(43, 227, 194, 0.16);
  --c-sale: #4A6382;
  --c-quote: #A35F00;
  --c-test: #0A75A0;
  --c-report: #6346D1;
  --c-retest: #BC4A12;
  --c-done: #0A8571;
  --c-closed: #687C93;
  color-scheme: light;
}
:root {
  --btn-a: #2BE3C2;
  --btn-b: #1FA89A;
  --btn-ink: #04121A;
  --radius: 14px;
  --font-body: "Heebo", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --font-brand: "Rajdhani", "Heebo", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --top-h: 64px;
  --tab-h: 0px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: radial-gradient(ellipse 70% 50% at 50% -10%, var(--glow), transparent 70%), linear-gradient(180deg, var(--bg-2), var(--bg) 60%);
  background-attachment: fixed;
  color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.6;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 30%, transparent 85%);
}
body > * { position: relative; z-index: 1; }
body.lock { overflow: hidden; }

svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
h1, h2 { font-weight: 800; margin: 0; text-wrap: balance; color: var(--ink-strong); letter-spacing: -0.01em; }
h1 { font-size: clamp(26px, 3.2vw, 34px); line-height: 1.15; }
h2 { font-size: 20px; font-weight: 700; }
code { font-family: var(--font-mono); font-size: 14px; }
a { color: var(--accent); }
.muted { color: var(--dim); margin: 0; }
.dim { color: var(--muted); font-size: 14px; }
.eyebrow {
  display: block; font-family: var(--font-brand); font-weight: 700; font-size: 13px;
  letter-spacing: 0.3em; color: var(--accent); margin-bottom: 6px; direction: ltr; text-align: right;
}
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------- controls ---------- */
.btn {
  font: inherit; font-weight: 700; font-size: 15px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  padding: 10px 20px; border-radius: 999px; min-height: 44px; white-space: nowrap;
  transition: transform .15s ease, border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.btn:hover { border-color: var(--line-accent); background: var(--hover); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, var(--btn-a), var(--btn-b)); border-color: transparent; color: var(--btn-ink);
  box-shadow: 0 8px 24px -10px rgba(43, 227, 194, 0.6);
}
.btn.primary:hover { box-shadow: 0 10px 30px -8px rgba(43, 227, 194, 0.75); transform: translateY(-1px); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.btn.danger:hover { background: var(--warn-soft); border-color: var(--warn); }
.btn.solid-danger { background: var(--warn); color: #fff; border-color: transparent; }
.btn.small { min-height: 36px; padding: 5px 14px; font-size: 14px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; flex: none;
  border: 1px solid var(--line-2); background: transparent; color: var(--dim); cursor: pointer;
}
.icon-btn:hover { color: var(--accent); border-color: var(--line-accent); }
:root[data-theme="dark"] .i-moon, :root[data-theme="light"] .i-sun { display: none; }
.gate-theme { position: fixed; top: max(16px, env(safe-area-inset-top)); left: max(16px, env(safe-area-inset-left)); z-index: 5; background: var(--glass); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

input, select, textarea {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--field);
  border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 14px; width: 100%; min-height: 46px;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled, select:disabled { opacity: 0.6; }
select {
  appearance: none; padding-left: 38px; background-repeat: no-repeat; background-position: 14px 50%; background-size: 14px 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237D93AD' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}
option { background: var(--surface); color: var(--ink); }
textarea { resize: vertical; min-height: 96px; }
input::placeholder, textarea::placeholder { color: var(--muted); }
input[dir="ltr"] { text-align: right; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; color: var(--dim); min-width: 0; }
.err { color: var(--warn); margin: 0; font-size: 15px; }
.hint-warn { color: var(--amber); margin: -6px 0 0; font-size: 14px; }
.note-info { margin: 0; font-size: 15px; color: var(--accent); background: var(--accent-soft); border: 1px solid var(--line-accent); border-radius: 10px; padding: 8px 12px; }

/* ---------- gate: setup, login, 2FA ---------- */
.gate {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding: max(24px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.gate-shell {
  width: min(920px, 100%); display: grid; grid-template-columns: 1.05fr 1fr; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line-accent); border-radius: 20px; box-shadow: var(--shadow);
}
.gate-shell > .gate-card { border: 0; border-radius: 0; background: transparent; box-shadow: none; width: 100%; padding: 44px 40px; }
/* The brand side stays dark in both themes: the logo is white. */
.gate-brand {
  position: relative; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 28px; padding: 44px 32px;
  background: radial-gradient(ellipse at 50% 40%, rgba(43, 227, 194, 0.22), transparent 65%), linear-gradient(135deg, #0B1B2E, #061320);
}
.gate-brand::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(43, 227, 194, 0.06) 1px, transparent 1px), linear-gradient(90deg, rgba(43, 227, 194, 0.06) 1px, transparent 1px);
  background-size: 28px 28px;
}
.gate-brand img { position: relative; width: min(300px, 80%); height: auto; filter: drop-shadow(0 10px 30px rgba(43, 227, 194, 0.25)); }
.brand-points { position: relative; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; color: #C0D3E8; font-size: 15px; }
.brand-points li { display: flex; align-items: center; gap: 10px; }
.brand-points li::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: #2BE3C2; transform: rotate(45deg); box-shadow: 0 0 12px #2BE3C2; flex: none; }
.gate-card {
  width: min(440px, 100%); display: flex; flex-direction: column; gap: 16px; padding: 32px 28px;
  background: var(--surface); border: 1px solid var(--line-accent); border-radius: 20px; box-shadow: var(--shadow);
}
.gate-card h1 { font-size: 30px; }
.gate-mark { width: 56px; height: 56px; align-self: flex-start; filter: drop-shadow(0 6px 18px rgba(43, 227, 194, 0.35)); }
.mobile-only { display: none; }
.fine { margin: 0; font-size: 13px; color: var(--muted); text-align: center; }
.pw-field { position: relative; display: block; }
.pw-field input { padding-left: 48px; }
.pw-toggle {
  position: absolute; left: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px;
  display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 8px;
}
.pw-toggle:hover, .pw-toggle[aria-pressed="true"] { color: var(--accent); }
.otp { font-family: var(--font-mono); font-size: 24px; letter-spacing: 0.5em; text-align: center !important; }
.qr { align-self: center; background: #fff; padding: 10px; border-radius: 12px; max-width: 100%; height: auto; border: 1px solid var(--line); }
.secret { display: block; overflow-wrap: anywhere; background: var(--surface-2); border: 1px dashed var(--line-accent); border-radius: 10px; padding: 10px 12px; color: var(--accent); }

/* ---------- app shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 15;
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top);
}
.topbar-in {
  max-width: 1240px; margin: 0 auto; height: var(--top-h); display: flex; align-items: center; gap: 24px;
  padding-inline: max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-left));
}
.brand { display: flex; align-items: center; gap: 10px; flex: none; }
.brand img { width: 34px; height: 34px; }
.brand-name { font-family: var(--font-brand); font-weight: 700; font-size: 22px; letter-spacing: 0.08em; color: var(--ink-strong); display: flex; align-items: baseline; }
.brand-name b { color: var(--accent); font-weight: 700; }
.brand-name small { font-size: 12px; letter-spacing: 0.3em; color: var(--muted); margin-left: 8px; }
.nav { display: flex; gap: 4px; flex: 1; }
.nav button {
  font: inherit; font-weight: 500; font-size: 15px; color: var(--dim); background: transparent; border: 0; cursor: pointer;
  padding: 8px 16px; border-radius: 999px; transition: color .15s ease, background-color .15s ease;
}
.nav button:hover { color: var(--ink-strong); background: var(--hover); }
.nav button[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.me { display: flex; align-items: center; gap: 10px; margin-inline-start: auto; min-width: 0; }
.me-text { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; min-width: 0; margin-inline-end: 4px; }
#who-name { font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.role { font-family: var(--font-brand); font-size: 12px; font-weight: 700; letter-spacing: 0.18em; color: var(--accent); }

#app {
  max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px;
  padding: 28px max(20px, env(safe-area-inset-right)) calc(48px + var(--tab-h) + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
#app > section { display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.section-head { margin-top: 18px; }
.banner { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); color: var(--warn); border-radius: 10px; padding: 10px 14px; font-size: 15px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.stat {
  font: inherit; color: inherit; text-align: start; cursor: pointer; position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm, none);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 4px;
  transition: border-color .15s ease, transform .15s ease;
}
.stat:hover { border-color: var(--line-accent); transform: translateY(-2px); }
.stat[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.stat::after { content: ""; position: absolute; inset-block-start: 0; inset-inline-start: 0; width: 100%; height: 3px; background: var(--k, var(--accent)); }
.stat .num { font-family: var(--font-brand); font-size: 38px; font-weight: 700; line-height: 1; color: var(--k, var(--accent)); font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: 14px; color: var(--dim); font-weight: 500; }
.stat.k-warn { --k: var(--amber); }
.stat.k-danger { --k: var(--warn); }
.stat.k-ok { --k: var(--c-done); }

.tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search { position: relative; flex: 1 1 280px; }
.filter { position: relative; display: flex; gap: 6px; align-items: center; }
.filter-btn { background: var(--surface); min-height: 46px; font-weight: 500; }
.filter-btn.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.filter-btn .chev { transition: transform .15s ease; }
.filter-btn[aria-expanded="true"] .chev { transform: rotate(180deg); }
.filter-clear { width: 38px; height: 38px; }
.filter-menu {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 12; width: 300px; max-width: calc(100vw - 32px); max-height: min(460px, 70vh); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px;
  animation: fade .12s ease;
}
.fitem {
  font: inherit; font-size: 15px; color: var(--ink); background: transparent; border: 0; cursor: pointer; width: 100%;
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; text-align: start;
}
.fitem:hover, .fitem:focus-visible { background: var(--hover); outline: none; }
.fitem .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--muted)); flex: none; }
.fitem .lbl { flex: 1; }
.fitem b { font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 2ch; text-align: center; }
.fitem.zero { color: var(--muted); }
.fitem[aria-checked="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.fitem[aria-checked="true"] b { color: var(--accent); }
.fitem[aria-checked="true"]::after { content: "✓"; font-weight: 700; }
.fsep { height: 1px; background: var(--line); margin: 6px 4px; }
.search svg { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search input { padding-right: 42px; border-radius: 999px; background: var(--surface); }
.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 500;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent);
  border-radius: 999px; padding: 2px 10px; white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); flex: none; }
.s-inquiry, .s-intro { --c: var(--c-sale); }
.s-quote { --c: var(--c-quote); }
.s-scoping, .s-started, .s-finished { --c: var(--c-test); }
.s-report { --c: var(--c-report); }
.s-retest, .s-retest2 { --c: var(--c-retest); }
.s-done { --c: var(--c-done); }
.s-noreply, .s-declined { --c: var(--c-closed); }

.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.head, .row {
  display: grid; gap: 6px 16px; align-items: center; width: 100%; text-align: start;
  grid-template-columns: 1.4fr 1.5fr 0.9fr 1.6fr 1.6fr 1fr; padding: 14px 18px;
}
.head { font-size: 13px; font-weight: 700; color: var(--muted); border-bottom: 1px solid var(--line); padding-block: 10px; background: var(--surface-2); }
.row { color: inherit; border-bottom: 1px solid var(--line); cursor: pointer; transition: background-color .12s ease; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--hover); }
.row:hover .co strong { color: var(--accent); }
.row > * { min-width: 0; }
.co strong { font-weight: 700; color: var(--ink-strong); overflow-wrap: anywhere; transition: color .12s ease; }
.co .fu { display: block; margin-top: 2px; }
.contact { display: flex; flex-direction: column; }
.contact .nm { overflow-wrap: anywhere; }
.contact .ltr { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; text-align: right; }
.inq { color: var(--muted); font-size: 14px; }
.fu { font-size: 14px; font-variant-numeric: tabular-nums; color: var(--dim); }
.fu.late { color: var(--warn); font-weight: 700; }
.empty { padding: 56px 20px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.empty p { margin: 0; color: var(--dim); max-width: 46ch; }
.skeleton { height: 14px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 0%, var(--line-2) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.2s linear infinite; }
.sk-row { padding: 18px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1.4fr 1fr 0.8fr; gap: 16px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* document chips: in the list and in the file panel */
.fchips { display: flex; flex-wrap: wrap; gap: 6px; }
.fchip {
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid color-mix(in srgb, var(--fc) 40%, transparent); background: color-mix(in srgb, var(--fc) 12%, transparent); color: var(--fc);
  border-radius: 8px; padding: 3px 9px; min-height: 30px; white-space: nowrap;
}
.fchip:hover { background: color-mix(in srgb, var(--fc) 22%, transparent); border-color: var(--fc); }
.fchip.more { --fc: var(--muted); font-weight: 500; }
.nofiles { color: var(--muted); font-size: 14px; }
.fcat { font-size: 12px; font-weight: 700; color: var(--fc); background: color-mix(in srgb, var(--fc) 12%, transparent); border: 1px solid color-mix(in srgb, var(--fc) 35%, transparent); border-radius: 6px; padding: 1px 8px; white-space: nowrap; }
.k-report { --fc: var(--c-report); }
.k-scoping { --fc: var(--c-test); }
.k-quote { --fc: var(--c-quote); }
.k-contract { --fc: var(--c-retest); }
.k-other { --fc: var(--c-sale); }

/* users and audit */
.urow { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.urow:last-child { border-bottom: 0; }
.urow > * { min-width: 0; overflow-wrap: anywhere; }
.urow strong { color: var(--ink-strong); }
.uctl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.uctl select { width: 150px; min-height: 40px; padding-block: 6px; }
.uact { grid-column: 1 / -1; display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; padding-top: 12px; border-top: 1px dashed var(--line-2); }
.uact label { flex: 1 1 220px; }
.uform { background: var(--surface); border: 1px solid var(--line-accent); border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.uform .full { grid-column: 1 / -1; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.arow { display: grid; grid-template-columns: 140px 1fr; gap: 4px 16px; padding: 10px 18px; border-bottom: 1px solid var(--line); font-size: 14px; }
.arow:last-child { border-bottom: 0; }
.arow time { color: var(--muted); font-variant-numeric: tabular-nums; }
.arow .what { overflow-wrap: anywhere; }
.arow .what b { color: var(--ink-strong); font-weight: 500; }
.arow .who { color: var(--muted); }
.tag { font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line-2); color: var(--dim); margin-inline-end: 6px; }
.tag.del { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.tag.add { color: var(--accent); border-color: var(--line-accent); }

/* account */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.card .full { grid-column: 1 / -1; }
.me-card { max-width: 560px; }
.me-card > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.pwcard { max-width: 560px; }

/* ---------- side panel ---------- */
#scrim { position: fixed; inset: 0; background: var(--scrim); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); z-index: 20; animation: fade .2s ease; }
#panel {
  position: fixed; inset-block: 0; inset-inline-end: 0; width: min(620px, 100%); z-index: 30;
  background: var(--bg); border-inline-start: 1px solid var(--line-accent);
  overflow-y: auto; overscroll-behavior: contain; box-shadow: -30px 0 80px -30px rgba(0, 0, 0, 0.5);
  animation: slide .22s ease;
}
@keyframes slide { from { transform: translateX(-24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }
.pbody {
  display: flex; flex-direction: column; gap: 22px;
  padding: 20px max(20px, env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
.phead {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; position: sticky; top: 0; z-index: 2;
  padding: calc(16px + env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) 14px max(20px, env(safe-area-inset-left));
  background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.phead h2 { font-size: 23px; overflow-wrap: anywhere; }
.phead .meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.psec { display: flex; flex-direction: column; gap: 12px; }
.psec > h3 { margin: 0; font-family: var(--font-brand); font-size: 13px; font-weight: 700; letter-spacing: 0.25em; color: var(--accent); direction: ltr; text-align: right; }
.ext { font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
.save-hint { display: flex; align-items: center; gap: 8px; }
.save-hint::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: none; }

.up-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.up-row label { flex: 1 1 200px; }
.drop {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--line-accent); border-radius: var(--radius); padding: 22px 16px; color: var(--dim);
  background: var(--accent-soft); transition: background-color .15s ease, border-color .15s ease;
}
.drop:hover, .drop.over { border-color: var(--accent); color: var(--ink-strong); }
.drop svg { color: var(--accent); }
.drop strong { color: var(--ink-strong); font-size: 15px; }
.drop small { font-size: 13px; color: var(--muted); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.uploading { font-size: 14px; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.uploading::before { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-accent); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.frow { display: flex; justify-content: space-between; align-items: center; gap: 10px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; flex-wrap: wrap; }
.ficon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-family: var(--font-brand); font-weight: 700; font-size: 12px; letter-spacing: 0.05em; flex: none; }
.fmain { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 240px; }
.fmain.clickable { cursor: pointer; }
.fmain.clickable:hover strong { color: var(--accent); text-decoration: underline; }
.fname { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; gap: 2px; }
.fname strong { font-weight: 500; color: var(--ink-strong); }
.fname small { color: var(--muted); font-size: 13px; }
.factions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.factions select { width: auto; min-height: 36px; padding-block: 4px; font-size: 14px; }

.note { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.note p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.note small, .event small { color: var(--muted); font-size: 13px; }
.link-btn { font: inherit; font-size: 13px; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.link-btn:hover { color: var(--warn); }
.event { color: var(--dim); font-size: 14px; padding-inline: 6px; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.event::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-2); flex: none; align-self: center; }
.note-form { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.confirm { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--warn); font-size: 15px; }
.danger-zone { border-top: 1px solid var(--line); padding-top: 16px; }

/* ---------- file viewer ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 35; display: flex; flex-direction: column;
  background: var(--bg); animation: fade .15s ease;
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
}
.viewer-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--glass); border-bottom: 1px solid var(--line);
}
.viewer-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 260px; flex-wrap: wrap; }
.viewer-title strong { color: var(--ink-strong); overflow-wrap: anywhere; }
.viewer-title small { color: var(--muted); font-size: 13px; }
.viewer-actions { display: flex; gap: 8px; align-items: center; }
.viewer-body { flex: 1; min-height: 0; display: grid; place-items: center; overflow: auto; background: var(--bg-2); }
.viewer-body iframe { width: 100%; height: 100%; border: 0; background: #fff; }
.viewer-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-body pre {
  align-self: stretch; justify-self: stretch; margin: 0; padding: 20px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: var(--font-mono); font-size: 14px; color: var(--ink); background: var(--surface); direction: ltr; text-align: left;
}
.viewer-msg { text-align: center; padding: 32px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--dim); max-width: 48ch; }
.viewer-msg strong { color: var(--ink-strong); font-size: 18px; }
.viewer-msg.loading::before { content: ""; width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line-accent); border-top-color: var(--accent); animation: spin .8s linear infinite; }

#toast {
  position: fixed; z-index: 40; inset-inline: 16px; margin-inline: auto; width: fit-content; max-width: calc(100% - 32px);
  bottom: calc(20px + var(--tab-h) + env(safe-area-inset-bottom));
  background: var(--ink-strong); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 500;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.5); font-size: 15px; animation: fade .2s ease;
}

.tabbar, .fab { display: none; }

/* ---------- tablet and phone ---------- */
@media (max-width: 959px) {
  .head { display: none; }
  .row { grid-template-columns: 1fr auto; grid-template-areas: "co st" "contact contact" "files files" "inq fu"; padding: 14px 16px; }
  .co { grid-area: co; } .contact { grid-area: contact; } .st { grid-area: st; justify-self: end; }
  .inq { grid-area: inq; } .row > .fu { grid-area: fu; justify-self: end; } .files { grid-area: files; }
  .files .nofiles { display: none; }
}
@media (max-width: 859px) {
  :root { --top-h: 58px; --tab-h: 66px; }
  .gate-shell { grid-template-columns: 1fr; max-width: 460px; }
  .gate-brand { display: none; }
  .gate-shell > .gate-card { padding: 32px 24px; }
  .mobile-only { display: block; }

  .nav { display: none; }
  .topbar-in { gap: 12px; }
  .brand-name { font-size: 20px; }
  #who-name { max-width: 40vw; font-size: 14px; }

  .tabbar {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; z-index: 15; inset-inline: 0; bottom: 0;
    height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line);
  }
  .tabbar button { font: inherit; font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: none; border: 0; color: var(--muted); cursor: pointer; }
  .tabbar button[aria-pressed="true"] { color: var(--accent); font-weight: 700; }
  .fab {
    display: grid; place-items: center; position: fixed; z-index: 16; width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer;
    left: max(18px, env(safe-area-inset-left)); bottom: calc(var(--tab-h) + 18px + env(safe-area-inset-bottom));
    background: linear-gradient(135deg, var(--btn-a), var(--btn-b)); color: var(--btn-ink); box-shadow: 0 12px 30px -8px rgba(43, 227, 194, 0.7);
  }
  .fab[hidden] { display: none; }
  #add { display: none; }

  #app { padding-top: 20px; gap: 14px; }
  .filter { flex: 1 1 100%; }
  .filter-btn { flex: 1; justify-content: center; }
  .filter-menu {
    position: fixed; inset: auto 0 0 0; top: auto; width: 100%; max-width: none; max-height: 75vh; z-index: 25;
    border-radius: 20px 20px 0 0; border-bottom: 0; padding: 10px 10px calc(14px + env(safe-area-inset-bottom));
    box-shadow: 0 0 0 100vmax var(--scrim); animation: sheet-up .2s ease;
  }
  .filter-menu::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--line-2); margin: 2px auto 10px; }
  .fitem { padding: 13px 14px; font-size: 16px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; }
  .stat .num { font-size: 32px; }
  .arow { grid-template-columns: 1fr; }
  #panel { width: 100%; border-inline-start: 0; animation-name: rise; }
  @keyframes rise { from { transform: translateY(24px); opacity: 0; } }
}
@media (max-width: 559px) {
  .me-text { display: none; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1; }
  .urow { grid-template-columns: 1fr; }
  .uform, .card { grid-template-columns: 1fr; }
  .uctl select { flex: 1; width: auto; }
  .gate-card { padding: 26px 20px; }
  .viewer-actions .btn { padding-inline: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
