/* ============================================================================
   Asisten Pembukuan Bos BRILink AI — Luxury Native CSS3 (Mobile-First)
   Zero External CSS Frameworks | Tabular Numerals | White-Label Theme Ready
   ============================================================================ */

:root {
  --brand-primary: #0B1F3A;
  --brand-primary-hover: #132F56;
  --brand-accent: #C9A227;
  --brand-accent-soft: #FBF6E6;
  --bg-canvas: #F8FAFC;
  --bg-surface: #FFFFFF;
  --bg-subtle: #F1F5F9;
  --text-main: #0F172A;
  --text-muted: #64748B;
  --border-color: #E2E8F0;
  --success: #15803D;
  --success-bg: #F0FDF4;
  --danger: #B91C1C;
  --danger-bg: #FEF2F2;
  --warning: #B45309;
  --warning-bg: #FFFBEB;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 24px rgba(11, 31, 58, 0.08);
  --font-display: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

html, body {
  font-family: var(--font-body);
  background-color: var(--bg-canvas);
  color: var(--text-main);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

a {
  color: inherit;
  text-decoration: none;
}

.tabular {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

/* ---------------- App Shell Layout ---------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 268px;
  background: var(--brand-primary);
  color: #E2E8F0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-brand img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: cover;
  background: #FFFFFF;
}

.sidebar-brand-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.25;
}

.sidebar-brand-sub {
  font-size: 11px;
  color: #94A3B8;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 600;
  color: #94A3B8;
  padding: 14px 12px 6px;
  letter-spacing: 0.04em;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  color: #CBD5E1;
  transition: background-color 0.16s ease, color 0.16s ease;
  white-space: nowrap;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
}

.nav-link.active {
  background: rgba(201, 162, 39, 0.18);
  color: #FFFFFF;
  font-weight: 600;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.9;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  color: #94A3B8;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  z-index: 35;
}

/* ---------------- Main Area ---------------- */
.main-wrap {
  flex: 1;
  margin-left: 268px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 64px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 25;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-main);
}

.page-content {
  padding: 24px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
}

/* ---------------- Cards & Grid ---------------- */
.grid {
  display: grid;
  gap: 20px;
}

.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)); }

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.card-title {
  font-size: 16px;
  font-weight: 700;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
}

.kpi-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.kpi-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.text-positive { color: var(--success); }
.text-negative { color: var(--danger); }
.text-muted { color: var(--text-muted); }

/* ---------------- Buttons & Inputs ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  min-height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.16s ease, border-color 0.16s ease, transform 0.12s ease;
}

.btn:active {
  transform: scale(0.99);
}

.btn-primary {
  background: var(--brand-primary);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--brand-primary-hover);
}

.btn-accent {
  background: var(--brand-accent);
  color: #0B1F3A;
}

.btn-accent:hover {
  filter: brightness(0.95);
}

.btn-outline {
  background: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background: var(--bg-subtle);
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
}

.btn-danger:hover {
  filter: brightness(0.92);
}

.btn-sm {
  padding: 7px 12px;
  min-height: 34px;
  font-size: 13px;
}

.form-grid {
  display: grid;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.form-control {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid #CBD5E1;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text-main);
  background: #FFFFFF;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(11, 31, 58, 0.1);
}

textarea.form-control {
  min-height: 92px;
  resize: vertical;
}

/* ---------------- Tables ---------------- */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table td {
  padding: 12px;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
}

.table tbody tr:hover {
  background: #F8FAFC;
}

.text-right { text-align: right !important; }

/* ---------------- Progress Bar & Quota Meter ---------------- */
.quota-bar-track {
  width: 100%;
  height: 10px;
  background: var(--bg-subtle);
  border-radius: 6px;
  overflow: hidden;
  margin: 12px 0;
}

.quota-bar-fill {
  height: 100%;
  background: var(--brand-primary);
  transition: width 0.25s ease;
}

.quota-bar-fill.full {
  background: var(--warning);
}

/* ---------------- Alerts & Notices ---------------- */
.notice {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  font-size: 14px;
}

.notice-warning {
  background: var(--warning-bg);
  border-color: #FDE68A;
  color: #92400E;
}

.notice-success {
  background: var(--success-bg);
  border-color: #BBF7D0;
  color: #166534;
}

.notice-danger {
  background: var(--danger-bg);
  border-color: #FECACA;
  color: #991B1B;
}

/* ---------------- Auth Pages ---------------- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(155deg, #0B1F3A 0%, #16335C 52%, #0F172A 100%);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.28);
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.auth-logo img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
}

/* ---------------- Chart Container ---------------- */
.chart-box {
  width: 100%;
  min-height: 240px;
  padding-top: 8px;
}

/* ---------------- Toast ---------------- */
.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--brand-primary);
  color: #FFFFFF;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow-md);
  max-width: 360px;
}

.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* ---------------- Segmented Tabs ---------------- */
.segmented {
  display: inline-flex;
  background: var(--bg-subtle);
  padding: 4px;
  border-radius: 10px;
  gap: 4px;
}

.segmented button {
  border: none;
  background: transparent;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.segmented button.active {
  background: #FFFFFF;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

/* ---------------- Responsive ---------------- */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-overlay.open {
    display: block;
  }
  .main-wrap {
    margin-left: 0;
  }
  .menu-toggle {
    display: inline-flex;
  }
  .page-content {
    padding: 16px;
  }
  .grid-4, .grid-3, .grid-2 {
    grid-template-columns: 1fr;
  }
}

@media print {
  .sidebar, .topbar, .no-print {
    display: none !important;
  }
  .main-wrap {
    margin-left: 0 !important;
  }
  .card {
    border: 1px solid #CBD5E1;
    break-inside: avoid;
  }
}
