/* ============================================================
   SOM Labs Management System — POC v2 (UI Mockup)
   Design system + layout. Dummy/demo only.
   ============================================================ */

:root {
  --bg:            #eef2f7;
  --surface:       #ffffff;
  --surface-2:     #f7f9fc;
  --sidebar:       #0f172a;
  --sidebar-2:     #1e293b;
  --sidebar-text:  #cbd5e1;
  --border:        #e2e8f0;

  --primary:       #4f46e5;
  --primary-600:   #4338ca;
  --primary-soft:  #eef2ff;
  --accent:        #0ea5e9;
  --teal:          #14b8a6;

  --success:       #16a34a;
  --success-soft:  #dcfce7;
  --warning:       #d97706;
  --warning-soft:  #fef3c7;
  --danger:        #dc2626;
  --danger-soft:   #fee2e2;
  --info:          #0284c7;
  --info-soft:     #e0f2fe;

  --text:          #0f172a;
  --text-muted:    #64748b;
  --text-faint:    #94a3b8;

  --radius:        14px;
  --radius-sm:     9px;
  --shadow:        0 1px 3px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
  --shadow-lg:     0 12px 40px rgba(15,23,42,.14);
  --sidebar-w:     258px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { text-decoration: none; color: inherit; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  color: var(--sidebar-text);
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column;
  z-index: 30;
}
.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 22px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.brand .logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid; place-items: center; color: #fff; font-size: 19px;
  box-shadow: 0 6px 16px rgba(79,70,229,.45);
}
.brand .title { font-weight: 700; color: #fff; font-size: 15px; letter-spacing: .2px; }
.brand .subtitle { font-size: 11px; color: var(--text-faint); }

.nav-group { padding: 14px 12px 4px; }
.nav-group .label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em;
  color: #64748b; padding: 6px 12px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 13px; margin: 2px 4px; border-radius: 9px;
  color: var(--sidebar-text); cursor: pointer; font-size: 13.5px; font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item i { font-size: 17px; width: 20px; text-align: center; color: #94a3b8; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, var(--primary), var(--primary-600)); color: #fff; }
.nav-item.active i { color: #fff; }
.nav-item .badge-mini {
  margin-left: auto; background: rgba(255,255,255,.16); color: #fff;
  font-size: 11px; padding: 1px 8px; border-radius: 20px;
}
.sidebar-foot {
  margin-top: auto; padding: 16px; border-top: 1px solid rgba(255,255,255,.07);
  font-size: 11.5px; color: var(--text-faint);
}

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

/* ---------- Topbar ---------- */
.topbar {
  height: 64px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 18px;
  padding: 0 26px; position: sticky; top: 0; z-index: 20;
}
.topbar .search {
  flex: 1; max-width: 420px; position: relative;
}
.topbar .search i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }
.topbar .search input {
  width: 100%; border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 10px; padding: 9px 12px 9px 38px; font-size: 13px; outline: none;
}
.topbar .search input:focus { border-color: var(--primary); background: #fff; }
.topbar .spacer { flex: 1; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); display: grid; place-items: center; cursor: pointer;
  color: var(--text-muted); position: relative;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; border: 2px solid #fff; }
.lang-switch { display: flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.lang-switch button { border: 0; background: var(--surface); padding: 8px 12px; font-size: 12px; cursor: pointer; color: var(--text-muted); font-weight: 600; }
.lang-switch button.active { background: var(--primary); color: #fff; }
.user-chip { display: flex; align-items: center; gap: 10px; padding-left: 8px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: linear-gradient(135deg,#6366f1,#0ea5e9); color:#fff; display:grid; place-items:center; font-weight:700; font-size:14px; }
.user-chip .meta .n { font-weight: 600; font-size: 13px; }
.user-chip .meta .r { font-size: 11.5px; color: var(--text-muted); }

/* ---------- Content ---------- */
.content { padding: 26px; flex: 1; }
.page { display: none; animation: fade .25s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 22px; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; margin: 0 0 4px; font-weight: 700; }
.page-head .crumb { font-size: 12.5px; color: var(--text-muted); }
.page-head .crumb i { font-size: 10px; margin: 0 6px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 16px; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }
.btn i { font-size: 15px; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 1200px){ .grid-4{grid-template-columns:repeat(2,1fr)} }
@media (max-width: 900px){ .grid-4,.grid-3,.grid-2{grid-template-columns:1fr} }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.card-head .sub { font-size: 12px; color: var(--text-muted); }
.card-body { padding: 20px; }

/* Stat cards */
.stat { padding: 20px; display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden; }
.stat .ico { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; }
.stat .num { font-size: 28px; font-weight: 800; letter-spacing: -.5px; }
.stat .lbl { font-size: 12.5px; color: var(--text-muted); font-weight: 500; }
.stat .trend { font-size: 11.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.trend.up { color: var(--success); } .trend.down { color: var(--danger); }
.ico.i-indigo { background: var(--primary-soft); color: var(--primary); }
.ico.i-teal { background: #ccfbf1; color: var(--teal); }
.ico.i-sky { background: var(--info-soft); color: var(--info); }
.ico.i-amber { background: var(--warning-soft); color: var(--warning); }
.ico.i-green { background: var(--success-soft); color: var(--success); }
.ico.i-rose { background: var(--danger-soft); color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; padding: 12px 16px; background: var(--surface-2);
  color: var(--text-muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.tbl td { padding: 13px 16px; border-bottom: 1px solid var(--border); }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--surface-2); }
.mono { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 12.5px; }
.cell-strong { font-weight: 600; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; }
.badge::before { content:''; width:6px; height:6px; border-radius:50%; background: currentColor; opacity:.9; }
.b-success { background: var(--success-soft); color: var(--success); }
.b-warning { background: var(--warning-soft); color: var(--warning); }
.b-danger  { background: var(--danger-soft); color: var(--danger); }
.b-info    { background: var(--info-soft); color: var(--info); }
.b-muted   { background: #f1f5f9; color: var(--text-muted); }
.badge.plain::before { display:none; }

/* ---------- Forms ---------- */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 11.5px; color: var(--text-faint); }
.field input, .field select, .field textarea {
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 13.5px;
  outline: none; background: var(--surface); font-family: inherit; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }

/* ---------- Upload ---------- */
.dropzone {
  border: 2px dashed #c7d2fe; border-radius: var(--radius); background: var(--primary-soft);
  padding: 40px 24px; text-align: center; cursor: pointer; transition: all .2s;
}
.dropzone:hover { background: #e0e7ff; border-color: var(--primary); }
.dropzone .big { font-size: 42px; color: var(--primary); margin-bottom: 10px; }
.dropzone h4 { margin: 0 0 4px; font-size: 16px; }
.dropzone p { margin: 0; color: var(--text-muted); font-size: 13px; }
.file-list { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.file-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.file-row .fi { width: 36px; height: 36px; border-radius: 9px; background: var(--info-soft); color: var(--info); display: grid; place-items: center; font-size: 17px; }
.file-row .fmeta { flex: 1; }
.file-row .fmeta .fn { font-weight: 600; font-size: 13px; }
.file-row .fmeta .fs { font-size: 11.5px; color: var(--text-muted); }
.progress { height: 6px; background: #e2e8f0; border-radius: 6px; overflow: hidden; margin-top: 6px; }
.progress > span { display: block; height: 100%; width: 0; background: linear-gradient(90deg,var(--primary),var(--accent)); transition: width .4s; }

/* ---------- DocType mapping ---------- */
.doctype-card { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.doctype-card .dt-head { padding: 12px 16px; background: var(--sidebar); color: #fff; display:flex; align-items:center; gap:10px; font-weight:600; font-size:13.5px; }
.doctype-card .dt-head .pill { margin-left:auto; font-size:11px; background:rgba(255,255,255,.16); padding:2px 9px; border-radius:20px; }
.kv { display:flex; justify-content:space-between; gap:12px; padding:9px 16px; border-bottom:1px solid var(--border); font-size:13px; }
.kv:last-child{border-bottom:0;}
.kv .k { color: var(--text-muted); }
.kv .v { font-weight:600; text-align:right; }
.flow { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:20px; }
.flow .node { background:var(--surface); border:1px solid var(--border); border-radius:10px; padding:10px 16px; font-weight:600; font-size:13px; display:flex; align-items:center; gap:8px; box-shadow:var(--shadow); }
.flow .node i { color: var(--primary); }
.flow .arrow { color: var(--text-faint); font-size: 16px; }

/* ---------- AI result ---------- */
.ai-result { border-left: 4px solid var(--primary); background: var(--surface-2); border-radius: 10px; padding: 16px; }
.ai-result h4 { margin: 0 0 10px; font-size: 14px; display:flex; align-items:center; gap:8px; }
.conf-bar { height: 8px; background:#e2e8f0; border-radius:8px; overflow:hidden; }
.conf-bar > span { display:block; height:100%; background: linear-gradient(90deg,var(--teal),var(--success)); }

/* ---------- Misc ---------- */
.muted { color: var(--text-muted); }
.section-gap { height: 18px; }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 220px; }
.list-tight > div { padding: 11px 0; border-bottom: 1px solid var(--border); display:flex; align-items:center; gap:12px; }
.list-tight > div:last-child { border-bottom: 0; }
.dotline { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: #f1f5f9; color: var(--text-muted); font-weight: 600; }
.toggle { position: relative; width: 42px; height: 24px; }
.toggle input { display:none; }
.toggle .slider { position:absolute; inset:0; background:#cbd5e1; border-radius:20px; cursor:pointer; transition:.2s; }
.toggle .slider::before { content:''; position:absolute; width:18px; height:18px; left:3px; top:3px; background:#fff; border-radius:50%; transition:.2s; }
.toggle input:checked + .slider { background: var(--primary); }
.toggle input:checked + .slider::before { transform: translateX(18px); }
.integration-row { display:flex; align-items:center; gap:14px; padding:14px 0; border-bottom:1px solid var(--border); }
.integration-row:last-child{border-bottom:0;}
.integration-row .ii { width:42px; height:42px; border-radius:11px; display:grid; place-items:center; font-size:19px; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--sidebar); color:#fff;
  padding: 14px 18px; border-radius: 12px; box-shadow: var(--shadow-lg);
  display:flex; align-items:center; gap:12px; font-size:13.5px; z-index: 100;
  transform: translateY(120%); transition: transform .35s cubic-bezier(.2,.9,.3,1.2);
}
.toast.show { transform: none; }
.toast i { color: var(--success); font-size: 18px; }

/* Demo banner */
.demo-banner {
  background: linear-gradient(90deg, #fef3c7, #fde68a); color: #92400e;
  font-size: 12.5px; font-weight: 600; text-align: center; padding: 7px;
  border-bottom: 1px solid #fcd34d;
}
.demo-banner i { margin-right: 6px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0f172a, #1e293b); }
.login-card { width: 380px; background: #fff; border-radius: 18px; box-shadow: var(--shadow-lg); padding: 34px 32px; }
.login-card .brand { border: 0; padding: 0 0 22px; justify-content: center; }
.login-card h2 { margin: 0 0 4px; font-size: 19px; text-align: center; }
.login-card .sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 22px; }
.login-card .field input { font-size: 14px; }
.login-card .btn-primary { width: 100%; justify-content: center; margin-top: 6px; padding: 11px; }
.login-err { background: var(--danger-soft); color: var(--danger); padding: 10px 12px; border-radius: 9px; font-size: 13px; margin-bottom: 16px; text-align: center; }
.login-hint { text-align: center; font-size: 12px; color: var(--text-faint); margin-top: 16px; }
