/* ============================================
   SURAT ISP — EDITORIAL CORPORATE DESIGN SYSTEM
   ============================================ */

/* Premium fonts dari Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* === DESIGN TOKENS === */
:root {
  /* Color Palette — Deep Editorial */
  --ink: #0a0e1a;
  --ink-soft: #1a1f2e;
  --ink-muted: #4a5266;
  --ink-faded: #8a92a6;

  --paper: #fafaf7;
  --paper-warm: #f5f3ee;
  --paper-cool: #f0f1f4;
  --white: #ffffff;

  --line: #e4e2dc;
  --line-soft: #ecebe5;

  /* Brand — Emerald yang sophisticated */
  --brand: #1e40af;
  --brand-bright: #3b82f6;
  --brand-soft: #dbeafe;
  --brand-deep: #1e3a8a;

  /* Semantic colors */
  --gold: #b88a2e;
  --gold-soft: #f5ecd5;
  --crimson: #a02e2e;
  --crimson-soft: #f5e0e0;
  --slate: #5a6478;
  --amber: #c87a1f;
  --amber-soft: #f7e8d4;

  /* Typography */
  --font-serif: 'Fraunces', 'Georgia', serif;
  --font-sans: 'Inter', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Menlo', monospace;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;

  /* Radius */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --r-xl: 16px;

  /* Shadows — sharp & editorial, not soft */
  --shadow-xs: 0 1px 0 rgba(10, 14, 26, 0.04);
  --shadow-sm: 0 1px 2px rgba(10, 14, 26, 0.06), 0 1px 1px rgba(10, 14, 26, 0.04);
  --shadow-md: 0 4px 12px rgba(10, 14, 26, 0.08), 0 2px 4px rgba(10, 14, 26, 0.04);
  --shadow-lg: 0 12px 24px rgba(10, 14, 26, 0.10), 0 4px 8px rgba(10, 14, 26, 0.06);
  --shadow-brand: 0 8px 24px rgba(30, 64, 175, 0.18);

  /* Layout */
  --sidebar-w: 260px;
  --header-h: 64px;
}

/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

h1, h2, h3, h4, h5 {
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--ink);
}

h1 { font-size: 28px; font-weight: 600; }
h2 { font-size: 22px; }
h3 { font-size: 18px; }
h4 { font-size: 16px; }

a { color: var(--brand); text-decoration: none; transition: color .15s; }
a:hover { color: var(--brand-bright); }

button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

code, .mono { font-family: var(--font-mono); }

/* === LOGIN PAGE === */
.login-body {
  min-height: 100vh;
  display: flex;
  background: var(--ink);
  position: relative;
  overflow: hidden;
}

.login-body::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(59, 130, 246, 0.18), transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(245, 158, 11, 0.08), transparent 50%);
  pointer-events: none;
}

.login-body::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}

.login-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px 56px;
  color: var(--paper);
  position: relative;
  z-index: 1;
}

.login-mark {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-mark span { color: var(--brand-bright); }

.login-headline {
  max-width: 480px;
}

.login-headline .eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brand-bright);
  margin-bottom: 24px;
}

.login-headline h1 {
  font-size: 56px;
  font-weight: 500;
  line-height: 1.05;
  color: var(--paper);
  margin-bottom: 24px;
  letter-spacing: -0.03em;
}

.login-headline h1 em {
  font-style: italic;
  font-weight: 400;
  color: var(--brand-bright);
}

.login-headline p {
  font-size: 16px;
  line-height: 1.6;
  color: rgba(250, 250, 247, 0.7);
  max-width: 420px;
}

.login-footer {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(250, 250, 247, 0.4);
  letter-spacing: 0.05em;
}

.login-right {
  width: 480px;
  background: var(--paper);
  padding: 64px 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  z-index: 1;
}

.login-form-header { margin-bottom: 40px; }

.login-form-header h2 {
  font-size: 32px;
  margin-bottom: 8px;
}

.login-form-header p {
  color: var(--ink-muted);
  font-size: 14px;
}

