/* base.css — reset, tipografi, layout shell. Tanpa warna hardcode. */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; color: inherit; }

h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 20px; font-weight: 650; }
h3 { font-size: 16px; font-weight: 650; }

.mono, code, .stat-value, .metric, time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.page-sub { color: var(--text-muted); font-size: 13px; margin-top: var(--s-1); }

.section-label {
  font-size: 11px; font-weight: 650; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-faint);
  margin: var(--s-8) 0 var(--s-3);
}
.section-label:first-child { margin-top: 0; }

/* ---- Shell: sidebar + topbar + content ---- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  position: sticky; top: 0; height: 100vh;
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto; z-index: 20;
  transition: width var(--t-base) var(--ease);
}
.sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .group-title,
.sidebar.collapsed .brand-name,
.sidebar.collapsed .side-foot-text { display: none; }

.brand {
  display: flex; align-items: center; gap: var(--s-2);
  height: var(--topbar-h); padding: 0 var(--s-4);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.brand-mark {
  width: 28px; height: 28px; border-radius: var(--r-sm); flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.brand-name { font-weight: 700; font-size: 15px; }
.brand-env { font-size: 11px; color: var(--text-faint); }

.nav-group { padding: var(--s-3) var(--s-2) 0; }
.group-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-2); cursor: pointer; border-radius: var(--r-sm);
  color: var(--text-faint);
}
.group-head:hover { background: var(--surface-2); }
.group-title { font-size: 11px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; }
.group-badge { font-size: 11px; font-family: var(--font-mono); color: var(--text-muted); }

.nav-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3); margin: 1px 0;
  border-radius: var(--r-sm); cursor: pointer; position: relative;
  color: var(--text-muted); border: none; background: none;
  width: 100%; text-align: left; font-size: 13.5px;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); }
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 2px; border-radius: 2px; background: var(--accent);
}
.nav-mono {
  width: 28px; height: 28px; border-radius: var(--r-sm); flex-shrink: 0;
  display: grid; place-items: center; font-size: 13px; font-weight: 650;
  background: var(--surface-3); color: var(--text-muted);
}
.nav-item.active .nav-mono { background: var(--accent-soft); color: var(--accent); }
.nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: var(--idle); }
.nav-dot.ok { background: var(--ok); }
.nav-dot.warn { background: var(--warn); }
.nav-dot.err { background: var(--err); }
.nav-dot.running { background: var(--ok); animation: pulse-dot 2s infinite; }

.side-foot {
  margin-top: auto; padding: var(--s-3);
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--s-2);
}
.conn-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex-shrink: 0; }
.conn-dot.warn { background: var(--warn); }
.conn-dot.err { background: var(--err); }
.side-foot-text { font-size: 12px; color: var(--text-muted); flex: 1; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  height: var(--topbar-h); flex-shrink: 0;
  display: flex; align-items: center; gap: var(--s-3);
  padding: 0 var(--s-4);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.breadcrumb { font-size: 13px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb b { color: var(--text); font-weight: 650; }
.topbar-spacer { flex: 1; }
.last-sync { font-size: 12px; color: var(--text-faint); font-family: var(--font-mono); white-space: nowrap; }
.icon-btn {
  width: 32px; height: 32px; border-radius: var(--r-sm); flex-shrink: 0;
  display: grid; place-items: center; cursor: pointer;
  background: none; border: 1px solid transparent; color: var(--text-muted);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.icon-btn:disabled { opacity: 0.45; cursor: default; }
.icon-btn .spin { animation: spin 0.8s linear infinite; }

.content {
  width: 100%; max-width: var(--content-max);
  margin: 0 auto; padding: var(--s-6) var(--s-8);
}
.page-head { display: flex; align-items: flex-start; gap: var(--s-4); margin-bottom: var(--s-6); flex-wrap: wrap; }
.page-head-main { flex: 1; min-width: 220px; }
.page-actions { display: flex; gap: var(--s-2); flex-wrap: wrap; }

/* ---- Grid ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); }
.service-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s-4); }
.split-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); }

/* ---- Focus & motion ---- */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }
@keyframes fade-in { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes flash-bg { from { background: var(--accent-soft); } to { background: transparent; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Responsive ---- */
.drawer-scrim {
  display: none; position: fixed; inset: 0; z-index: 15;
  background: rgba(0,0,0,0.5);
}
.drawer-scrim.open { display: block; }
.bottom-nav { display: none; }
.menu-btn { display: none; }

@media (max-width: 1279px) {
  .kpi-grid, .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1023px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 30;
    transform: translateX(-100%); transition: transform var(--t-base) var(--ease);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.collapsed { width: var(--sidebar-w); transform: translateX(-100%); }
  .sidebar.open.collapsed { transform: translateX(0); }
  .sidebar.collapsed .nav-label,
  .sidebar.collapsed .group-title,
  .sidebar.collapsed .brand-name,
  .sidebar.collapsed .side-foot-text { display: initial; }
  .menu-btn { display: grid; }
  .split-2 { grid-template-columns: 1fr; }
  .content { padding: var(--s-4); }
}
@media (max-width: 639px) {
  .kpi-grid, .stat-grid { grid-template-columns: 1fr; }
  .content { padding: var(--s-4) var(--s-4) 84px; }
  .bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg-subtle); border-top: 1px solid var(--border);
  }
  .bottom-nav a, .bottom-nav button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: var(--s-2) 0; font-size: 11px; color: var(--text-muted);
    background: none; border: none; cursor: pointer; min-height: 56px; justify-content: center;
  }
  .bottom-nav a.active, .bottom-nav button.active { color: var(--accent); }
  .last-sync { display: none; }
}
