:root {
  --ink: #131820;
  --ink-2: #1c2530;
  --canvas: #eef1f5;
  --surface: #ffffff;
  --line: #dde3ea;
  --text: #1b2330;
  --muted: #67707e;
  --accent: #1f7a70;      /* deep teal - "vault" */
  --accent-ink: #0f463f;
  --accent-soft: #e5f2f0;
  --clay: #b5642a;
  --danger: #c23b46;
  --danger-soft: #fbe9ea;
  --warn: #b8860b;
  --ok: #2e7d52;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--canvas);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--ink);
  color: #cdd6e2;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand .mark {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: -.01em; color: #fff; font-size: 17px;
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #2aa596);
  display: grid; place-items: center; color: #fff; font-weight: 800;
}
.brand .tag { color: #8592a4; font-size: 12px; margin-top: 4px; letter-spacing: .02em; }

.nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 8px; color: #b7c1d0;
  font-weight: 500; font-size: 14.5px;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav a.active { background: var(--accent); color: #fff; }
.nav a svg { width: 18px; height: 18px; flex: none; opacity: .95; }
.nav .section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: #6b7788; padding: 14px 12px 6px;
}

.side-user {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 14px 16px; font-size: 13px;
}
.side-user .u-name { color: #fff; font-weight: 600; }
.side-user .u-role {
  display: inline-block; margin-top: 3px; font-size: 11px; letter-spacing: .04em;
  text-transform: uppercase; color: var(--accent); font-weight: 700;
}
.side-user button {
  margin-top: 10px; width: 100%; background: rgba(255,255,255,.08);
  color: #d7deea; border: none; padding: 8px; border-radius: 7px; cursor: pointer;
  font-size: 13px;
}
.side-user button:hover { background: rgba(255,255,255,.16); }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }
.content { flex: 1; padding: 30px 34px; max-width: 1180px; width: 100%; }
.page-head { margin-bottom: 22px; }
.page-head h1 { font-size: 24px; margin: 0 0 4px; letter-spacing: -.02em; }
.page-head p { margin: 0; color: var(--muted); }

.footer {
  border-top: 1px solid var(--line);
  padding: 14px 34px; color: var(--muted); font-size: 12.5px;
  font-family: var(--mono); background: var(--surface);
}

/* ---------- Cards / panels ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card + .card { margin-top: 20px; }
.card-head {
  padding: 16px 20px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h2 { font-size: 16px; margin: 0; letter-spacing: -.01em; }
.card-body { padding: 18px 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: .12s; font-family: inherit;
}
.btn:hover { border-color: #c2cad4; background: #fbfcfd; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-danger { background: #fff; border-color: #e6b9bd; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: #384250; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=search],
input[type=datetime-local], textarea, select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { resize: vertical; min-height: 120px; font-family: var(--mono); font-size: 13px; }
.field { margin-bottom: 16px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
tbody tr:hover { background: #f8fafb; }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
}
.badge-pending { background: #fdf3e0; color: var(--warn); }
.badge-approved { background: #e6f4ec; color: var(--ok); }
.badge-denied { background: var(--danger-soft); color: var(--danger); }
.badge-admin { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- File tree ---------- */
.tree { list-style: none; margin: 0; padding: 0; }
.tree .row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; border: 1px solid transparent;
}
.tree .row:hover { background: #f6f8fa; border-color: var(--line); }
.tree .row .ic { width: 18px; height: 18px; flex: none; color: var(--muted); }
.tree .row .ic.folder { color: var(--clay); }
.tree .name { font-weight: 500; }
.tree .meta { color: var(--muted); font-size: 12.5px; margin-left: 6px; }
.tree .spacer { flex: 1; }
.tree .actions { display: flex; gap: 4px; opacity: 0; transition: .12s; }
.tree .row:hover .actions { opacity: 1; }
.tree ul { list-style: none; margin: 2px 0 2px 22px; padding-left: 12px; border-left: 1px dashed var(--line); }

/* ---------- Toast ---------- */
.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; }
.toast {
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 9px;
  box-shadow: var(--shadow); font-size: 14px; max-width: 360px; animation: pop .18s ease;
}
.toast.ok { background: #14532d; }
.toast.err { background: #7f1d24; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

/* ---------- Modal ---------- */
.modal-back {
  position: fixed; inset: 0; background: rgba(15,20,28,.5);
  display: grid; place-items: center; z-index: 1000; padding: 20px;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden;
}
.modal.lg { max-width: 820px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 17px; }
.modal-body { padding: 22px; max-height: 70vh; overflow: auto; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth-hero {
  background: radial-gradient(120% 120% at 0% 0%, #1c2a2e 0%, var(--ink) 55%);
  color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: center;
}
.auth-hero .logo-lg {
  width: 52px; height: 52px; border-radius: 13px;
  background: linear-gradient(135deg, var(--accent), #2aa596);
  display: grid; place-items: center; font-weight: 800; font-size: 24px; color:#fff;
}
.auth-hero h1 { font-size: 34px; letter-spacing: -.03em; margin: 26px 0 0; line-height: 1.1; }
.auth-hero p { color: #9fb0b3; max-width: 400px; font-size: 15px; }
.auth-hero .feat { margin-top: 30px; display: flex; flex-direction: column; gap: 12px; }
.auth-hero .feat div { display: flex; gap: 11px; align-items: center; color: #cdd8d9; font-size: 14px; }
.auth-hero .feat svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.auth-hero .foot { color: #6f7f82; font-size: 12px; font-family: var(--mono); }

.auth-panel { display: grid; place-items: center; padding: 40px; background: var(--surface); }
.auth-form { width: 100%; max-width: 360px; }
.auth-form h2 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.02em; }
.auth-form .sub { color: var(--muted); margin: 0 0 26px; }
.auth-form .btn-primary { width: 100%; padding: 11px; font-size: 15px; }
.err-line { color: var(--danger); font-size: 13.5px; margin-top: 12px; min-height: 18px; }
.otp-input { letter-spacing: .5em; text-align: center; font-size: 20px; font-family: var(--mono); }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; opacity: .4; margin-bottom: 10px; }

.qr-box { text-align: center; }
.qr-box img { width: 200px; height: 200px; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background:#fff; }
.secret {
  font-family: var(--mono); background: var(--canvas); padding: 8px 12px; border-radius: 8px;
  display: inline-block; margin-top: 10px; font-size: 13px; word-break: break-all;
}
.placeholders { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.placeholders code {
  font-family: var(--mono); font-size: 12px; background: var(--accent-soft);
  color: var(--accent-ink); padding: 2px 8px; border-radius: 6px; cursor: pointer;
}
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); gap: 12px; }
.img-card { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background:#fff; }
.img-card img { width: 100%; height: 92px; object-fit: contain; background: #f4f6f8; }
.img-card .cap { padding: 8px; font-size: 12px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.img-card .cap .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: column; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .grid-2 { grid-template-columns: 1fr; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}

/* ---- First-boot setup wizard ---- */
.setup-badge{
  display:inline-block;
  font-size:12px;
  font-weight:600;
  letter-spacing:.04em;
  text-transform:uppercase;
  color:var(--accent);
  background:rgba(31,122,112,.10);
  border:1px solid rgba(31,122,112,.28);
  padding:5px 10px;
  border-radius:999px;
  margin-bottom:14px;
}
.pw-meter{
  height:5px;
  border-radius:999px;
  background:#e6eaef;
  margin:9px 0 7px;
  overflow:hidden;
}
.pw-meter span{
  display:block;
  height:100%;
  width:0;
  border-radius:999px;
  transition:width .18s ease, background .18s ease;
}
.pw-meter span.lvl-1{ background:#d9534f; }
.pw-meter span.lvl-2{ background:#e0a534; }
.pw-meter span.lvl-3{ background:#3f9d5a; }
.pw-meter span.lvl-4{ background:var(--accent); }

/* ---- Users tab helpers ---- */
.row-actions{ white-space:nowrap; display:flex; gap:6px; justify-content:flex-end; }
td.muted{ color:var(--muted); text-align:center; padding:18px 0; }

/* ---- Locked (not yet approved) folders on View Data ---- */
.tree .row.locked .name { color: var(--muted); }
.tree .row.locked .ic svg { color: var(--muted); }
.locked-note {
  font-size: 12px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 999px; padding: 2px 9px; margin-left: 4px;
}

/* ---- Version Control ---- */
.ver-list { display: flex; flex-direction: column; gap: 14px; }
.ver-item { border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; background: var(--surface); }
.ver-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.ver-tag {
  font-family: var(--mono); font-size: 13px; font-weight: 700; color: #fff;
  background: var(--accent); border-radius: 7px; padding: 3px 9px;
}
.ver-title { font-weight: 650; font-size: 15px; }
.ver-date { color: var(--muted); font-size: 13px; margin-left: auto; font-family: var(--mono); }
.ver-notes { margin-top: 10px; color: var(--ink); font-size: 14px; white-space: pre-wrap; line-height: 1.55; }
.notes-cell { color: var(--muted); font-size: 13px; max-width: 260px; }

/* Long page headings (e.g. the full ISDSS name) should wrap cleanly */
.page-head h1 { max-width: 900px; line-height: 1.2; text-wrap: balance; }

/* ---- Mail configuration + mail log ---- */
.cfg-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.cfg-grid .field.wide { grid-column: 1 / -1; }
.cfg-status { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 14px; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot.on { background: #3f9d5a; }
.dot.off { background: #c9ced6; }
.badge-delivered { background: rgba(63,157,90,.12); color: #2f7d46; border-color: rgba(63,157,90,.3); }
.badge-queued { background: rgba(224,165,52,.14); color: #8a6413; border-color: rgba(224,165,52,.35); }
.badge-failed { background: rgba(217,83,79,.12); color: #a8322e; border-color: rgba(217,83,79,.3); }
.mail-preview { color: var(--muted); font-size: 12.5px; max-width: 340px; }
@media (max-width: 860px) { .cfg-grid { grid-template-columns: 1fr; } }

/* ---- Warning banner (e.g. notifications cannot be delivered) ---- */
.warn-banner {
  border: 1px solid rgba(224,165,52,.45);
  background: rgba(224,165,52,.10);
  color: #6d5210;
  border-radius: 11px;
  padding: 13px 16px;
  font-size: 13.5px;
  line-height: 1.55;
  margin-bottom: 16px;
}
.warn-banner a { color: var(--accent); font-weight: 600; margin-left: 6px; }
.req-star { color: #c0392b; font-weight: 700; margin-left: 2px; }

/* ---- Folder dates on View Data ---- */
.folder-dates {
  display: flex; flex-wrap: wrap; gap: 10px 22px;
  margin: 2px 0 8px 34px; padding: 7px 12px;
  border-left: 2px solid var(--line);
  background: rgba(19,24,32,.02);
  border-radius: 0 8px 8px 0;
}
.date-item { display: flex; align-items: baseline; gap: 7px; }
.date-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.date-value { font-family: var(--mono); font-size: 12.5px; color: var(--ink); }
.date-value.muted-value { color: var(--muted); font-style: italic; }
.date-value.date-expired { color: #a8322e; font-weight: 600; }

/* ---- Collapsible tree in Data Management ---- */
.tw { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tw-toolbar {
  display: flex; gap: 8px; align-items: center;
  padding: 8px 12px; border-bottom: 1px solid var(--line); background: rgba(19,24,32,.02);
}
.tw-toolbar .hint { margin-left: auto; }
.caret {
  width: 22px; height: 22px; flex: none; display: inline-flex;
  align-items: center; justify-content: center; cursor: pointer;
  border-radius: 6px; color: var(--muted); background: transparent; border: none;
  transition: transform .15s ease, background .15s ease;
}
.caret:hover { background: rgba(19,24,32,.06); color: var(--ink); }
.caret svg { width: 13px; height: 13px; }
.caret.open { transform: rotate(90deg); }
.caret.leaf { visibility: hidden; cursor: default; }
.child-count {
  font-size: 11.5px; color: var(--muted); background: rgba(19,24,32,.05);
  border-radius: 999px; padding: 1px 8px; margin-left: 6px;
}
.fdate { font-family: var(--mono); font-size: 11.5px; color: var(--muted); margin-left: 8px; }
.fdate.missing { color: #b3541e; font-style: italic; }

/* ---- Access countdown on View Data ---- */
.access-timer {
  font-family: var(--mono); font-size: 12.5px;
  padding: 1px 9px; border-radius: 999px; border: 1px solid transparent;
  display: inline-block;
}
.access-perm { color: #2f7d46; background: rgba(63,157,90,.10); border-color: rgba(63,157,90,.28); }
.access-live { color: #1f5f8b; background: rgba(31,95,139,.10); border-color: rgba(31,95,139,.26); }
.access-soon { color: #8a6413; background: rgba(224,165,52,.14); border-color: rgba(224,165,52,.38); }
.access-denied { color: #a8322e; background: rgba(217,83,79,.10); border-color: rgba(217,83,79,.28); font-weight: 600; }

/* ---- Radio list (validity choices) ---- */
.radio-group { display: flex; flex-direction: column; gap: 2px; }
.radio-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  cursor: pointer; font-size: 14px; transition: background .12s ease, border-color .12s ease;
}
.radio-row:hover { background: rgba(19,24,32,.03); }
.radio-row input { width: auto; margin: 0; accent-color: var(--accent); }
.radio-row:has(input:checked) { border-color: var(--accent); background: rgba(31,122,112,.07); }

/* ---- Storage page ---- */
.usage-bar {
  height: 22px; border-radius: 999px; background: #e9edf2;
  overflow: hidden; border: 1px solid var(--line);
}
.usage-bar.sm { height: 8px; }
.usage-bar span { display: block; height: 100%; transition: width .3s ease; }
.bar-ok { background: linear-gradient(90deg, var(--accent), #2f9a8d); }
.bar-warn { background: linear-gradient(90deg, #d9a13a, #e0b45b); }
.bar-crit { background: linear-gradient(90deg, #c0392b, #d9534f); }
.usage-legend {
  display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 12px;
  font-size: 13.5px; color: var(--muted); align-items: center;
}
.usage-legend strong { color: var(--ink); font-family: var(--mono); }
.usage-pct { margin-left: auto; font-weight: 600; color: var(--accent); }
.usage-pct.warn { color: #8a6413; }
.usage-pct.crit { color: #a8322e; }

/* ---- Sidebar logo ----
   The artwork is dark-on-white, so it sits on a light panel to stay legible
   against the dark sidebar. */
.brand-logo {
  display: block;
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 0;
  box-shadow: 0 1px 0 rgba(255,255,255,.06), 0 2px 10px rgba(0,0,0,.18);
  transition: box-shadow .15s ease, transform .15s ease;
}
.brand-logo:hover { box-shadow: 0 1px 0 rgba(255,255,255,.10), 0 4px 16px rgba(0,0,0,.26); }
.brand-logo img { width: 100%; height: auto; display: block; }
.brand .tag { margin-top: 10px; }
@media (max-width: 860px) {
  .brand-logo { max-width: 260px; }
}