.alert {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  margin-bottom: 20px;
  border-left: 3px solid;
}

.alert.error {
  background: var(--crimson-soft);
  border-color: var(--crimson);
  color: var(--crimson);
}

/* === LAYOUT — APP SHELL === */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
  background: var(--ink);
  color: var(--paper);
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--ink-soft);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px 24px;
  border-bottom: 1px solid var(--ink-soft);
  margin-bottom: 16px;
}

.sidebar-brand .logo-mark {
  width: 36px;
  height: 36px;
  background: var(--brand-bright);
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 18px;
  color: var(--ink);
  flex-shrink: 0;
}

.sidebar-brand .brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.sidebar-brand .brand-text strong {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  color: var(--paper);
}

.sidebar-brand .brand-text span {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--brand-bright);
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-nav { flex: 1; overflow-y: auto; }

.sidebar-section {
  margin-bottom: 24px;
}

.sidebar-section-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-faded);
  padding: 0 12px;
  margin-bottom: 8px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  color: rgba(250, 250, 247, 0.7);
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  margin-bottom: 2px;
  position: relative;
}

.sidebar-link:hover {
  background: var(--ink-soft);
  color: var(--paper);
}

.sidebar-link.active {
  background: var(--ink-soft);
  color: var(--paper);
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--brand-bright);
  border-radius: 0 2px 2px 0;
}

.sidebar-link .icon {
  width: 16px;
  height: 16px;
  opacity: 0.8;
}

.sidebar-user {
  padding: 16px 12px;
  border-top: 1px solid var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-user .avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--brand);
  color: var(--paper);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 13px;
  font-family: var(--font-serif);
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-info strong {
  display: block;
  font-size: 13px;
  color: var(--paper);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-info span {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-faded);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.sidebar-user .logout-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid var(--ink-soft);
  color: var(--ink-faded);
  display: grid;
  place-items: center;
  transition: all .15s;
}

.sidebar-user .logout-btn:hover {
  background: var(--crimson);
  border-color: var(--crimson);
  color: var(--paper);
}

/* MAIN CONTENT AREA */
.main {
  background: var(--paper);
  min-height: 100vh;
}

.topbar {
  height: var(--header-h);
  padding: 0 32px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}

.topbar-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-muted);
  letter-spacing: 0.05em;
}

.topbar-meta strong { color: var(--ink); }

.content {
  padding: 32px;
  max-width: 1400px;
}

/* === PAGE HEADER === */
.page-header {
  margin-bottom: 32px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.page-header-left .eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-header-left .eyebrow::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 1px;
  background: var(--brand);
}

.page-header-left h1 {
  font-size: 32px;
  margin-bottom: 6px;
}

.page-header-left p {
  color: var(--ink-muted);
  font-size: 14px;
  max-width: 600px;
}

.page-header-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* === CARDS === */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line-soft);
}

.card-head h2, .card-head h3 {
  font-family: var(--font-serif);
}

.card h3 { margin-bottom: 16px; }

/* === STATS GRID — EDITORIAL === */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 32px;
}

.stat-block {
  background: var(--white);
  padding: 24px;
  position: relative;
  transition: background .2s;
}

.stat-block:hover { background: var(--paper-warm); }

.stat-block .label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 12px;
}

.stat-block .value {
  font-family: var(--font-serif);
  font-size: 42px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-block .delta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--brand);
  margin-top: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-block.accent .value { color: var(--brand); }

/* Mini stats per jenis */
.stats-mini {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.stat-mini {
  background: var(--white);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  padding: 16px 20px;
  border-radius: var(--r-md);
}

.stat-mini .label {
  font-size: 11px;
  color: var(--ink-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.stat-mini .value {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 600;
  color: var(--ink);
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
  font-family: var(--font-sans);
}

.btn:hover {
  border-color: var(--ink-muted);
  background: var(--paper-warm);
  color: var(--ink);
}

.btn-primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.btn-primary:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--paper);
  box-shadow: var(--shadow-brand);
}

.btn-brand {
  background: var(--brand);
  color: var(--paper);
  border-color: var(--brand);
}

.btn-brand:hover {
  background: var(--brand-bright);
  border-color: var(--brand-bright);
  color: var(--paper);
}

.btn-danger {
  background: var(--white);
  color: var(--crimson);
  border-color: var(--crimson-soft);
}

.btn-danger:hover {
  background: var(--crimson);
  color: var(--paper);
  border-color: var(--crimson);
}

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-block { width: 100%; justify-content: center; padding: 12px 16px; }

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
}

