/* ==========================================================
   Shell layout: full-width header, left navigation rail, content
   column with a thin system status bar underneath.
   ========================================================== */

/* ================= Header ================= */
#topbar {
  position: relative;
  height: var(--topbar-h); min-height: var(--topbar-h);
  display: flex; align-items: center;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.tb-brand {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  height: 100%;
  display: flex; align-items: center; gap: 11px;
  padding: 0 16px;
  border-right: 1px solid var(--border);
}
.tb-logo {
  width: 34px; height: 34px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent-strong);
  overflow: hidden;
}
.tb-logo svg { width: 20px; height: 20px; }
.tb-logo.has-img { background: transparent; border-color: transparent; }
.tb-badge { width: 34px; height: 34px; object-fit: contain; }
.tb-brand-text { min-width: 0; }
.tb-title {
  font-family: var(--font-display);
  font-size: 14.5px; font-weight: 700; letter-spacing: .6px; color: var(--text-0);
  line-height: 1.15; white-space: nowrap;
}
.tb-title span { color: var(--accent-strong); }
.tb-dept-sub {
  font-size: 10px; font-weight: 600; letter-spacing: .7px; text-transform: uppercase;
  color: var(--text-2); line-height: 1.3; margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px;
}

/* ---- Global search ---- */
.tb-search {
  position: relative;
  flex: 1 1 auto; min-width: 180px; max-width: 620px;
  margin: 0 18px;
}
.tb-search-box {
  display: flex; align-items: center; gap: 9px;
  height: 36px; padding: 0 10px 0 12px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.tb-search-box:hover { border-color: var(--border-strong); }
.tb-search.open .tb-search-box,
.tb-search-box:focus-within { border-color: var(--accent-border); box-shadow: var(--glow-accent); background: var(--bg-2); }
.tb-search-ico { color: var(--text-2); display: flex; }
.tb-search-ico svg { width: 15px; height: 15px; }
.tb-search-box input {
  flex: 1; min-width: 0; height: 100%;
  background: transparent; border: none; outline: none;
  color: var(--text-0); font-size: 13px;
}
.tb-search-box input::placeholder { color: var(--text-3); }
.kbd {
  font-family: var(--font-mono); font-size: 10px; color: var(--text-2);
  border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: var(--radius-xs); padding: 1px 6px; white-space: nowrap; flex: none;
  background: var(--bg-2);
}

.tb-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px 0 6px;
  height: 100%;
}
.tb-divider { width: 1px; height: 26px; background: var(--border); flex: none; }

.tb-status-pill {
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px 0 11px;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 11.5px; font-weight: 700; letter-spacing: .3px; color: var(--text-0);
  cursor: pointer; white-space: nowrap;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.tb-status-pill:hover { border-color: var(--border-strong); background: var(--bg-4); }
.tb-status-pill .mono { color: var(--text-1); font-weight: 600; }
.tb-chev { display: flex; color: var(--text-2); }
.tb-chev svg { width: 12px; height: 12px; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.status-dot.good { background: var(--good-strong); box-shadow: 0 0 0 3px var(--good-soft); }
.status-dot.busy { background: var(--warn-strong); box-shadow: 0 0 0 3px var(--warn-soft); }
.status-dot.emergency { background: var(--danger-strong); box-shadow: 0 0 0 3px var(--danger-soft); animation: pulseDot 1.2s ease-in-out infinite; }
.status-dot.off { background: var(--text-3); }
.status-dot.info { background: var(--info-strong); box-shadow: 0 0 0 3px var(--info-soft); }
@keyframes pulseDot { 50% { box-shadow: 0 0 0 5px transparent; } }

.tb-clock-wrap { text-align: right; line-height: 1.15; padding: 0 2px; }
.tb-clock { font-family: var(--font-mono); font-size: 14px; font-weight: 700; color: var(--text-0); letter-spacing: .5px; white-space: nowrap; }
.tb-date { font-size: 10px; color: var(--text-2); letter-spacing: .4px; text-transform: uppercase; margin-top: 2px; white-space: nowrap; }

.icon-btn {
  position: relative;
  width: 34px; height: 34px; flex: none;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-1); cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--bg-4); color: var(--text-0); border-color: var(--border-strong); }
