/* ==========================================
   DESIGN TOKENS — CRM Surya Madina
   ========================================== */
:root {
  /* Warna */
  --bg: #F5F7F6;
  --surface: #FFFFFF;
  --surface-muted: #F0F3F2;
  --border: #E3E8E6;

  --ink: #1B2320;
  --ink-muted: #667169;
  --ink-faint: #97A19B;

  --primary: #1B4B43;
  --primary-hover: #123A33;
  --primary-tint: #E8F0EE;

  --gold: #C79A2E;
  --gold-tint: #FBF3DF;

  --hot: #DC2626;      --hot-tint: #FDECEC;
  --warm: #C79A2E;      --warm-tint: #FBF3DF;
  --cold: #0E7490;     --cold-tint: #E6F4F7;
  --hold: #6B7280;     --hold-tint: #F0F1F2;
  --closing: #15803D;  --closing-tint: #E9F7EE;
  --lost: #44403C;     --lost-tint: #F1F0EE;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --shadow-sm: 0 1px 2px rgba(20, 30, 27, 0.06);
  --shadow-md: 0 8px 24px rgba(20, 30, 27, 0.08);
  --shadow-lg: 0 20px 48px rgba(20, 30, 27, 0.14);

  --font-display: 'Plus Jakarta Sans', 'Inter', sans-serif;
  --font-body: 'Inter', sans-serif;

  --sidebar-w: 252px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); margin: 0; color: var(--ink); }

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

button { font-family: var(--font-body); cursor: pointer; }

::selection { background: var(--gold-tint); }

/* Focus visibility (a11y) */
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ==========================================
   LAYOUT PRIMITIVES
   ========================================== */
.container-page { max-width: 1320px; margin: 0 auto; padding: 32px 24px 64px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.card-pad { padding: 22px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.flex { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }

.text-muted { color: var(--ink-muted); }
.text-faint { color: var(--ink-faint); }

/* ==========================================
   GATEWAY (Executive Overview)
   ========================================== */
.gateway-hero {
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 15% -10%, #E8F0EE 0%, transparent 60%),
    var(--bg);
}

.gateway-topline {
  display: flex; align-items: center; gap: 14px;
  padding: 40px 0 8px;
}

.brand-mark {
  width: 46px; height: 46px; border-radius: 12px;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; font-size: 18px;
  flex-shrink: 0;
}

.eyebrow {
  font-family: var(--font-display); font-weight: 600; font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--gold);
  margin-bottom: 2px;
}

.metric-hero {
  border-radius: var(--radius-lg);
  padding: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.metric-hero.is-primary { background: var(--primary); color: white; border: none; }
.metric-hero.is-primary .metric-hero-label { color: rgba(255,255,255,0.72); }
.metric-hero-label { font-size: 12.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); margin-bottom: 10px; }
.metric-hero-value { font-family: var(--font-display); font-size: 40px; font-weight: 700; line-height: 1; }
.metric-hero-value.gold { color: var(--gold); }

.branch-picker { display: flex; flex-direction: column; gap: 10px; }
.branch-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: var(--font-display); font-weight: 600; font-size: 14.5px;
  color: var(--ink);
  transition: border-color .15s ease, transform .15s ease, background .15s ease;
  text-align: left;
  width: 100%;
}
.branch-btn:hover { border-color: var(--primary); background: var(--primary-tint); transform: translateX(3px); }
.branch-btn .icon-box {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--primary-tint); color: var(--primary);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.branch-btn .arrow { margin-left: auto; color: var(--ink-faint); }

/* ==========================================
   APP SHELL (Sidebar + Topbar)
   ========================================== */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--primary);
  color: rgba(255,255,255,0.86);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  padding: 22px 20px 18px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-brand .brand-name { font-family: var(--font-display); font-weight: 700; color: white; font-size: 15px; }
.sidebar-brand .brand-sub { font-size: 11.5px; color: rgba(255,255,255,0.55); }

.nav-menu { padding: 16px 12px; flex-grow: 1; overflow-y: auto; }
.nav-section-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255,255,255,0.4); padding: 14px 10px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500;
  color: rgba(255,255,255,0.72);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.nav-link:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-link.active { background: white; color: var(--primary); font-weight: 600; }
.nav-link svg { width: 17px; height: 17px; flex-shrink: 0; }

.nav-link.nav-sheet { background: rgba(199,154,46,0.18); color: var(--gold); margin-top: 8px; }
.nav-link.nav-sheet:hover { background: rgba(199,154,46,0.3); color: var(--gold); }

.sidebar-footer { padding: 14px; border-top: 1px solid rgba(255,255,255,0.1); }
.btn-ghost-danger {
  width: 100%; padding: 9px; border-radius: var(--radius-sm);
  background: transparent; border: 1px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.75); font-size: 12.5px; font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-ghost-danger:hover { border-color: #f87171; color: #fca5a5; }

.main-area { flex-grow: 1; min-width: 0; }
.topbar {
  height: 62px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; padding: 0 26px;
  position: sticky; top: 0; z-index: 5;
}
.topbar-title { font-family: var(--font-display); font-weight: 700; font-size: 15.5px; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--surface-muted); border: 1px solid var(--border); color: var(--ink-muted);
}