/* === FORMS === */
.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}

.form-group label .req { color: var(--crimson); }

.form-group .hint {
  font-size: 11px;
  color: var(--ink-faded);
  margin-top: 4px;
}

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="file"],
textarea, select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  font-size: 14px;
  background: var(--white);
  color: var(--ink);
  transition: all .15s;
  font-family: inherit;
}

input:hover, textarea:hover, select:hover { border-color: var(--ink-faded); }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}

textarea { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.form-divider {
  border-top: 1px solid var(--line);
  margin: 24px 0 20px;
  padding-top: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.form-divider span {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 500;
}

.form-actions {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* === TABLES === */
.table-wrap {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  background: var(--paper-warm);
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--line);
}

.table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  vertical-align: middle;
}

.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--paper-warm); }
.table tbody tr:last-child td { border-bottom: none; }

.table .nomor {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink);
  font-weight: 500;
}

.table .empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink-faded);
  font-style: italic;
}

/* === DETAIL TABLE === */
.detail-table { width: 100%; }
.detail-table th {
  text-align: left;
  padding: 10px 0;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  width: 35%;
  vertical-align: top;
}
.detail-table td {
  padding: 10px 0;
  font-size: 14px;
  color: var(--ink);
  border-bottom: 1px solid var(--line-soft);
}
.detail-table tr:last-child td,
.detail-table tr:last-child th { border-bottom: none; }

/* === BADGES & STATUS === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--paper-cool);
  border-radius: var(--r-sm);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-gold { background: var(--gold-soft); color: var(--gold); }
.badge-crimson { background: var(--crimson-soft); color: var(--crimson); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.status-draft { background: var(--amber-soft); color: var(--amber); }
.status-published { background: var(--brand-soft); color: var(--brand); }
.status-archived { background: var(--paper-cool); color: var(--ink-muted); }

/* === FILTER BAR === */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

.filter-bar select, .filter-bar input {
  height: 38px;
}

.filter-bar input[type="text"] {
  flex: 1;
  max-width: 400px;
}

/* === SURAT TYPE GRID === */
.surat-types {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.surat-type-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  transition: all .2s;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
}

.surat-type-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--brand-soft) 0%, transparent 60%);
  opacity: 0;
  transition: opacity .2s;
}

.surat-type-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.surat-type-card:hover::before { opacity: 1; }

.surat-type-card > * { position: relative; z-index: 1; }

.surat-type-card .type-num {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--ink-faded);
  font-weight: 600;
}

.surat-type-card h4 {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
}

.surat-type-card p {
  font-size: 12px;
  color: var(--ink-muted);
  line-height: 1.5;
}

.surat-type-card .arrow {
  font-family: var(--font-serif);
  color: var(--brand);
  font-weight: 600;
  margin-top: auto;
  font-size: 13px;
}

/* === JSON DATA DISPLAY === */
.json-data {
  background: var(--ink);
  color: var(--paper);
  padding: 16px 20px;
  border-radius: var(--r-md);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  overflow-x: auto;
  border: 1px solid var(--ink-soft);
}

/* === SIGNATURE PREVIEW === */
.signature-preview {
  margin: 16px 0 24px;
  padding: 20px;
  background: var(--paper-warm);
  border: 1px dashed var(--line);
  border-radius: var(--r-md);
}

.signature-preview p {
  font-size: 11px;
  color: var(--ink-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 12px;
}

.signature-preview img {
  max-width: 260px;
  max-height: 100px;
  background: var(--white);
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}

/* === UTILITIES === */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--ink-muted); }
.mb-0 { margin-bottom: 0 !important; }
.mt-3 { margin-top: 16px; }

hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 24px 0;
}

/* === ANIMATIONS === */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.content { animation: fadeIn .3s ease-out; }

.card, .stat-block, .surat-type-card {
  animation: fadeIn .4s ease-out backwards;
}

/* Staggered animation for grids */
.surat-types > *:nth-child(1) { animation-delay: .05s; }
.surat-types > *:nth-child(2) { animation-delay: .10s; }
.surat-types > *:nth-child(3) { animation-delay: .15s; }
.surat-types > *:nth-child(4) { animation-delay: .20s; }
.surat-types > *:nth-child(5) { animation-delay: .25s; }
.surat-types > *:nth-child(6) { animation-delay: .30s; }
.surat-types > *:nth-child(7) { animation-delay: .35s; }

/* === RESPONSIVE === */
@media (max-width: 1024px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0; }
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    left: -260px;
    width: 260px;
    transition: left .2s;
    z-index: 100;
  }
  .sidebar.open { left: 0; }
  .topbar { padding: 0 16px; }
  .content { padding: 16px; }
  .login-body { flex-direction: column; }
  .login-left { padding: 32px 24px; }
  .login-right { width: 100%; padding: 32px 24px; }
  .login-headline h1 { font-size: 36px; }
  .stats-row { grid-template-columns: 1fr; }
}

/* === SCROLLBARS === */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--paper-warm); }
::-webkit-scrollbar-thumb { background: var(--ink-faded); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-muted); }

/* ===================================================================
   MASTER DATA UI — Production-ready design system
   Stats cards + sidebar filter + modern data table + slide-over
   =================================================================== */

/* === MASTER LAYOUT GRID === */
.master-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  margin-top: 16px;
}
@media (max-width: 900px) {
  .master-layout { grid-template-columns: 1fr; }
}

