/* ============================================================
   Dental CRM Blast - Design System
   Selaras dengan dashboard V2 (Inter, primary #df643f)
   ============================================================ */

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

:root {
  --sidebar-w: 236px;
  --bg: #f8f9fb;
  --bg-card: #ffffff;
  --bg-hover: #f8f9fb;
  --bg-subtle: #f1f5f9;
  --border: #e5e7eb;
  --border-light: #f0f1f3;
  --text: #1e293b;
  --text-dim: #64748b;
  --text-bright: #0f172a;
  --primary: #df643f;
  --primary-dark: #c44a28;
  --primary-light: rgba(223,100,63,0.08);
  --success: #10B981;
  --success-light: rgba(16,185,129,0.1);
  --danger: #EF4444;
  --danger-light: rgba(239,68,68,0.1);
  --warning: #F59E0B;
  --warning-light: rgba(245,158,11,0.1);
  --info: #06B6D4;
  --info-light: rgba(6,182,212,0.1);
  --purple: #8B5CF6;
  --purple-light: rgba(139,92,246,0.1);
  --c1: #df643f; --c2: #10B981; --c3: #F59E0B; --c4: #EC4899;
  --c5: #06B6D4; --c6: #8B5CF6; --c7: #F97316; --c8: #14B8A6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --sidebar-bg: #ffffff;
  --sidebar-border: #e5e7eb;
  --sidebar-hover: #f1f5f9;
  --sidebar-active: rgba(223,100,63,0.08);
}

[data-theme="dark"] {
  --bg: #0f1117;
  --bg-card: #1a1b23;
  --bg-hover: #22232d;
  --bg-subtle: #22232d;
  --border: #2a2b35;
  --border-light: #1f2029;
  --text: #cbd5e1;
  --text-dim: #7b8aa0;
  --text-bright: #f1f5f9;
  --primary-light: rgba(223,100,63,0.15);
  --success-light: rgba(16,185,129,0.15);
  --danger-light: rgba(239,68,68,0.15);
  --warning-light: rgba(245,158,11,0.15);
  --info-light: rgba(6,182,212,0.15);
  --purple-light: rgba(139,92,246,0.15);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.3);
  --sidebar-bg: #14151d;
  --sidebar-border: #2a2b35;
  --sidebar-hover: #1f2029;
  --sidebar-active: rgba(223,100,63,0.2);
}

html { font-size: 14px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100dvh; display: flex; overflow: hidden;
}

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  background: var(--sidebar-bg); border-right: 1px solid var(--sidebar-border);
  display: flex; flex-direction: column; height: 100dvh; z-index: 50;
  transition: width .25s ease, min-width .25s ease;
}
.sidebar.collapsed { width: 62px; min-width: 62px; }
.sidebar.collapsed .nav-label,
.sidebar.collapsed .brand-text,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .sidebar-foot { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.sidebar.collapsed .nav-item i { margin-right: 0; }

.sidebar-brand {
  padding: 18px 16px; display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border-light); min-height: 68px;
}
.brand-icon {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, #df643f, #c44a28);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 17px;
}
.brand-icon.custom-logo { background: none; overflow: hidden; }
.brand-icon.custom-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 9px; }
.brand-text { display: flex; flex-direction: column; overflow: hidden; }
.brand-name { font-weight: 700; font-size: 1rem; color: var(--text-bright); white-space: nowrap; }
.brand-tagline { font-size: .66rem; color: var(--text-dim); white-space: nowrap; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav-section-title {
  font-size: .66rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-dim); padding: 14px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 0; padding: 9px 12px; border-radius: 8px;
  color: var(--text-dim); font-size: .87rem; font-weight: 500; cursor: pointer;
  text-decoration: none; transition: all .15s; margin-bottom: 2px; border: 0; background: none;
  width: 100%; font-family: inherit;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--text); }
.nav-item.active { background: var(--sidebar-active); color: var(--primary); font-weight: 600; }
.nav-item i { font-size: 17px; margin-right: 11px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; font-size: .68rem; font-weight: 700; padding: 1px 7px;
  border-radius: 20px; background: var(--primary); color: #fff;
}
.sidebar-foot { padding: 12px; border-top: 1px solid var(--border-light); font-size: .72rem; color: var(--text-dim); }

/* ============ MAIN ============ */
.main { flex: 1; display: flex; flex-direction: column; height: 100dvh; overflow: hidden; min-width: 0; }
.topbar {
  height: 64px; min-height: 64px; display: flex; align-items: center; gap: 14px;
  padding: 0 22px; background: var(--bg-card); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.12rem; font-weight: 700; color: var(--text-bright); white-space: nowrap; }
.topbar .sub { font-size: .76rem; color: var(--text-dim); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.content { flex: 1; overflow-y: auto; padding: 20px 22px 40px; }

.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-dim); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 16px;
  transition: all .15s; font-family: inherit;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--primary); }

