@import url("tokens.css");

/* ════════════════════════════════════════════════════════════════════════
   MicSer v1.0.0 — application styles
   Dark institutional scientific interface · Seismocode design tokens
   ════════════════════════════════════════════════════════════════════════ */
* { box-sizing: border-box; }
html, body, #root { margin: 0; padding: 0; min-height: 100vh; }
body {
  background: var(--earth-1);
  color: var(--fg-2);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button { font-family: inherit; cursor: pointer; }
::selection { background: rgba(0,212,245,0.25); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--earth-4); border-radius: 6px; border: 2px solid var(--earth-1); }
::-webkit-scrollbar-thumb:hover { background: var(--earth-5); }
a { color: inherit; text-decoration: none; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.eyebrow {
  font-family: var(--font-display); font-size: 10px; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--fg-4);
}

/* ── App shell ─────────────────────────────────────────────────────────── */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.main-col { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }
.content { flex: 1; padding: 26px 32px 40px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.content-narrow { max-width: 1180px; width: 100%; margin: 0 auto; }

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--earth-2); border-right: 1px solid var(--border-faint);
  padding: 18px 14px 14px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { padding: 2px 6px 16px; border-bottom: 1px solid var(--border-faint); margin-bottom: 12px; }
.brand-lockup { display: flex; align-items: center; gap: 9px; }
.brand-mark { width: 26px; height: 26px; border-radius: 6px; flex-shrink: 0; }
.brand-word { font-family: var(--font-display); font-weight: 700; font-size: 17px; color: #fff; letter-spacing: -0.02em; line-height: 1; }
.brand-word .v { font-weight: 300; color: var(--fg-4); font-size: 11px; margin-left: 4px; letter-spacing: 0; }
.brand-sub { margin-top: 9px; font-family: var(--font-display); font-size: 9px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--brand-green-3); }