/* === STATS CARDS ROW === */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
@media (max-width: 900px) { .stats-row { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  position: relative;
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(10,14,26,0.06); }
.stat-card-accent { position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--brand); }
.stat-card.warning .stat-card-accent { background: #f59e0b; }
.stat-card.danger .stat-card-accent { background: #dc2626; }
.stat-card.dark .stat-card-accent { background: var(--ink); }
.stat-card.success .stat-card-accent { background: #10b981; }

.stat-card-label {
  font-size: 11px;
  color: var(--ink-faded);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.stat-card-value {
  font-family: 'Fraunces', Times, serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1;
}
.stat-card-trend {
  font-size: 11px;
  color: var(--ink-muted);
  margin-top: 4px;
}
.stat-card-icon {
  position: absolute; top: 16px; right: 16px;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--paper-warm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}

/* === SIDEBAR FILTER === */
.filter-sidebar {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
  height: fit-content;
  position: sticky;
  top: 20px;
}
.filter-section { margin-bottom: 20px; }
.filter-section:last-child { margin-bottom: 0; }
.filter-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--ink-faded);
  text-transform: uppercase;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.filter-clear {
  font-size: 10px;
  color: var(--brand);
  cursor: pointer;
  font-weight: 500;
}
.filter-clear:hover { text-decoration: underline; }

.filter-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background .15s;
  margin-bottom: 2px;
}
.filter-option:hover { background: var(--paper-warm); }
.filter-option.active { background: var(--brand-soft); color: var(--brand-deep); font-weight: 600; }
.filter-option-count {
  font-size: 11px;
  color: var(--ink-faded);
  background: var(--paper-warm);
  padding: 2px 8px;
  border-radius: 10px;
}
.filter-option.active .filter-option-count { background: white; color: var(--brand); }

/* === DATA TABLE WRAPPER === */
.data-table-wrapper {
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.data-table-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.data-table-search {
  flex: 1;
  min-width: 240px;
  position: relative;
}
.data-table-search input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  transition: border-color .15s;
}
.data-table-search input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.data-table-search::before {
  content: '🔍';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  opacity: 0.5;
}

.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chip {
  padding: 4px 10px;
  background: var(--paper-warm);
  color: var(--ink-muted);
  border-radius: 14px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.filter-chip:hover { background: var(--paper-cool); }
.filter-chip.active {
  background: var(--brand);
  color: white;
}
.filter-chip-remove { opacity: 0.7; }

/* === DATA TABLE === */
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table thead th {
  background: var(--paper-warm);
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  user-select: none;
}
.data-table thead th.sortable { cursor: pointer; }
.data-table thead th.sortable:hover { background: var(--paper-cool); color: var(--ink); }
.data-table thead th .sort-indicator { font-size: 10px; opacity: 0.4; margin-left: 4px; }
.data-table thead th.sorted .sort-indicator { opacity: 1; color: var(--brand); }

.data-table tbody tr {
  border-bottom: 1px solid var(--line-soft);
  transition: background .1s;
}
.data-table tbody tr:hover { background: var(--paper-warm); }
.data-table tbody tr.selected { background: var(--brand-soft); }
.data-table tbody tr.selected:hover { background: var(--brand-soft); }

.data-table tbody td {
  padding: 12px;
  font-size: 13px;
  vertical-align: middle;
}
.data-table td.cell-primary { font-weight: 600; color: var(--ink); }
.data-table td.cell-code {
  font-family: 'JetBrains Mono', Courier, monospace;
  font-size: 11px;
  color: var(--ink-muted);
}
.data-table td.cell-muted { color: var(--ink-muted); font-size: 12px; }
.data-table td.cell-actions { text-align: right; white-space: nowrap; }

.cell-checkbox {
  width: 32px;
  text-align: center;
}
.cell-checkbox input { cursor: pointer; }

/* === STATUS BADGES === */
.badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-radius: 4px;
  text-transform: uppercase;
}
.badge-normal { background: #d1fae5; color: #065f46; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-high { background: #fed7aa; color: #9a3412; }
.badge-critical { background: #fecaca; color: #991b1b; }
.badge-isolated { background: #e5e7eb; color: #374151; }
.badge-info { background: var(--brand-soft); color: var(--brand-deep); }

/* === ROW ACTIONS === */
.row-action-btn {
  background: transparent;
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  color: var(--ink-muted);
  transition: all .15s;
  margin-left: 4px;
}
.row-action-btn:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--brand-soft);
}
.row-action-btn.danger:hover {
  border-color: #dc2626;
  color: #dc2626;
  background: #fef2f2;
}

/* === EMPTY STATE === */
.empty-state {
  padding: 60px 20px;
  text-align: center;
}
.empty-state-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}
.empty-state-title {
  font-family: 'Fraunces', Times, serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}
.empty-state-desc {
  color: var(--ink-muted);
  font-size: 13px;
  margin-bottom: 20px;
}

/* === PAGINATION === */
.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: var(--paper-warm);
}
.pagination-info { font-size: 12px; color: var(--ink-muted); }
.pagination-controls { display: flex; gap: 4px; }
.pagination-btn {
  padding: 4px 10px;
  border: 1px solid var(--line);
  background: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-muted);
  transition: all .15s;
}
.pagination-btn:hover:not(:disabled) {
  border-color: var(--brand);
  color: var(--brand);
}
.pagination-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination-btn.active {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

/* === BULK ACTIONS BAR === */
.bulk-actions-bar {
  background: var(--ink);
  color: white;
  padding: 10px 16px;
  border-radius: var(--r-md);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: slideDown 0.2s ease;
}
@keyframes slideDown {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.bulk-actions-count { font-size: 13px; font-weight: 600; }
.bulk-actions-buttons { display: flex; gap: 6px; }
.bulk-action-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: white;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background .15s;
}
.bulk-action-btn:hover { background: rgba(255,255,255,0.2); }
.bulk-action-btn.danger:hover { background: #dc2626; border-color: #dc2626; }

/* === SLIDE-OVER PANEL === */
.slideover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 26, 0.4);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s, visibility .25s;
}
.slideover-overlay.active { opacity: 1; visibility: visible; }

