/* ============================================================================
   KERJACERDAS — APP SHELL, TOPBAR, AUTO-ADAPTING SIDEBAR, DRAWER
   ========================================================================== */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 100%;
  height: 100vh;
  overflow: hidden;
  transition: grid-template-columns var(--t-med);
}

/* ---------------------------------------------------------------- SIDEBAR */
.sidebar {
  grid-column: 1;
  background: var(--dlkl-green-800);
  color: var(--ink-invert);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--dlkl-green-900);
  z-index: 60;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 18px;
  flex: 0 0 auto;
  border-bottom: 1px solid rgba(199, 167, 123, 0.18);
}
.brand-mark {
  width: 34px; height: 34px;
  flex: 0 0 34px;
  border-radius: 9px;
  background: linear-gradient(150deg, var(--biscuit) 0%, #9C7F52 100%);
  color: var(--dlkl-green-900);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  display: grid; place-items: center;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
}
.brand-text { min-width: 0; }
.brand-name {
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.1;
  white-space: nowrap;
}
.brand-sub {
  font-size: 10px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--biscuit);
  white-space: nowrap;
}

.nav { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding: 14px 10px 20px; }
.nav::-webkit-scrollbar-thumb { background: rgba(199,167,123,.28); border-color: var(--dlkl-green-800); }

.nav-group-label {
  font-size: 10px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(199, 167, 123, .72);
  padding: 16px 12px 7px;
  white-space: nowrap;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border-radius: var(--r-md);
  color: rgba(247, 243, 236, .8);
  cursor: pointer;
  position: relative;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--dlkl-green-600); color: #fff; }
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 50%;
  width: 3px; height: 20px;
  transform: translate(-10px, -50%);
  background: var(--biscuit);
  border-radius: 0 3px 3px 0;
}
.nav-ico { flex: 0 0 20px; width: 20px; height: 20px; display: grid; place-items: center; }
.nav-ico svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-label { flex: 1 1 auto; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; }
.nav-count {
  flex: 0 0 auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--alert);
  color: #fff;
  font-size: 10.5px;
  font-weight: 600;
  text-align: center;
}

.sidebar-foot {
  flex: 0 0 auto;
  padding: 12px;
  border-top: 1px solid rgba(199,167,123,.15);
}
.who {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--r-md);
  background: rgba(255,255,255,.05);
  cursor: pointer;
  transition: background var(--t-fast);
}
.who:hover { background: rgba(255,255,255,.09); }
.who-av {
  width: 32px; height: 32px; flex: 0 0 32px;
  border-radius: 50%;
  background: var(--biscuit-soft);
  color: var(--dlkl-green-800);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 700;
}
.who-meta { min-width: 0; flex: 1 1 auto; }
.who-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-role { font-size: 10px; color: var(--biscuit); letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.who-caret { flex: 0 0 auto; color: rgba(247,243,236,.55); }

/* ------------------------------------------------------------ MAIN COLUMN */
.main {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  background: var(--canvas);
}

/* --------------------------------------------------------------- TOPBAR */
.topbar {
  flex: 0 0 auto;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  z-index: 40;
}
.hamburger {
  display: none;
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-md);
  cursor: pointer;
  place-items: center;
  flex: 0 0 auto;
}
.hamburger svg { width: 20px; height: 20px; stroke: var(--ink); fill: none; stroke-width: 1.8; stroke-linecap: round; }

.page-id { min-width: 0; flex: 0 1 auto; margin-right: auto; }
.page-id .crumb {
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (max-width: 1200px) { .page-id .crumb { display: none; } }
.page-id h1 {
  font-family: var(--font-display);
  font-size: 20px;
  line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-tools { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

.scope-pill {
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-alt);
}
.scope-pill svg { width: 15px; height: 15px; stroke: var(--dlkl-green-700); fill: none; stroke-width: 1.7; }
.scope-pill select {
  border: 0; background: transparent; font-size: 13px; font-weight: 500;
  cursor: pointer; max-width: 210px;
}
.date-pill {
  display: flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-alt);
}
.date-pill input {
  border: 0; background: transparent; font-size: 12.5px;
  font-family: var(--font-mono); width: 116px; cursor: pointer;
}
.date-pill .dash { color: var(--ink-faint); }

/* ------------------------------------------------------------- CONTENT */
.content {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 22px;
  scroll-behavior: smooth;
}
.content-inner { max-width: 1560px; margin: 0 auto; }

.page-head {
  display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head .lede { flex: 1 1 380px; min-width: 0; }
.page-head h2 { font-family: var(--font-display); font-size: 23px; margin-bottom: 3px; }
.page-head .sub { font-size: 13px; color: var(--ink-muted); }
.page-head .acts { display: flex; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-2-1 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* ------------------------------------------------------------- BACKDROP */
#sidebar-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 31, 26, .5);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity var(--t-med);
  z-index: 55;
}
body.drawer-open #sidebar-backdrop { opacity: 1; pointer-events: auto; }

/* =========================================================== RESPONSIVE */

/* Tablet 768–1024px → compact icon bar 68px */
@media (max-width: 1024px) {
  .app-shell { grid-template-columns: var(--sidebar-compact) 1fr; }
  .sidebar { align-items: center; }
  .brand { padding: 0; justify-content: center; width: 100%; }
  .brand-text, .nav-label, .nav-group-label, .who-meta, .who-caret { display: none; }
  .nav { padding: 12px 8px; width: 100%; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .nav-item.active::before { transform: translate(-8px, -50%); }
  .nav-count {
    position: absolute; top: 4px; right: 6px;
    min-width: 16px; padding: 0 4px; font-size: 9px; line-height: 16px;
  }
  .nav-group-sep { height: 1px; background: rgba(199,167,123,.18); margin: 12px 6px; display: block; }
  .sidebar-foot { width: 100%; }
  .who { justify-content: center; }
  .content { padding: 18px; }
}
.nav-group-sep { display: none; }

/* Mobile ≤768px → off-canvas drawer */
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    align-items: stretch;
    transform: translateX(-100%);
    transition: transform var(--t-med);
    box-shadow: var(--sh-3);
  }
  body.drawer-open .sidebar { transform: translateX(0); }
  .brand { padding: 0 18px; justify-content: flex-start; }
  .brand-text, .nav-label, .nav-group-label, .who-meta, .who-caret { display: block; }
  .brand-text { display: block; }
  .nav { padding: 14px 10px 20px; }
  .nav-item { justify-content: flex-start; padding: 9px 12px; }
  .nav-item.active::before { transform: translate(-10px, -50%); }
  .nav-count { position: static; min-width: 20px; padding: 1px 6px; font-size: 10.5px; line-height: normal; }
  .nav-group-sep { display: none; }
  .who { justify-content: flex-start; }
  .main { grid-column: 1; }
  .hamburger { display: grid; }
  .topbar { padding: 0 14px; gap: 10px; }
  .page-id h1 { font-size: 17px; }
  .page-id .crumb { display: none; }
  .content { padding: 14px; }
  .grid-4, .grid-3, .grid-2, .grid-2-1 { grid-template-columns: minmax(0, 1fr); }
}

@media (min-width: 769px) and (max-width: 1320px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2-1 { grid-template-columns: minmax(0, 1fr); }
}