/* ============ CARDS ============ */
.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-head {
  padding: 14px 16px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 10px;
}
.card-head h2 { font-size: .93rem; font-weight: 700; color: var(--text-bright); }
.card-head .hint { font-size: .74rem; color: var(--text-dim); }
.card-body { padding: 16px; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g6 { grid-template-columns: repeat(6, minmax(0,1fr)); }
@media (max-width: 1400px) { .g6 { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 1100px) { .g4, .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 760px) { .g2, .g3, .g4, .g6 { grid-template-columns: 1fr; } }

/* ============ KPI ============ */
.kpi {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 15px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi::after {
  content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--primary); opacity: .85;
}
.kpi.k-success::after { background: var(--success); }
.kpi.k-warning::after { background: var(--warning); }
.kpi.k-danger::after { background: var(--danger); }
.kpi.k-info::after { background: var(--info); }
.kpi.k-purple::after { background: var(--purple); }
.kpi-label {
  font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-dim); display: flex; align-items: center; gap: 5px;
}
.kpi-value { font-size: 1.5rem; font-weight: 800; color: var(--text-bright); margin-top: 5px; line-height: 1.15; }
.kpi-sub { font-size: .72rem; color: var(--text-dim); margin-top: 3px; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text); font-size: .83rem; font-weight: 500;
  font-family: inherit; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: .77rem; border-radius: 6px; }
.btn-block { width: 100%; }