.org {
  background: var(--earth-3); border: 1px solid var(--border-faint); border-radius: 5px;
  padding: 9px 11px; margin-bottom: 14px; cursor: pointer; transition: background var(--dur-base) var(--ease-out);
  overflow: hidden; min-width: 0;
}
.org:hover { background: var(--earth-4); }
.org-row { display: flex; align-items: center; justify-content: space-between; color: #fff; min-width: 0; }
.org-name { font-family: var(--font-display); font-weight: 500; font-size: 13px; display: flex; align-items: center; gap: 7px; min-width: 0; width: 100%; }
.org-meta { font-family: var(--font-mono); font-size: 10px; color: var(--fg-4); margin-top: 5px; }

.nav-section { font-family: var(--font-display); font-size: 9.5px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--fg-5); padding: 15px 8px 6px; }
.nav {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 5px;
  font-family: var(--font-display); font-weight: 400; font-size: 13px; color: var(--fg-2);
  user-select: none; transition: background var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out); border: 0; background: none; width: 100%; text-align: left;
}
.nav:hover { background: var(--earth-3); color: #fff; }
.nav.active { background: rgba(0,212,245,0.08); color: #fff; position: relative; }
.nav.active::before { content: ""; position: absolute; left: -14px; top: 50%; width: 2px; height: 17px; background: var(--data-cyan); border-radius: 0 2px 2px 0; transform: translateY(-50%); }
.nav-icon { display: inline-flex; opacity: 0.85; }
.nav-lbl { flex: 1; }
.nav-count { font-family: var(--font-mono); font-size: 10px; color: var(--fg-4); background: var(--earth-3); padding: 2px 7px; border-radius: 10px; }
.nav.active .nav-count { background: rgba(0,212,245,0.18); color: var(--data-cyan); }
.nav:disabled { opacity: 0.4; cursor: not-allowed; }
.nav-lock { margin-left: auto; opacity: 0.5; }

.user-card { display: flex; align-items: center; gap: 10px; padding: 11px 8px 4px; margin-top: 10px; border-top: 1px solid var(--border-faint); }
.avatar { width: 32px; height: 32px; border-radius: 999px; background: var(--brand-green); color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 600; font-size: 12px; flex-shrink: 0; }
.user-name { font-family: var(--font-display); font-size: 12.5px; font-weight: 500; color: #fff; }
.user-role { font-family: var(--font-mono); font-size: 10px; color: var(--fg-4); }

/* ── Topbar ────────────────────────────────────────────────────────────── */
.topbar {
  height: 56px; display: flex; align-items: center; gap: 16px; padding: 0 32px;
  border-bottom: 1px solid var(--border-faint); background: var(--earth-1); position: sticky; top: 0; z-index: 40;
}
.crumb { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-size: 14px; flex: 1; min-width: 0; }
.crumb-link { color: var(--fg-3); cursor: pointer; white-space: nowrap; font-weight: 400; transition: color 0.15s; }
.crumb-link:hover { color: #fff; }
.crumb-current { color: #fff; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb .sep { color: var(--fg-5); display: inline-flex; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn { background: var(--earth-2); border: 1px solid var(--border-faint); color: var(--fg-2); width: 34px; height: 34px; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; position: relative; transition: background var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out); }
.icon-btn:hover { background: var(--earth-3); color: #fff; }

/* ── Buttons ───────────────────────────────────────────────────────────── */
.btn { font-family: var(--font-display); font-weight: 500; font-size: 12.5px; letter-spacing: 0.01em; line-height: 1; padding: 10px 15px; border-radius: 5px; border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background var(--dur-base) var(--ease-out), transform 80ms ease, opacity var(--dur-base); white-space: nowrap; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--brand-green); color: #fff; border-color: var(--brand-green-2); }
.btn-primary:hover:not(:disabled) { background: var(--brand-green-2); }
.btn-secondary { background: var(--earth-3); color: #fff; border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--earth-4); }
.btn-ghost { background: transparent; color: var(--fg-2); }
.btn-ghost:hover:not(:disabled) { background: var(--earth-3); color: #fff; }
.btn-cyan { background: rgba(0,212,245,0.12); color: var(--data-cyan); border-color: rgba(0,212,245,0.4); }
.btn-cyan:hover:not(:disabled) { background: rgba(0,212,245,0.2); }
.btn-danger { background: rgba(225,29,72,0.12); color: #FB7185; border-color: rgba(225,29,72,0.4); }
.btn-danger:hover:not(:disabled) { background: rgba(225,29,72,0.2); }
.btn-lg { padding: 13px 22px; font-size: 13.5px; }
.btn-sm { padding: 6px 11px; font-size: 11.5px; }
.btn-block { width: 100%; }

/* ── Pills / badges ────────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-family: var(--font-display); font-weight: 600; font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap; }
.pill .dot { width: 6px; height: 6px; border-radius: 999px; }
.pill-pass  { background: rgba(34,197,94,0.12);  color: #22C55E; border: 1px solid rgba(34,197,94,0.4); }
.pill-pass  .dot { background: #22C55E; }
.pill-fail  { background: rgba(225,29,72,0.13);  color: #FB7185; border: 1px solid rgba(225,29,72,0.4); }
.pill-fail  .dot { background: #E11D48; }
.pill-info  { background: rgba(0,212,245,0.12);  color: #00D4F5; border: 1px solid rgba(0,212,245,0.4); }
.pill-info  .dot { background: #00D4F5; }
.pill-warn  { background: rgba(240,168,48,0.12); color: #F0A830; border: 1px solid rgba(240,168,48,0.4); }
.pill-warn  .dot { background: #F0A830; }
.pill-muted { background: var(--earth-3); color: var(--fg-3); border: 1px solid var(--border-faint); }
.pill-muted .dot { background: var(--fg-4); }
.pill-final { background: rgba(34,197,94,0.14); color: #5FE08A; border: 1px solid rgba(34,197,94,0.45); }
.pill-final .dot { background: #22C55E; }
.pill-cand  { background: rgba(0,212,245,0.1); color: #4FE0FF; border: 1px solid rgba(0,212,245,0.35); }
.pill-cand  .dot { background: #00D4F5; }
.pill-arch  { background: var(--earth-4); color: var(--fg-4); border: 1px solid var(--border-faint); }
.pill-arch  .dot { background: var(--fg-5); }

.tag { display: inline-flex; align-items: center; gap: 6px; font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-3); background: var(--earth-3); border: 1px solid var(--border-faint); border-radius: 3px; padding: 3px 8px; }

/* grade badge */
.grade { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 6px; font-family: var(--font-display); font-weight: 700; font-size: 16px; color: #060E1C; }
.grade-lg { width: 56px; height: 56px; font-size: 30px; border-radius: 10px; }
.grade-sm { width: 22px; height: 22px; font-size: 12px; border-radius: 4px; }

/* ── Panel / card ──────────────────────────────────────────────────────── */
.panel { background: var(--earth-2); border: 1px solid var(--border-faint); border-radius: 8px; padding: 18px 20px; display: flex; flex-direction: column; min-width: 0; }
.panel.flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.panel-head.tight { margin-bottom: 12px; }
.panel-title { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 15px; color: #fff; letter-spacing: -0.005em; }
.panel-sub { font-family: var(--font-body); font-size: 12px; color: var(--fg-3); margin-top: 4px; }
.panel-actions { display: flex; align-items: center; gap: 8px; }

.card { background: var(--earth-3); border: 1px solid var(--border-faint); border-radius: 8px; }

/* page header */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.page-title { margin: 6px 0 0; font-family: var(--font-display); font-weight: 300; font-size: 28px; color: #fff; letter-spacing: -0.015em; }
.page-desc { font-family: var(--font-body); font-size: 13.5px; color: var(--fg-3); margin-top: 8px; max-width: 640px; line-height: 1.5; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 7px; }
.field-lbl { font-family: var(--font-display); font-size: 12px; font-weight: 500; color: var(--fg-2); }
.field-lbl .opt { color: var(--fg-5); font-weight: 400; margin-left: 5px; }
.field-hint { font-family: var(--font-body); font-size: 11.5px; color: var(--fg-4); line-height: 1.45; }
.input, .select, textarea.input {
  background: var(--earth-1); border: 1px solid var(--border); border-radius: 5px; padding: 10px 12px;
  color: #fff; font-family: var(--font-body); font-size: 13px; width: 100%; outline: none;
  transition: border-color var(--dur-base), box-shadow var(--dur-base);
}
.input::placeholder { color: var(--fg-5); }
.input:focus, .select:focus, textarea.input:focus { border-color: rgba(0,212,245,0.5); box-shadow: 0 0 0 2px rgba(0,212,245,0.16); }
.input.mono { font-family: var(--font-mono); }
textarea.input { resize: vertical; min-height: 80px; line-height: 1.5; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' fill='none' stroke='%237B8FA1' stroke-width='1.5' viewBox='0 0 24 24'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 34px; cursor: pointer; }

/* dropzone */
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: 8px; background: var(--earth-1); padding: 28px 22px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; transition: border-color var(--dur-base), background var(--dur-base); cursor: pointer; }
.dropzone:hover { border-color: rgba(0,212,245,0.5); background: rgba(0,212,245,0.03); }
.dropzone.dz-over { border-color: rgba(0,212,245,0.8); background: rgba(0,212,245,0.08); border-style: solid; transform: scale(1.01); }
.dropzone.filled { border-style: solid; border-color: rgba(34,197,94,0.4); background: rgba(34,197,94,0.04); align-items: stretch; cursor: default; }
.dz-icon { color: var(--fg-4); }
.dz-title { font-family: var(--font-display); font-size: 13px; font-weight: 500; color: #fff; }
.dz-sub { font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-4); }
.dz-file { display: flex; align-items: center; gap: 11px; }
.dz-file-name { font-family: var(--font-mono); font-size: 12px; color: #fff; }
.dz-file-meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-4); }

/* checkbox */
.checkbox { display: inline-flex; align-items: center; gap: 9px; font-family: var(--font-body); font-size: 12.5px; color: var(--fg-2); cursor: pointer; user-select: none; }
.checkbox .box { width: 17px; height: 17px; border-radius: 4px; border: 1px solid var(--border-strong); background: var(--earth-1); display: inline-flex; align-items: center; justify-content: center; color: #060E1C; flex-shrink: 0; transition: background var(--dur-base), border-color var(--dur-base); }
.checkbox.on .box { background: var(--brand-green-3); border-color: var(--brand-green-3); }

/* ── Tables ────────────────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-family: var(--font-display); font-size: 12.5px; }
.tbl thead th { font-family: var(--font-display); font-size: 9.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-4); text-align: left; padding: 11px 16px; border-top: 1px solid var(--border-faint); border-bottom: 1px solid var(--border-faint); background: var(--earth-2); white-space: nowrap; }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl th.ctr, .tbl td.ctr { text-align: center; }
.tbl tbody tr { border-bottom: 1px solid var(--border-faint); transition: background 120ms ease; }
.tbl tbody tr.clickable { cursor: pointer; }
.tbl tbody tr.clickable:hover { background: var(--earth-3); }
.tbl tbody tr.sel { background: rgba(0,212,245,0.07); }
.tbl td { padding: 13px 16px; color: var(--fg-2); vertical-align: middle; }
.tbl .t-id { font-family: var(--font-mono); color: #fff; font-weight: 500; }
.tbl .t-num { font-family: var(--font-mono); color: #fff; font-variant-numeric: tabular-nums; }
.tbl .t-muted { color: var(--fg-4); }
.chev-cell { color: var(--fg-5); text-align: right; width: 28px; }

/* ── Modal ─────────────────────────────────────────────────────────────── */
.overlay { position: fixed; inset: 0; background: rgba(3,8,18,0.72); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 24px; animation: fadeIn 160ms var(--ease-out); }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
.modal { background: var(--earth-2); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--elev-3); width: 100%; max-width: 460px; animation: modalIn 200ms var(--ease-out); overflow: hidden; }
.modal.wide { max-width: 720px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(0.99) } to { opacity: 1; transform: none } }
.modal-head { padding: 22px 24px 0; }
.modal-eye { display: flex; align-items: center; gap: 9px; }
.modal-title { margin: 14px 0 6px; font-family: var(--font-display); font-weight: 500; font-size: 19px; color: #fff; letter-spacing: -0.01em; }
.modal-desc { font-family: var(--font-body); font-size: 13px; color: var(--fg-3); line-height: 1.5; }
.modal-body { padding: 18px 24px; }
.modal-foot { padding: 16px 24px; border-top: 1px solid var(--border-faint); display: flex; gap: 10px; justify-content: space-between; align-items: center; }
.modal-foot .grow { flex: 1; }

/* ── Empty / loading / error states ────────────────────────────────────── */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 56px 24px; gap: 14px; }
.empty-icon { width: 52px; height: 52px; border-radius: 12px; background: var(--earth-3); border: 1px solid var(--border-faint); display: flex; align-items: center; justify-content: center; color: var(--fg-4); }
.empty-title { font-family: var(--font-display); font-weight: 500; font-size: 16px; color: #fff; }
.empty-desc { font-family: var(--font-body); font-size: 13px; color: var(--fg-3); max-width: 380px; line-height: 1.55; }

.spinner { width: 20px; height: 20px; border: 2px solid var(--earth-5); border-top-color: var(--data-cyan); border-radius: 999px; animation: spin 720ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }
.skeleton { background: linear-gradient(90deg, var(--earth-3) 25%, var(--earth-4) 50%, var(--earth-3) 75%); background-size: 200% 100%; animation: shimmer 1.3s ease-in-out infinite; border-radius: 4px; }
@keyframes shimmer { to { background-position: -200% 0 } }

.banner { display: flex; gap: 11px; align-items: flex-start; padding: 13px 16px; border-radius: 7px; font-family: var(--font-body); font-size: 12.5px; line-height: 1.5; }
.banner-warn { background: rgba(240,168,48,0.08); border: 1px solid rgba(240,168,48,0.3); color: #F4C46B; }
.banner-info { background: rgba(0,212,245,0.07); border: 1px solid rgba(0,212,245,0.28); color: #8FE6FA; }
.banner-err  { background: rgba(225,29,72,0.08); border: 1px solid rgba(225,29,72,0.3); color: #FB9BAB; }
.banner-lock { background: var(--earth-3); border: 1px solid var(--border); color: var(--fg-3); }
.banner b { color: #fff; font-family: var(--font-display); font-weight: 500; }

/* toast */
.toast-wrap { position: fixed; bottom: 24px; right: 24px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast { display: flex; align-items: center; gap: 11px; background: var(--earth-3); border: 1px solid var(--border); border-radius: 8px; padding: 13px 16px; box-shadow: var(--elev-3); font-family: var(--font-body); font-size: 13px; color: #fff; min-width: 280px; animation: toastIn 240ms var(--ease-out); }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px) } to { opacity: 1; transform: none } }
.toast .tk { width: 22px; height: 22px; border-radius: 999px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* project card action menu */
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 14px; background: none; border: none; color: var(--fg-2); font-family: var(--font-display); font-size: 12.5px; cursor: pointer; text-align: left; transition: background 100ms; }
.menu-item:hover { background: var(--earth-4); color: #fff; }