.icon-btn .btn-ico svg, .icon-btn svg { width: 16px; height: 16px; }
.icon-btn.active { border-color: var(--accent-border); color: var(--accent-strong); }
.icon-btn.close:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.icon-btn .notif-count {
  position: absolute; top: -5px; right: -5px;
  min-width: 17px; height: 17px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  background: var(--danger); color: #fff;
  font-size: 9.5px; font-weight: 700;
  border-radius: 9px; box-shadow: 0 0 0 2px var(--bg-1);
}

.tb-user {
  display: flex; align-items: center; gap: 9px;
  height: 40px; padding: 0 8px 0 4px;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-0); cursor: pointer; text-align: left;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease);
  min-width: 0;
}
.tb-user:hover { background: var(--bg-3); border-color: var(--border); }
.tb-user-avatar, .avatar {
  width: 32px; height: 32px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  background: var(--bg-4); border: 1px solid var(--border-strong);
  color: var(--text-0); font-size: 11.5px; font-weight: 700; letter-spacing: .3px;
}
.tb-user-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; line-height: 1.2; }
.tb-user-sub { font-size: 10.5px; color: var(--text-2); white-space: nowrap; margin-top: 2px; line-height: 1.2; }
.tb-user-sub .mono { color: var(--accent-strong); font-weight: 600; }
.tb-user-text { min-width: 0; }

/* ================= Shell ================= */
#layout { flex: 1; display: flex; min-height: 0; }
#layout.hidden { display: none; }

/* ================= Sidebar ================= */
#sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  display: flex; flex-direction: column;
  background: var(--bg-1);
  border-right: 1px solid var(--border);
}
#sidebar.hidden { display: none; }