/* ============ FORMS ============ */
label.fl {
  display: block; font-size: .74rem; font-weight: 600; color: var(--text-dim);
  margin-bottom: 5px; text-transform: uppercase; letter-spacing: .03em;
}
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; padding: 8px 11px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text); font-size: .85rem; font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
textarea { resize: vertical; min-height: 70px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > .field { margin-bottom: 0; flex: 1; min-width: 130px; }
.check {
  display: inline-flex; align-items: center; gap: 7px; font-size: .82rem;
  color: var(--text); cursor: pointer; user-select: none;
}
.check input { width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer; }
.chip-group { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 5px 11px; border-radius: 20px; border: 1px solid var(--border);
  background: var(--bg-card); color: var(--text-dim); font-size: .78rem; cursor: pointer;
  transition: all .15s; font-family: inherit;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

/* ============ TABLE ============ */
.tbl-wrap { overflow: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .81rem; }
table.tbl th {
  text-align: left; padding: 9px 11px; font-size: .7rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim);
  border-bottom: 1px solid var(--border); background: var(--bg-subtle);
  position: sticky; top: 0; z-index: 2; white-space: nowrap;
}
table.tbl td { padding: 9px 11px; border-bottom: 1px solid var(--border-light); vertical-align: middle; }
table.tbl tbody tr:hover { background: var(--bg-hover); }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.tbl td.mono { font-family: ui-monospace, 'Cascadia Code', monospace; font-size: .78rem; }

/* ============ BADGES ============ */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 20px; font-size: .7rem; font-weight: 600; white-space: nowrap;
}
.b-gray { background: var(--bg-subtle); color: var(--text-dim); }
.b-success { background: var(--success-light); color: var(--success); }
.b-warning { background: var(--warning-light); color: #b45309; }
.b-danger { background: var(--danger-light); color: var(--danger); }
.b-info { background: var(--info-light); color: #0e7490; }
.b-purple { background: var(--purple-light); color: var(--purple); }
.b-primary { background: var(--primary-light); color: var(--primary); }
[data-theme="dark"] .b-warning { color: var(--warning); }
[data-theme="dark"] .b-info { color: var(--info); }

/* ============ MISC ============ */
.muted { color: var(--text-dim); }
.small { font-size: .76rem; }
.tiny { font-size: .7rem; }
.right { text-align: right; }
.center { text-align: center; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.flex { display: flex; } .between { justify-content: space-between; } .middle { align-items: center; }
.gap6 { gap: 6px; } .gap10 { gap: 10px; } .gap14 { gap: 14px; }
.wrap { flex-wrap: wrap; }
.hidden { display: none !important; }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.empty {
  padding: 40px 20px; text-align: center; color: var(--text-dim);
}
.empty i { font-size: 34px; opacity: .35; display: block; margin-bottom: 10px; }
.empty h3 { font-size: .95rem; color: var(--text); margin-bottom: 5px; }

.progress { height: 7px; border-radius: 20px; background: var(--bg-subtle); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); border-radius: 20px; transition: width .3s; }

/* ============ TOAST ============ */
#toasts { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 11px 16px; border-radius: 9px; font-size: .84rem; color: #fff;
  box-shadow: 0 6px 18px rgba(0,0,0,.18); max-width: 380px;
  display: flex; align-items: center; gap: 9px; animation: tin .25s ease;
}
.toast.success { background: #059669; } .toast.error { background: #dc2626; }
.toast.info { background: #0891b2; } .toast.warn { background: #d97706; }
@keyframes tin { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ============ MODAL ============ */
.modal-bg {
  position: fixed; inset: 0; background: rgba(15,23,42,.55); z-index: 9000;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: fade .15s ease;
}
.modal {
  background: var(--bg-card); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3);
  width: 100%; max-width: 640px; max-height: 88vh; overflow: auto;
}
.modal.wide { max-width: 900px; }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.modal-head h3 { font-size: 1rem; font-weight: 700; color: var(--text-bright); }
.modal-body { padding: 18px 20px; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ============ LOGIN ============ */
.login-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(circle at 20% 20%, var(--primary-light), transparent 55%), var(--bg);
}
.login-card {
  width: 100%; max-width: 380px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 16px; padding: 30px 26px; box-shadow: var(--shadow-md);
}
.login-logo {
  width: 46px; height: 46px; border-radius: 12px; margin-bottom: 16px;
  background: linear-gradient(135deg, #df643f, #c44a28);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 22px;
}
.login-logo.custom-logo { background: none; overflow: hidden; }
.login-logo.custom-logo img { width: 100%; height: 100%; object-fit: contain; border-radius: 12px; }

/* ============ FUNNEL ============ */
.funnel-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.funnel-label { width: 92px; font-size: .78rem; color: var(--text-dim); flex-shrink: 0; }
.funnel-bar-wrap { flex: 1; background: var(--bg-subtle); border-radius: 6px; height: 26px; overflow: hidden; }
.funnel-bar {
  height: 100%; background: linear-gradient(90deg, var(--primary), #f0876a);
  border-radius: 6px; display: flex; align-items: center; padding: 0 9px;
  color: #fff; font-size: .75rem; font-weight: 700; min-width: 34px;
  transition: width .5s ease;
}
.funnel-val { width: 96px; text-align: right; font-size: .8rem; font-weight: 700; flex-shrink: 0; }

/* ============ SEGMEN CARD ============ */
.seg-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px;
  background: var(--bg-card); border-left: 3px solid var(--primary);
}
.seg-name { font-size: .78rem; font-weight: 700; color: var(--text-bright); }
.seg-val { font-size: 1.15rem; font-weight: 800; margin-top: 2px; }
.seg-meta { font-size: .7rem; color: var(--text-dim); margin-top: 2px; }

/* ============ STEP WIZARD ============ */
.steps { display: flex; gap: 6px; margin-bottom: 18px; flex-wrap: wrap; }
.step {
  display: flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 8px;
  background: var(--bg-subtle); color: var(--text-dim); font-size: .8rem; font-weight: 600;
}
.step .n {
  width: 20px; height: 20px; border-radius: 50%; background: var(--border);
  display: flex; align-items: center; justify-content: center; font-size: .7rem; color: var(--text);
}
.step.on { background: var(--primary-light); color: var(--primary); }
.step.on .n { background: var(--primary); color: #fff; }
.step.done { background: var(--success-light); color: var(--success); }
.step.done .n { background: var(--success); color: #fff; }

/* ============ PAGINATION ============ */
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 12px 4px; }
.pager .pg { font-size: .8rem; color: var(--text-dim); }

/* ============ MULTISELECT ============ */
.multiselect { position: relative; }
.ms-box {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 36px;
  padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-card); cursor: pointer; font-size: .82rem; user-select: none;
}
.ms-box:hover { border-color: var(--primary); }
.ms-box.focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.ms-box .ms-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-box .ms-caret { font-size: 12px; color: var(--text-dim); }
.ms-panel {
  position: absolute; z-index: 7000; top: calc(100% + 4px); left: 0; min-width: 230px; max-width: 320px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-md); overflow: hidden;
}
.ms-search-wrap { padding: 8px 8px 0; }
.ms-search {
  width: 100%; padding: 6px 9px; border: 1px solid var(--border); border-radius: 6px;
  font-size: .8rem; font-family: inherit; background: var(--bg);
}
.ms-actions { display: flex; gap: 6px; padding: 6px 8px; border-bottom: 1px solid var(--border-light); }
.ms-actions button {
  border: 0; background: none; color: var(--primary); font-size: .74rem; font-weight: 600;
  cursor: pointer; padding: 3px 6px; border-radius: 5px; font-family: inherit;
}
.ms-actions button:hover { background: var(--primary-light); }
.ms-list { max-height: 250px; overflow: auto; padding: 4px; }
.ms-opt {
  display: flex; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 6px;
  font-size: .8rem; cursor: pointer;
}
.ms-opt:hover { background: var(--bg-hover); }
.ms-opt input { width: 14px; height: 14px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }
.ms-opt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-group {
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-dim); padding: 7px 8px 3px;
}
.ms-empty { padding: 10px; text-align: center; }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

@media print { .sidebar, .topbar-right, .btn { display: none !important; } }
