:root{
  --bg:#f4f6f8; --card:#fff; --ink:#16212b; --muted:#64748b; --line:#e2e8f0;
  --brand:#0f766e; --brand-d:#0b5a54; --brand-l:#ccfbf1; --danger:#b91c1c; --warn:#b45309; --ok:#15803d;
  --radius:10px; --shadow:0 1px 2px rgba(15,23,42,.06),0 4px 12px rgba(15,23,42,.05);
}
*{box-sizing:border-box}
html{font-size:15px}
body{margin:0;font-family:system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;background:var(--bg);color:var(--ink);line-height:1.45}
a{color:var(--brand);text-decoration:none}
a:hover{text-decoration:underline}
h1,h2,h3{margin:0 0 .5rem;line-height:1.2}
h2{font-size:1.25rem} h3{font-size:1.05rem}
.muted{color:var(--muted)} .small{font-size:.85rem} .right{text-align:right} .nowrap{white-space:nowrap}
.pos{color:var(--ok)} .neg{color:var(--danger)}

/* shell */
.shell{display:flex;min-height:100vh}
.sidebar{width:230px;background:#0b1f2a;color:#cbd5e1;display:flex;flex-direction:column;padding:1rem .75rem;position:sticky;top:0;height:100vh;flex-shrink:0}
.brand{display:flex;align-items:center;gap:.6rem;color:#fff;font-weight:700;font-size:1.05rem;padding:.25rem .5rem 1rem}
.brand:hover{text-decoration:none}
.logo{display:inline-grid;place-items:center;width:34px;height:34px;border-radius:9px;background:var(--brand);color:#fff;font-weight:800}
.sidebar nav{display:flex;flex-direction:column;gap:2px;flex:1}
.sidebar nav a{display:flex;align-items:center;gap:.65rem;padding:.6rem .7rem;border-radius:8px;color:#cbd5e1}
.sidebar nav a:hover{background:#13303f;text-decoration:none;color:#fff}
.sidebar nav a.active{background:var(--brand);color:#fff}
.ico{width:1.3rem;text-align:center}
.who{border-top:1px solid #1e3a4a;padding:.8rem .5rem 0;font-size:.85rem}
.who-name{color:#fff;font-weight:600;overflow:hidden;text-overflow:ellipsis}
.who-role{text-transform:capitalize;color:#94a3b8;margin-bottom:.5rem}
.main{flex:1;min-width:0}
.topbar{display:flex;align-items:center;gap:.75rem;padding:1rem 1.5rem .25rem}
.topbar h1{font-size:1.5rem;margin:0}
.menu-btn{display:none;background:none;border:1px solid var(--line);border-radius:8px;font-size:1.2rem;padding:.2rem .6rem;cursor:pointer;background:#fff}
.content{padding:.75rem 1.5rem 3rem;max-width:1280px}

/* cards, grid */
.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);box-shadow:var(--shadow);padding:1rem 1.1rem;margin-bottom:1rem}
.card > h2:first-child,.card > h3:first-child{margin-bottom:.8rem}
.grid{display:grid;gap:1rem}
.g2{grid-template-columns:repeat(2,minmax(0,1fr))} .g3{grid-template-columns:repeat(3,minmax(0,1fr))} .g4{grid-template-columns:repeat(4,minmax(0,1fr))}
.stat{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:.8rem 1rem;box-shadow:var(--shadow)}
.stat .l{font-size:.78rem;text-transform:uppercase;letter-spacing:.04em;color:var(--muted)}
.stat .v{font-size:1.45rem;font-weight:700;margin-top:.1rem}
.row{display:flex;gap:.6rem;align-items:center;flex-wrap:wrap}
.spread{justify-content:space-between}

/* tabs */
.tabs{display:flex;gap:.25rem;border-bottom:1px solid var(--line);margin:0 0 1rem;flex-wrap:wrap}
.tabs a{padding:.55rem .95rem;border-radius:8px 8px 0 0;color:var(--muted);font-weight:600;border:1px solid transparent;border-bottom:0;margin-bottom:-1px}
.tabs a.active{background:#fff;color:var(--brand);border-color:var(--line)}
.tabs a:hover{text-decoration:none;color:var(--ink)}

/* forms */
label{display:block;font-size:.82rem;font-weight:600;color:#334155;margin-bottom:.2rem}
input[type=text],input[type=email],input[type=password],input[type=number],input[type=date],input[type=file],input[type=search],input[type=color],select,textarea{
  width:100%;padding:.5rem .6rem;border:1px solid #cbd5e1;border-radius:8px;font:inherit;background:#fff;color:var(--ink)}
input[type=color]{padding:.15rem;height:2.3rem}
textarea{min-height:5rem;resize:vertical}
input:focus,select:focus,textarea:focus{outline:2px solid var(--brand-l);border-color:var(--brand)}
.field{margin-bottom:.75rem}
.form-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:.75rem}
.check{display:flex;align-items:center;gap:.5rem;font-weight:500;font-size:.92rem}
.check input{width:auto}
.hint{font-size:.8rem;color:var(--muted);margin-top:.2rem}

/* buttons */
.btn{display:inline-flex;align-items:center;gap:.4rem;padding:.5rem .95rem;border-radius:8px;border:1px solid var(--brand);background:var(--brand);color:#fff;font:inherit;font-weight:600;cursor:pointer}
.btn:hover{background:var(--brand-d);text-decoration:none}
.btn-ghost{background:#fff;color:var(--brand)} .btn-ghost:hover{background:var(--brand-l)}
.sidebar .btn-ghost{background:transparent;color:#cbd5e1;border-color:#2b4a5b}
.btn-danger{background:#fff;color:var(--danger);border-color:#fca5a5} .btn-danger:hover{background:#fee2e2}
.btn-sm{padding:.28rem .6rem;font-size:.82rem}
form.inline{display:inline}

/* tables */
.table-wrap{overflow-x:auto;border:1px solid var(--line);border-radius:var(--radius);background:#fff}
table.t{width:100%;border-collapse:collapse;font-size:.92rem}
.t th{background:#f1f5f9;text-align:left;font-size:.76rem;text-transform:uppercase;letter-spacing:.04em;color:#475569;padding:.55rem .7rem;border-bottom:1px solid var(--line);white-space:nowrap}
.t td{padding:.55rem .7rem;border-bottom:1px solid #eef2f6;vertical-align:top}
.t tr:last-child td{border-bottom:0}
.t tbody tr:hover{background:#fafcfd}
.t tfoot td{font-weight:700;background:#f8fafc}
.t .num{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
.badge{display:inline-block;padding:.12rem .55rem;border-radius:99px;font-size:.74rem;font-weight:700}
.b-ok{background:#dcfce7;color:#166534} .b-warn{background:#fef3c7;color:#92400e} .b-mute{background:#e2e8f0;color:#475569} .b-err{background:#fee2e2;color:#991b1b}

.alert{padding:.65rem .9rem;border-radius:8px;margin-bottom:.9rem;border:1px solid}
.alert-ok{background:#f0fdf4;border-color:#bbf7d0;color:#166534}
.alert-err{background:#fef2f2;border-color:#fecaca;color:#991b1b}
.alert-info{background:#eff6ff;border-color:#bfdbfe;color:#1e40af}

details.coll{background:#fff;border:1px solid var(--line);border-radius:var(--radius);margin-bottom:1rem}
details.coll > summary{cursor:pointer;padding:.8rem 1rem;font-weight:700;list-style:none}
details.coll > summary::before{content:"▸ ";color:var(--brand)}
details.coll[open] > summary::before{content:"▾ "}
details.coll > .inner{padding:0 1rem 1rem}
details.menu{position:relative;display:inline-block}
details.menu > summary{list-style:none;cursor:pointer;padding:.15rem .6rem;border:1px solid var(--line);border-radius:8px;background:#fff;font-weight:700}
details.menu .pop{position:absolute;right:0;top:110%;z-index:20;min-width:170px;background:#fff;border:1px solid var(--line);border-radius:8px;box-shadow:0 8px 24px rgba(15,23,42,.15);padding:.3rem}
details.menu .pop a,details.menu .pop button{display:block;width:100%;text-align:left;padding:.4rem .6rem;border:0;background:none;font:inherit;color:var(--ink);border-radius:6px;cursor:pointer}
details.menu .pop a:hover,details.menu .pop button:hover{background:#f1f5f9;text-decoration:none}
details.menu .pop .danger{color:var(--danger)}

.pager{display:flex;gap:.3rem;margin-top:.8rem;flex-wrap:wrap}
.pager a,.pager span{padding:.3rem .65rem;border:1px solid var(--line);border-radius:7px;background:#fff;font-size:.85rem}
.pager a.cur{background:var(--brand);color:#fff;border-color:var(--brand)} .pager .dis{color:#94a3b8}

.notes-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(230px,1fr));gap:.8rem}
.note{border-radius:10px;padding:.8rem;border:1px solid rgba(0,0,0,.06);white-space:pre-wrap}
.note small{display:block;color:rgba(0,0,0,.5);margin-bottom:.35rem}
.c-yellow{background:#fef9c3}.c-green{background:#dcfce7}.c-blue{background:#dbeafe}.c-pink{background:#fce7f3}.c-orange{background:#ffedd5}.c-gray{background:#e2e8f0}

/* auth */
.auth-body{display:grid;place-items:center;min-height:100vh;padding:1rem;background:linear-gradient(135deg,#0b1f2a,#0f766e)}
.auth-card{background:#fff;border-radius:14px;padding:1.6rem;width:100%;max-width:410px;box-shadow:0 20px 50px rgba(0,0,0,.3)}
.auth-brand{display:flex;align-items:center;gap:.6rem;font-weight:800;font-size:1.15rem;margin-bottom:1rem}
.auth-card .btn{width:100%;justify-content:center}
.auth-links{display:flex;justify-content:space-between;margin-top:1rem;font-size:.9rem}

/* report designer preview */
.preview-box{background:#e2e8f0;padding:1rem;border-radius:var(--radius);overflow:auto}
.preview-box .rpt{box-shadow:var(--shadow)}

@media (max-width:900px){
  .shell{display:block}
  .sidebar{position:fixed;inset:0 auto 0 0;z-index:50;transform:translateX(-100%);transition:transform .2s;width:250px}
  .sidebar.open{transform:none}
  .menu-btn{display:inline-block}
  .g2,.g3,.g4{grid-template-columns:1fr}
  .content{padding:.5rem .9rem 3rem} .topbar{padding:.8rem .9rem .25rem}
  .g4{grid-template-columns:repeat(2,1fr)}
}
@media print{
  .sidebar,.topbar,.no-print,.tabs,.alert{display:none!important}
  .shell{display:block} .content{padding:0;max-width:none}
  body{background:#fff}
}
