/* SBL Assist — responsive shell for desktop and phone. */
:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --ink: #14263a;
  --muted: #5b7186;
  --line: #dde5ee;
  --brand: #1671b9;
  --brand-dark: #0e2c46;
  --brand-soft: #e3f1fb;
  --ok: #08755d;
  --ok-soft: #e1f4ee;
  --warn: #9a6b0f;
  --warn-soft: #fbf1d8;
  --danger: #b42318;
  --danger-soft: #fde8e6;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(20, 38, 58, 0.07);
  --sidebar-width: 268px;
  --bottom-nav-height: 62px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; }
h1.page-title { font-size: 26px; margin-bottom: 4px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; color: var(--brand-dark); }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
ul, ol { padding-left: 20px; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
input[type="search"], input[type="text"], input[type="password"], input[type="number"], input[type="file"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
textarea { min-height: 120px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--brand-dark);
  color: #e3eef8;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 18px 12px; }
.brand img { border-radius: 10px; background: #fff; padding: 3px; }
.brand-name { font-weight: 700; font-size: 17px; color: #fff; }
.brand-sub { font-size: 12px; color: #9fbdd8; }
.sidebar-close { display: none; margin-left: auto; color: #fff; }
.nav { padding: 6px 10px 12px; flex: 1; }
.nav-group { margin-bottom: 10px; }
.nav-title { font-size: 11px; letter-spacing: 1.1px; text-transform: uppercase; color: #8fb0cc; padding: 10px 10px 4px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 10px; color: #e3eef8; font-size: 14px;
}
.nav-link:hover { background: rgba(255, 255, 255, 0.08); text-decoration: none; }
.nav-link.is-active { background: var(--brand); color: #fff; }
.nav-icon { width: 22px; text-align: center; font-size: 16px; }
.sidebar-footer { padding: 12px 14px 18px; border-top: 1px solid rgba(255, 255, 255, 0.1); }
.sidebar-footer .btn { color: #fff; border-color: rgba(255, 255, 255, 0.35); background: transparent; }
.sidebar-footer .btn:hover { background: rgba(255, 255, 255, 0.08); }
.ios-hint { font-size: 12px; color: #9fbdd8; margin: 8px 0; }
.role-badge { font-size: 12px; color: #9fbdd8; margin: 0 0 10px; text-transform: uppercase; letter-spacing: 0.8px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 22px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-brand { display: none; font-weight: 700; color: var(--brand-dark); font-size: 17px; }
.menu-btn { display: none; }
.search { display: flex; gap: 8px; flex: 1; max-width: 560px; }
.search input { flex: 1; }
.content { padding: 22px; max-width: 1180px; width: 100%; }
.scrim { display: none; }

/* Buttons and badges */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); cursor: pointer; font-size: 14px; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: #b9c8d8; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #125e9a; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn.is-disabled { opacity: 0.45; pointer-events: none; }
.icon-btn { border: 0; background: transparent; font-size: 22px; cursor: pointer; padding: 4px 8px; line-height: 1; }
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: #e8eef5; color: var(--muted); vertical-align: middle;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.chip {
  display: inline-block; padding: 6px 12px; margin: 0 8px 8px 0; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand-dark); font-size: 14px;
}
.chip:hover { text-decoration: none; background: #d3e8f8; }
.chip.is-active { background: var(--brand); color: #fff; }
.chips { margin: 6px 0 4px; }

/* Cards and lists */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 6px 0 16px; }
.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--brand-dark); }
.kpi-label { font-size: 13px; color: var(--muted); }
.kpi-hint { font-size: 12px; color: var(--muted); margin-top: 2px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile {
  display: block; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; color: var(--ink);
}
.tile:hover { text-decoration: none; box-shadow: 0 8px 28px rgba(20, 38, 58, 0.13); }
.tile-icon { font-size: 26px; }
.tile-title { font-weight: 700; margin: 6px 0 2px; }
.tile-meta { font-size: 13px; color: var(--muted); }
.list { list-style: none; padding: 0; margin: 0; }
.item { padding: 14px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; padding-top: 4px; }
.item-title { font-weight: 700; font-size: 16px; }
.item-num { display: inline-block; min-width: 26px; color: var(--muted); font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; margin-top: 4px; }
.meta b { color: var(--brand-dark); font-weight: 600; }
.block { padding: 12px 14px; border-radius: 12px; background: #f6f9fc; margin: 10px 0; }
.block + .block { margin-top: 8px; }
.evidence { padding: 10px 14px; border-left: 4px solid var(--brand); background: var(--brand-soft); border-radius: 0 10px 10px 0; margin: 8px 0; font-size: 14px; }
.notice { padding: 12px 16px; border-radius: 12px; margin: 0 0 14px; font-size: 14px; background: var(--brand-soft); color: var(--brand-dark); }
.notice-warn { background: var(--warn-soft); color: var(--warn); }
.notice-danger { background: var(--danger-soft); color: var(--danger); }
.notice-ok { background: var(--ok-soft); color: var(--ok); }
.empty { padding: 26px; text-align: center; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.filters .field { flex: 1 1 180px; margin: 0; }
.filters .btn { height: 42px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; vertical-align: top; padding: 9px 8px; border-bottom: 1px solid var(--line); }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); white-space: nowrap; }
.num { text-align: right; white-space: nowrap; }
.report-frame { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.brief { font-size: 15px; }
.two-col { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; }

/* Bottom navigation (phone) */
.bottom-nav { display: none; }

/* Bare pages: login, offline */
.bare-main { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 28px; }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.login-logo img { width: 48px; height: 48px; border-radius: 12px; }

@media (max-width: 960px) {
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { display: block; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 40; height: 100vh;
    transform: translateX(-100%); transition: transform 0.2s ease; width: min(86vw, 340px); flex: none;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(14, 44, 70, 0.45); z-index: 30; }
  body.nav-open { overflow: hidden; }
  .sidebar-close { display: inline-block; }
  .menu-btn { display: inline-block; }
  .topbar { padding: 10px 14px; gap: 8px; }
  .topbar-brand { display: inline; }
  .search { max-width: none; width: 100%; order: 3; }
  .search .btn { display: none; }
  .topbar { flex-wrap: wrap; }
  .content { padding: 16px 14px calc(var(--bottom-nav-height) + 22px); }
  h1.page-title { font-size: 22px; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
  }
  .tab {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    font-size: 11px; color: var(--muted); border: 0; background: transparent; padding: 6px 2px;
  }
  .tab.is-active { color: var(--brand); font-weight: 600; }
  .tab-icon { font-size: 20px; }
  .kpi-value { font-size: 22px; }
  .report-frame { height: 70vh; }
  th, td { padding: 8px 6px; }
}
@media print {
  .sidebar, .topbar, .bottom-nav, .pager, .actions { display: none !important; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border: 1px solid var(--line); }
}