#nav { flex: 1; overflow-y: auto; padding: 12px 10px 10px; display: flex; flex-direction: column; }
.nav-group { display: flex; flex-direction: column; gap: 1px; margin-bottom: 12px; }
.nav-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-3); padding: 4px 10px 6px;
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  width: 100%; height: 34px; padding: 0 10px;
  background: transparent; border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-1); font-size: 12.8px; font-weight: 500; text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-icon {
  width: 18px; height: 18px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-2);
  transition: color var(--dur-fast) var(--ease);
}
.nav-icon svg { width: 17px; height: 17px; display: block; }
.nav-item:hover { background: var(--bg-3); color: var(--text-0); }
.nav-item:hover .nav-icon { color: var(--text-1); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--text-0); font-weight: 600;
}
.nav-item.active::before {
  content: ''; position: absolute; left: -10px; top: 7px; bottom: 7px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-item.active .nav-icon { color: var(--accent-strong); }
.nav-badge {
  margin-left: auto;
  min-width: 20px; height: 18px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700;
  background: var(--bg-4); color: var(--text-1);
  border-radius: 9px;
}
.nav-badge.alert { background: var(--danger-soft); color: var(--danger-strong); }
.nav-item.active .nav-badge { background: var(--accent); color: var(--on-accent); }

/* ---- Sidebar officer block ---- */
.sb-officer {
  flex: none;
  margin: 0 10px 10px;
  padding: 11px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.sb-officer-top { display: flex; align-items: center; gap: 10px; }
.sb-officer .avatar { width: 38px; height: 38px; font-size: 12.5px; border-radius: var(--radius); }
.sb-officer .avatar.on { border-color: var(--accent-border); color: var(--accent-strong); background: var(--accent-soft); }
.officer-name { font-size: 12.8px; font-weight: 600; color: var(--text-0); line-height: 1.25; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.officer-sub { font-size: 10.8px; color: var(--text-2); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-officer-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.sb-meta-cell { background: var(--bg-1); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 5px 8px; min-width: 0; }
.sb-meta-label { font-size: 9px; font-weight: 700; letter-spacing: .8px; color: var(--text-3); text-transform: uppercase; }
.sb-meta-value { font-size: 11.5px; font-weight: 600; color: var(--text-0); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-meta-value.mono { color: var(--accent-strong); }
.sb-duty {
  display: flex; align-items: center; gap: 8px; width: 100%;
  margin-top: 8px; padding: 6px 8px;
  background: var(--bg-1); border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 600; color: var(--text-1); cursor: pointer; text-align: left;
  transition: border-color var(--dur-fast) var(--ease);
}
.sb-duty:hover { border-color: var(--border-strong); color: var(--text-0); }
.sb-duty .tb-chev { margin-left: auto; }
.sb-actions { display: flex; gap: 6px; margin-top: 8px; }
.sb-actions .btn { flex: 1; }

/* ================= Content column ================= */
#main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg-0); }
#view-root { flex: 1; overflow-y: auto; padding: 20px 24px 28px; min-width: 0; min-height: 0; }

.view-header {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin-bottom: 16px; flex-wrap: wrap;
}
.view-header h1 {
  margin: 0; font-family: var(--font-display);
  font-size: 20px; font-weight: 700; letter-spacing: .1px; color: var(--text-0);
}
.view-sub { margin: 3px 0 0; color: var(--text-2); font-size: 12px; }
.view-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Status bar ---- */
#statusbar {
  height: var(--statusbar-h); min-height: var(--statusbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 14px;
  background: var(--bg-1);
  border-top: 1px solid var(--border);
  font-size: 10.5px; color: var(--text-2); letter-spacing: .3px;
  white-space: nowrap; overflow: hidden;
}
.sbar-item { display: flex; align-items: center; gap: 6px; min-width: 0; }
.sbar-item .status-dot { width: 6px; height: 6px; box-shadow: none; }
.sbar-item svg { width: 12px; height: 12px; }
.sbar-strong { color: var(--text-1); font-weight: 600; }
.sbar-loc { overflow: hidden; text-overflow: ellipsis; }
.sbar-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.sbar-sep { width: 1px; height: 12px; background: var(--border); }

/* ================= Two-pane (list + detail) ================= */
.split-panel {
  display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 14px;
  height: calc(var(--mdt-h) - var(--topbar-h) - var(--statusbar-h) - 150px);
  min-height: 360px;
}
.split-panel.wide-list { grid-template-columns: 400px minmax(0, 1fr); }
.list-pane {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow-y: auto; padding: 6px;
}
.detail-pane {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow-y: auto; padding: 20px 22px;
  min-width: 0;
}

/* ================= Responsive ================= */
@media (max-width: 1600px) {
  :root { --sidebar-w: 212px; }
  .split-panel { grid-template-columns: 300px minmax(0, 1fr); }
  .split-panel.wide-list { grid-template-columns: 340px minmax(0, 1fr); }
}
@media (max-width: 1440px) {
  .tb-clock-wrap .tb-date { display: none; }
  .tb-user-text { display: none; }
  .tb-search { margin: 0 12px; }
}
@media (max-width: 1320px) {
  :root { --sidebar-w: 196px; --topbar-h: 52px; }
  #view-root { padding: 16px 18px 22px; }
  .tb-brand { padding: 0 12px; gap: 9px; }
  .tb-dept-sub { max-width: 120px; }
  .kbd { display: none; }
  .tb-status-pill .tb-status-text { display: none; }
  .split-panel { grid-template-columns: 270px minmax(0, 1fr); gap: 10px; }
  .split-panel.wide-list { grid-template-columns: 300px minmax(0, 1fr); }
  .detail-pane { padding: 16px; }
  .sb-officer-meta { display: none; }
}
@media (max-height: 780px) {
  :root { --topbar-h: 50px; --statusbar-h: 24px; }
  .nav-item { height: 30px; }
  .nav-group { margin-bottom: 8px; }
  .sb-officer-meta { display: none; }
  .sb-actions { display: none; }
  #view-root { padding-top: 14px; }
}