.slideover-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 540px;
  max-width: 90vw;
  background: white;
  z-index: 1001;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(10, 14, 26, 0.1);
}
.slideover-panel.active { transform: translateX(0); }

.slideover-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: start;
}
.slideover-title {
  font-family: 'Fraunces', Times, serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
}
.slideover-subtitle {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 4px;
}
.slideover-close {
  background: transparent;
  border: 1px solid var(--line);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--ink-muted);
  font-size: 16px;
  transition: all .15s;
}
.slideover-close:hover {
  background: var(--paper-warm);
  color: var(--ink);
}

.slideover-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
}

.slideover-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  background: var(--paper-warm);
}

/* Form field group dalam slideover */
.field-group { margin-bottom: 16px; }
.field-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.field-group label .req { color: #dc2626; }
.field-group input, .field-group select, .field-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.field-group input:focus, .field-group select:focus, .field-group textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.field-group .hint {
  font-size: 11px;
  color: var(--ink-faded);
  margin-top: 4px;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-faded);
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 20px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
}
.field-section-title:first-child { margin-top: 0; }

/* === TOAST === */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--ink);
  color: white;
  padding: 12px 20px;
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  z-index: 9999;
  font-size: 13px;
  animation: toastIn 0.25s ease;
}
.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* === AVATAR (initials circle) === */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-deep);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
}
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }
.avatar.vendor { background: #fef3c7; color: #92400e; }

/* User name + secondary line cell */
.cell-stack { display: flex; align-items: center; gap: 10px; }
.cell-stack-text { display: flex; flex-direction: column; gap: 2px; }
.cell-stack-primary { font-weight: 600; color: var(--ink); font-size: 13px; }
.cell-stack-secondary { font-size: 11px; color: var(--ink-faded); }

/* ===================================================================
   MOBILE RESPONSIVE — Comprehensive mobile-first
   =================================================================== */

/* Hamburger button — hidden on desktop */
.mobile-menu-toggle {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  margin-right: 8px;
  border-radius: 6px;
  color: var(--ink);
  align-items: center;
  justify-content: center;
}
.mobile-menu-toggle:hover { background: var(--paper-warm); }

/* Mobile sidebar overlay (dimming) */
.mobile-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(10, 14, 26, 0.5);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.2s;
}
.mobile-sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* === BREAKPOINT: TABLET (1024px) === */
@media (max-width: 1024px) {
  .master-layout {
    grid-template-columns: 220px 1fr;
    gap: 16px;
  }
  .field-row { grid-template-columns: 1fr; gap: 8px; }
}