/* ==========================================
   BUTTONS
   ========================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; border: 1px solid transparent;
  transition: transform .1s ease, background .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-gold { background: var(--gold); color: #2A2005; }
.btn-gold:hover { filter: brightness(1.05); }
.btn-outline { background: var(--surface); border-color: var(--border); color: var(--ink); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger-outline { background: var(--surface); border-color: var(--border); color: var(--hot); }
.btn-danger-outline:hover { background: var(--hot-tint); border-color: var(--hot); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-icon { padding: 8px; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ==========================================
   FORMS
   ========================================== */
label.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-muted); margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; font-size: 13.5px; font-family: var(--font-body);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-muted); color: var(--ink);
  transition: border-color .15s ease, background .15s ease;
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: none; border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-tint);
}
.field-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 720px) { .field-row { grid-template-columns: 1fr; } }
.field-row.cols-2 { grid-template-columns: repeat(2, 1fr); }

/* ==========================================
   TABLES
   ========================================== */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
  text-align: left; font-weight: 600; color: var(--ink-muted);
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface-muted); white-space: nowrap;
  font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em;
}
table.data-table td { padding: 14px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data-table tbody tr { transition: background .12s ease; }
table.data-table tbody tr:hover { background: var(--surface-muted); }
table.data-table tbody tr:last-child td { border-bottom: none; }

/* ==========================================
   BADGES / STATUS
   ========================================== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
}
.badge-hot { background: var(--hot-tint); color: var(--hot); }
.badge-warm { background: var(--warm-tint); color: var(--warm); }
.badge-cold { background: var(--cold-tint); color: var(--cold); }
.badge-hold { background: var(--hold-tint); color: var(--hold); }
.badge-closing { background: var(--closing-tint); color: var(--closing); }
.badge-lost { background: var(--lost-tint); color: var(--lost); }
.badge-neutral { background: var(--surface-muted); color: var(--ink-muted); border: 1px solid var(--border); }

.lead-row-quality { border-left: 3px solid transparent; }
.lead-row-quality.q-hot { border-left-color: var(--hot); }
.lead-row-quality.q-warm { border-left-color: var(--warm); }
.lead-row-quality.q-cold { border-left-color: var(--cold); }
.lead-row-quality.q-hold { border-left-color: var(--hold); }

/* ==========================================
   MODAL (custom, lightweight)
   ========================================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(19, 26, 23, 0.5);
  display: none; align-items: center; justify-content: center; z-index: 100;
  padding: 20px; backdrop-filter: blur(2px);
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: var(--surface); border-radius: var(--radius-lg);
  width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .18s ease;
}
.modal-box.modal-lg { max-width: 720px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; }
.modal-header h3 { font-size: 16.5px; }
.modal-close { width: 30px; height: 30px; border-radius: 8px; border: none; background: var(--surface-muted); color: var(--ink-muted); font-size: 16px; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: var(--hot-tint); color: var(--hot); }
.modal-body { padding: 18px 24px 24px; }
.modal-footer { display: flex; justify-content: space-between; align-items: center; padding: 0 24px 22px; gap: 10px; }
.modal-footer.end { justify-content: flex-end; }

/* ==========================================
   EMPTY STATES & SKELETONS
   ========================================== */
.empty-state { text-align: center; padding: 64px 20px; color: var(--ink-muted); }
.empty-state .icon { font-size: 34px; margin-bottom: 10px; opacity: 0.5; }
.empty-state h4 { font-size: 14.5px; margin-bottom: 4px; color: var(--ink); }
.empty-state p { font-size: 13px; margin: 0; }

@keyframes shimmer { 0% { background-position: -600px 0; } 100% { background-position: 600px 0; } }
.skel {
  background: linear-gradient(90deg, #EEF1F0 25%, #E4E9E7 37%, #EEF1F0 63%);
  background-size: 600px 100%; animation: shimmer 1.4s infinite linear;
  border-radius: 8px;
}
.skel-line { height: 14px; margin-bottom: 8px; }
.skel-card { height: 88px; border-radius: var(--radius-md); }
.skel-chart { height: 210px; border-radius: var(--radius-md); }

/* ==========================================
   TOASTS
   ========================================== */
#toast-container { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 600; color: white;
  box-shadow: var(--shadow-md);
  animation: toastIn .3s cubic-bezier(.2,.9,.3,1.2);
  min-width: 240px;
}
.toast.success { background: var(--closing); }
.toast.danger { background: var(--hot); }
.toast.hide { animation: toastOut .3s ease forwards; }
@keyframes toastIn { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes toastOut { to { transform: translateY(16px); opacity: 0; } }

/* ==========================================
   MISC UTIL
   ========================================== */
.pulse-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--closing);
  box-shadow: 0 0 0 0 rgba(21,128,61,0.55); animation: pulse 1.8s infinite; display: inline-block;
}
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(21,128,61,0); } 100% { box-shadow: 0 0 0 0 rgba(21,128,61,0); } }

.hidden { display: none !important; }

.d-flex-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.filter-bar {
  background: var(--surface-muted); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px 16px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  margin-bottom: 20px;
}

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; justify-content: space-between; padding: 11px 4px; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }

.search-box { position: relative; }
.search-box input { padding-left: 34px; }
.search-box .icn { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-faint); }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; overflow-x: auto; }
  .sidebar-brand { display: none; }
  .nav-menu { display: flex; padding: 10px; flex-grow: 0; }
  .nav-section-label { display: none; }
  .sidebar-footer { display: none; }
  .container-page { padding: 20px 16px 48px; }
}
