/* DABIB Management Console — hand-rolled styles, no framework.
   Palette follows the flow diagrams: teal primary, deep blue accents. */

:root {
  --teal: #129d9d;
  --teal-dark: #0d7d7d;
  --blue: #1155aa;
  --navy: #0f2a43;
  --bg: #f2f6f8;
  --card: #ffffff;
  --ink: #1c2b36;
  --muted: #6b7d8a;
  --line: #e2eaee;
  --green: #2e8b57;
  --amber: #e8a33d;
  --red: #c9243f;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 42, 67, .07);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
h1, h2, h3 { margin: 0 0 .4em; color: var(--navy); }
a { color: var(--teal-dark); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ── Layout ─────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex: 0 0 240px;
  background: var(--navy); color: #cfe0ec;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.main { flex: 1; padding: 26px 30px; min-width: 0; }

.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 14px; }
.logo-dot {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  color: #fff; font-weight: 800; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.brand-name { font-weight: 700; color: #fff; letter-spacing: .5px; }
.brand-sub { font-size: 11.5px; color: #8fa9bd; }

.nav { flex: 1; padding: 10px 10px; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; margin: 2px 0; border-radius: 9px;
  color: #b7cbdb; transition: background .18s, color .18s, transform .12s;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-link.active { background: var(--teal); color: #fff; }
.nav-link.active .nav-ico { transform: scale(1.12); }
.nav-ico { width: 20px; text-align: center; transition: transform .18s; }

.sidebar-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.09); }
.me { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--teal); color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.me-name { font-size: 13.5px; color: #fff; }
.me-role { font-size: 11.5px; color: #8fa9bd; }
.foot-links { display: flex; justify-content: space-between; font-size: 13px; }
.foot-links a { color: #9fc0d5; }
.foot-links a:hover { color: #fff; }

/* ── Cards / page chrome ────────────────────────────── */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 14px; flex-wrap: wrap; }
.page-head p { margin: 2px 0 0; }
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px;
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: 1fr; } .grid-2 { grid-template-columns: 1fr; } }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .num { font-size: 28px; font-weight: 700; color: var(--navy); }
.stat .lbl { color: var(--muted); font-size: 13px; }
.stat .ico { font-size: 20px; width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; margin-bottom: 8px; }
.ico-teal { background: #e0f3f3; color: var(--teal-dark); }
.ico-blue { background: #e3ecf8; color: var(--blue); }
.ico-green { background: #e4f2ea; color: var(--green); }
.ico-amber { background: #fbf0dc; color: #b57a17; }

/* ── Tables ─────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .4px; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: #f6fafb; }
tr.clickable { cursor: pointer; }

/* ── Badges ─────────────────────────────────────────── */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-teal   { background: #e0f3f3; color: var(--teal-dark); }
.b-green  { background: #e4f2ea; color: var(--green); }
.b-amber  { background: #fbf0dc; color: #a06b10; }
.b-red    { background: #fae4e8; color: var(--red); }
.b-blue   { background: #e3ecf8; color: var(--blue); }
.b-gray   { background: #eceff2; color: #5c6b77; }

/* ── Forms / buttons ────────────────────────────────── */
label { display: block; font-size: 13px; font-weight: 600; color: var(--navy); margin: 12px 0 5px; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid #cfdbe2; border-radius: 8px;
  font: inherit; color: var(--ink); background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(18,157,157,.14); }
textarea { resize: vertical; min-height: 74px; }
.field-row { display: flex; gap: 14px; } .field-row > div { flex: 1; }

.btn {
  display: inline-block; border: 0; border-radius: 8px; cursor: pointer;
  font: 600 14px/1 inherit; padding: 10px 16px; color: #fff;
  transition: transform .12s, filter .15s, box-shadow .15s;
}
.btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--teal); }
.btn-blue { background: var(--blue); }
.btn-green { background: var(--green); }
.btn-amber { background: var(--amber); color: #3c2b05; }
.btn-danger { background: var(--red); }
.btn-ghost { background: transparent; color: var(--teal-dark); border: 1px solid var(--teal); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-block { width: 100%; margin-top: 16px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.alert { padding: 11px 14px; border-radius: 9px; margin-bottom: 14px; font-size: 14px; }
.alert-danger { background: #fae4e8; color: var(--red); }
.alert-success { background: #e4f2ea; color: var(--green); }

/* ── Toggle switch (document access) ────────────────── */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; vertical-align: middle; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider-t {
  position: absolute; inset: 0; border-radius: 999px; background: #c8d4dc;
  transition: background .2s; cursor: pointer;
}
.slider-t:before {
  content: ""; position: absolute; width: 18px; height: 18px; border-radius: 50%;
  left: 3px; top: 3px; background: #fff; transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .slider-t { background: var(--teal); }
.switch input:checked + .slider-t:before { transform: translateX(18px); }

/* ── Charts (pure CSS) ──────────────────────────────── */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 44px; gap: 10px; align-items: center; font-size: 13.5px; }
.bar-track { background: #edf2f5; border-radius: 999px; height: 12px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--teal); width: 0; transition: width .8s cubic-bezier(.2,.7,.3,1); }
.bar-fill.alt { background: var(--blue); }
.bar-val { text-align: right; color: var(--muted); font-size: 12.5px; }

.donut-wrap { display: flex; gap: 22px; align-items: center; }
.donut { width: 140px; height: 140px; border-radius: 50%; position: relative; flex: 0 0 140px; }
.donut::after { content: ""; position: absolute; inset: 22px; border-radius: 50%; background: var(--card); }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 1; }
.donut-center .num { font-size: 22px; font-weight: 700; color: var(--navy); }
.legend { display: flex; flex-direction: column; gap: 7px; font-size: 13.5px; }
.legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; }

/* ── Modal ──────────────────────────────────────────── */
.modal-back {
  position: fixed; inset: 0; background: rgba(15,42,67,.45); z-index: 40;
  display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px;
  animation: fadeIn .18s ease;
  overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 14px; width: 640px; max-width: 100%;
  padding: 22px 24px; box-shadow: 0 18px 60px rgba(0,0,0,.25);
  animation: popIn .22s cubic-bezier(.2,.9,.3,1.2);
}
.modal-wide { width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-x { background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-x:hover { color: var(--red); }

/* ── Tabs, misc ─────────────────────────────────────── */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; }
.tab { padding: 9px 16px; cursor: pointer; border-radius: 8px 8px 0 0; font-weight: 600; font-size: 14px; color: var(--muted); }
.tab:hover { color: var(--teal-dark); background: #f2f8f9; }
.tab.active { color: var(--teal-dark); box-shadow: inset 0 -2px 0 var(--teal); }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.toolbar input[type=text], .toolbar select { width: auto; }

.empty { text-align: center; color: var(--muted); padding: 34px 10px; }
.empty .big { font-size: 34px; }

.doc-chip { display: inline-flex; align-items: center; gap: 6px; background: #f2f6f8; border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; margin: 3px 4px 3px 0; font-size: 13px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 22px; position: relative; border-left: 2px solid var(--line); margin-left: 8px; font-size: 13.5px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--teal); }

/* ── Login ──────────────────────────────────────────── */
.login-body { background: radial-gradient(1200px 600px at 20% -10%, #143a5c, var(--navy)); min-height: 100vh; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: #fff; border-radius: 18px; padding: 34px 36px; width: 400px; max-width: 100%; box-shadow: 0 24px 80px rgba(0,0,0,.35); }
.login-brand { text-align: center; margin-bottom: 18px; }
.login-brand .logo-dot { margin: 0 auto 10px; width: 54px; height: 54px; font-size: 26px; }
.login-brand h1 { letter-spacing: 2px; }
.login-langs { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--muted); }
.login-langs a.active { font-weight: 700; }

/* ── Animations ─────────────────────────────────────── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes shakeX { 10%,90% { transform: translateX(-2px);} 20%,80% { transform: translateX(3px);} 30%,70% { transform: translateX(-5px);} 50% { transform: translateX(4px);} }
.fade-up { animation: fadeUp .35s ease both; }
.shake { animation: shakeX .5s ease; }
.page-enter { animation: fadeUp .3s ease both; }

.page-loading { display: flex; justify-content: center; padding: 80px 0; }
.spinner {
  width: 38px; height: 38px; border-radius: 50%;
  border: 4px solid #d5e4ea; border-top-color: var(--teal);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
#toast-zone { position: fixed; right: 20px; bottom: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0,0,0,.3); font-size: 14px; animation: popIn .25s ease both;
}
.toast.err { background: var(--red); }