/* === BREAKPOINT: MOBILE (768px) === */
@media (max-width: 768px) {
  /* Show hamburger */
  .mobile-menu-toggle { display: inline-flex; }

  /* Sidebar slide-in from left */
  .sidebar {
    position: fixed;
    left: -280px;
    top: 0;
    bottom: 0;
    width: 280px;
    z-index: 100;
    transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
  }
  .sidebar.open { left: 0; }

  .app { grid-template-columns: 1fr; }

  /* Topbar — adjust untuk hamburger */
  .topbar {
    padding: 0 14px;
    height: 56px;
    gap: 8px;
  }
  .topbar-title {
    font-size: 16px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-meta {
    font-size: 11px;
    color: var(--ink-faded);
  }
  .topbar-date { display: none; } /* hide date di mobile, biar lebih lega */

  /* Content padding lebih kecil */
  .content { padding: 14px; }

  /* Page header stack */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .page-header h1 { font-size: 22px !important; }
  .page-header p { font-size: 12px !important; }
  .page-header-actions { width: 100%; }
  .page-header-actions .btn { width: 100%; justify-content: center; }

  /* === STATS CARDS — Stack 2x2 atau 1 column === */
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }
  .stat-card { padding: 12px; }
  .stat-card-value { font-size: 22px; }
  .stat-card-label { font-size: 10px; }
  .stat-card-trend { font-size: 10px; }
  .stat-card-icon { width: 24px; height: 24px; font-size: 12px; top: 12px; right: 12px; }

  /* === MASTER LAYOUT — Sidebar jadi accordion/collapsible === */
  .master-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .filter-sidebar {
    position: relative;
    top: 0;
    padding: 12px;
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
    transition: max-height 0.25s, padding 0.25s;
    border: 1px solid var(--line);
  }
  .filter-sidebar.expanded {
    max-height: 1000px;
    padding: 12px;
  }
  .filter-toggle-btn {
    display: flex !important;
    width: 100%;
    padding: 10px 14px;
    background: white;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    cursor: pointer;
    font-size: 13px;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
  }
  .filter-toggle-btn .filter-toggle-count {
    background: var(--brand);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
  }
  
  /* === DATA TABLE — Horizontal scroll + minimum width === */
  .data-table-wrapper {
    margin: 0 -14px; /* extend ke edge */
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .data-table-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px 12px;
  }
  .data-table-search { min-width: 100%; }
  .data-table-toolbar select { width: 100%; }
  
  /* Tabel scroll horizontal */
  .data-table-scroll-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .data-table { min-width: 700px; }
  .data-table thead th { font-size: 10px; padding: 8px 10px; }
  .data-table tbody td { padding: 10px 8px; font-size: 12px; }
  .cell-stack-primary { font-size: 12px; }
  .cell-stack-secondary { font-size: 10px; }
  .avatar { width: 28px; height: 28px; font-size: 10px; }
  .row-action-btn { padding: 3px 6px; font-size: 10px; margin: 0 1px; }
  
  /* Pagination compact */
  .pagination {
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
  }
  .pagination-info { font-size: 11px; }

  /* === SLIDE-OVER — Full width di mobile === */
  .slideover-panel {
    width: 100%;
    max-width: 100%;
  }
  .slideover-header { padding: 14px 16px; }
  .slideover-title { font-size: 18px; }
  .slideover-body { padding: 14px 16px; }
  .slideover-footer { padding: 12px 16px; gap: 6px; }
  .slideover-footer .btn { flex: 1; }

  /* === FORM SURAT - mobile === */
  .form-row { grid-template-columns: 1fr !important; gap: 8px !important; }
  .form-group { margin-bottom: 12px; }
  .form-group label { font-size: 11px; }
  .form-group input, .form-group select, .form-group textarea {
    padding: 8px 10px;
    font-size: 13px;
  }
  .form-actions {
    flex-direction: column-reverse;
    gap: 8px;
  }
  .form-actions .btn { width: 100%; justify-content: center; }

  /* === SOURCE PICKER mobile === */
  .source-picker-container {
    padding: 10px !important;
  }
  .source-picker-container > div:first-child {
    flex-direction: column !important;
    gap: 6px !important;
  }
  .source-picker-container label {
    width: 100%;
    justify-content: flex-start !important;
  }

  /* === BULK ACTIONS BAR mobile === */
  .bulk-actions-bar {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }
  .bulk-actions-buttons {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }
  .bulk-action-btn {
    flex: 1;
    min-width: 100px;
    text-align: center;
  }

  /* === FILTER CHIPS mobile === */
  .filter-chips {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 4px;
  }
  .filter-chips::-webkit-scrollbar { height: 4px; }
}

/* === BREAKPOINT: SMALL MOBILE (480px) === */
@media (max-width: 480px) {
  /* Stats jadi 1 kolom */
  .stats-row { grid-template-columns: 1fr; }
  
  .topbar-meta { display: none; } /* hide user info di small */
  .page-header h1 { font-size: 20px !important; }
  
  /* Login lebih compact */
  .login-headline h1 { font-size: 28px !important; }
}

/* === TOUCH TARGETS — iOS minimum 44px === */
@media (hover: none) and (pointer: coarse) {
  button, .btn, .pagination-btn, .row-action-btn, .sidebar-link, .filter-option, input[type="checkbox"] {
    min-height: 36px;
  }
  .btn, .pagination-btn {
    min-height: 40px;
  }
  /* Bigger checkbox for touch */
  input[type="checkbox"] { transform: scale(1.2); }
}
