/* =====================================================================
   SI-SURAT — Persuratan Digital · UI minimalis (putih + navy + aksen biru)
   ===================================================================== */
:root {
  --navy: #0f2557;
  --navy-2: #1e3a8a;
  --blue: #2563eb;
  --blue-600: #1d4ed8;
  --blue-50: #eff4ff;
  --blue-100: #dbe6fe;
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e5e9f0;
  --border-2: #d6dce6;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #64748b;
  --green: #16a34a; --green-bg: #e9f8ef;
  --amber: #b45309; --amber-bg: #fef4e2;
  --red: #dc2626; --red-bg: #fdecec;
  --violet: #7c3aed; --violet-bg: #f1ebfe;
  --indigo: #4338ca; --indigo-bg: #eceefe;
  --slate: #334155; --slate-bg: #eef1f5;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px -8px rgba(15, 23, 42, .18);
  --sb-w: 240px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
html.dark {
  --bg: #0b1120; --surface: #111a2e; --surface-2: #0f172a; --border: #1e2a44; --border-2: #2a3a5c;
  --text: #e5ecf7; --text-2: #b6c2d6; --muted: #8191ab; --blue-50: #13234a; --blue-100: #1b2f62;
  --green-bg: #0f2a1d; --amber-bg: #2b2111; --red-bg: #2e1517; --violet-bg: #231a3d; --indigo-bg: #1b1e45; --slate-bg: #1a2336;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 16px 40px -8px rgba(0, 0, 0, .6);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14.5px; line-height: 1.55; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-600); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
svg.lucide { width: 18px; height: 18px; stroke-width: 1.9; flex-shrink: 0; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, Consolas, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.center { text-align: center; }
[hidden] { display: none !important; }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--sb-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40; transition: width .22s ease, transform .22s ease; }
.main { flex: 1; margin-left: var(--sb-w); min-width: 0; transition: margin-left .22s ease; }
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; }
.sb-logo { width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; }
.sb-brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.sb-brand-text strong { color: var(--navy); font-size: 15.5px; letter-spacing: .02em; }
html.dark .sb-brand-text strong { color: #fff; }
.sb-brand-text span { color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: .01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-brand-text strong { white-space: nowrap; }
.sb-collapse { margin-left: auto; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; display: flex; }
.sb-collapse:hover { background: var(--surface-2); color: var(--text); }
.sb-nav { flex: 1; padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.sb-link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 9px; color: var(--text-2); font-weight: 500; position: relative; transition: background .15s, color .15s; }
.sb-link:hover { background: var(--surface-2); color: var(--text); }
.sb-link.active { background: var(--blue-50); color: var(--blue); }
.sb-link.active svg { color: var(--blue); }
.sb-badge { margin-left: auto; background: var(--blue); color: #fff; font-size: 11px; font-weight: 600; min-width: 20px; height: 20px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px; }
.sb-user { border-top: 1px solid var(--border); padding: 10px 12px; position: relative; }
.sb-user-btn { width: 100%; display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 8px; border-radius: 10px; cursor: pointer; color: inherit; text-align: left; font: inherit; }
.sb-user-btn:hover { background: var(--surface-2); }
.sb-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sb-user-text strong { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-text small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-caret { margin-left: auto; color: var(--muted); }
.sb-overlay { display: none; }

html.collapsed { --sb-w: 72px; }
html.collapsed .sb-brand-text, html.collapsed .sb-label, html.collapsed .sb-user-text, html.collapsed .sb-user-caret { display: none; }
html.collapsed .sb-brand { flex-direction: column; padding: 16px 0 10px; }
html.collapsed .sb-collapse { margin: 6px 0 0; transform: scaleX(-1); }
html.collapsed .sb-link { justify-content: center; padding: 11px; }
html.collapsed .sb-badge { position: absolute; top: 3px; right: 6px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
html.collapsed .sb-link:hover::after { content: attr(data-tip); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); background: var(--navy); color: #fff; padding: 5px 10px; border-radius: 6px; font-size: 12.5px; white-space: nowrap; z-index: 60; box-shadow: var(--shadow-lg); }
html.collapsed .sb-user-btn { justify-content: center; }

.topbar { height: 64px; display: flex; align-items: center; gap: 12px; padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 30; }
.tb-title { min-width: 0; }
.tb-title h1 { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-title p { color: var(--muted); font-size: 12.5px; }
.tb-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.tb-search { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 0 12px; height: 38px; width: 300px; color: var(--muted); }
.tb-search input { border: 0; background: none; outline: none; font: inherit; color: var(--text); width: 100%; }
.content { padding: 26px 28px 48px; max-width: 1400px; }

/* ---------- Komponen ---------- */
.icon-btn { width: 38px; height: 38px; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.dot-badge { position: absolute; top: -5px; right: -5px; background: var(--red); color: #fff; font-size: 10.5px; font-weight: 600; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px; border: 2px solid var(--surface); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 16px; border-radius: 9px; border: 1px solid transparent; font: inherit; font-weight: 500; font-size: 14px; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, opacity .15s; text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-600); color: #fff; }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-2); color: #fff; }
.btn-outline { background: var(--surface); border-color: var(--border-2); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #b91c1c; color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }
.btn-soft { background: var(--blue-50); color: var(--blue); }
.btn-soft:hover { background: var(--blue-100); color: var(--blue-600); }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn-xs { height: 28px; padding: 0 9px; font-size: 12.5px; border-radius: 7px; }
.btn-icon { width: 32px; padding: 0; }
.btn[disabled], .btn.loading { opacity: .6; pointer-events: none; }
.btn.loading::before { content: ''; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link { background: none; border: 0; color: var(--blue); cursor: pointer; font: inherit; font-size: 13px; padding: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; }
.card-head p { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h2 { font-size: 20px; }
.page-head p { color: var(--muted); margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mt { margin-top: 18px; } .mt-sm { margin-top: 10px; } .mb { margin-bottom: 18px; }

.stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-ico { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--blue-50); color: var(--blue); }
.stat-ico.green { background: var(--green-bg); color: var(--green); }
.stat-ico.amber { background: var(--amber-bg); color: var(--amber); }
.stat-ico.violet { background: var(--violet-bg); color: var(--violet); }
.stat-ico.red { background: var(--red-bg); color: var(--red); }
.stat-ico.slate { background: var(--slate-bg); color: var(--slate); }
html.dark .stat-ico.slate { color: var(--text-2); }
.stat-num { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1; color: var(--text); }
.stat-label { color: var(--muted); font-size: 13px; }
.trend { font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 20px; }
.trend svg { width: 13px; height: 13px; }
.trend.up { color: var(--green); background: var(--green-bg); }
.trend.down { color: var(--red); background: var(--red-bg); }
.trend.flat { color: var(--muted); background: var(--surface-2); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 500; white-space: nowrap; line-height: 1.6; }
.badge-gray { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge-blue { background: var(--blue-50); color: var(--blue); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-amber { background: var(--amber-bg); color: var(--amber); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-violet { background: var(--violet-bg); color: var(--violet); }
.badge-indigo { background: var(--indigo-bg); color: var(--indigo); }
.badge-slate { background: var(--slate-bg); color: var(--slate); }
html.dark .badge-indigo { color: #a5b4fc; } html.dark .badge-violet { color: #c4b5fd; } html.dark .badge-slate { color: var(--text-2); } html.dark .badge-amber { color: #fbbf24; } html.dark .badge-blue { color: #93b4ff; }

/* ---------- Tabel ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr.unread td { background: color-mix(in srgb, var(--blue-50) 55%, transparent); }
.table tr.unread .t-title { font-weight: 600; }
.t-title { color: var(--text); font-weight: 500; display: block; }
a.t-title:hover { color: var(--blue); }
.t-sub { color: var(--muted); font-size: 12.5px; display: block; margin-top: 1px; }
.t-actions { display: flex; gap: 4px; justify-content: flex-end; }
.star { color: #f59e0b; }
.star svg { fill: #f59e0b; width: 15px; height: 15px; }

/* ---------- Tab ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button { padding: 10px 14px; color: var(--muted); font-weight: 500; border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; font: inherit; font-weight: 500; display: inline-flex; gap: 7px; align-items: center; }
.tabs a:hover, .tabs button:hover { color: var(--text); }
.tabs .active { color: var(--blue); border-bottom-color: var(--blue); }
.tabs .count { background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-size: 11.5px; padding: 0 7px; border-radius: 10px; }
.tabs .active .count { background: var(--blue-50); border-color: transparent; color: var(--blue); }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg a, .seg button { padding: 6px 14px; border-radius: 7px; color: var(--muted); font-weight: 500; font-size: 13.5px; border: 0; background: none; cursor: pointer; font-family: inherit; }
.seg .active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Form ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.req::after { content: ' *'; color: var(--red); }
.input, .select, .textarea { width: 100%; height: 40px; border: 1px solid var(--border-2); border-radius: 9px; background: var(--surface); color: var(--text); padding: 0 12px; font: inherit; font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s; }
.textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 15%, transparent); }
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--red); }
.input-sm { height: 34px; font-size: 13.5px; }
.hint { font-size: 12px; color: var(--muted); }
.error-text { font-size: 12px; color: var(--red); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.check input { width: 16px; height: 16px; accent-color: var(--blue); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 11px; background: var(--border-2); position: relative; transition: background .2s; flex-shrink: 0; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--blue); }
.switch input:checked + .track::after { transform: translateX(16px); }
.dropzone { border: 1.5px dashed var(--border-2); border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .15s, background .15s; background: var(--surface-2); }
.dropzone:hover, .dropzone.drag { border-color: var(--blue); background: var(--blue-50); }
.dropzone strong { color: var(--text); display: block; margin: 6px 0 2px; font-weight: 500; }
.dropzone svg { width: 26px; height: 26px; color: var(--blue); }
.file-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; text-align: left; }
.file-chip { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); font-size: 13px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; padding: 14px 16px; border-bottom: 1px solid var(--border); align-items: center; }
.filters .input, .filters .select { height: 36px; font-size: 13.5px; width: auto; min-width: 140px; }
.filters .search { position: relative; flex: 1; min-width: 220px; }
.filters .search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; }
.filters .search .input { padding-left: 34px; width: 100%; }

/* ---------- Dropdown, modal, toast ---------- */
.dropdown { position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; display: none; z-index: 70; }
.dropdown.open { display: block; animation: pop .14s ease; }
.dropdown a, .dropdown button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px; color: var(--text); background: none; border: 0; font: inherit; font-size: 13.5px; cursor: pointer; text-align: left; }
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); }
.dropdown .danger { color: var(--red); }
.dropdown form { margin: 0; }
.dropdown-up { bottom: calc(100% - 4px); left: 12px; right: 12px; }
html.collapsed .dropdown-up { left: 8px; right: auto; width: 200px; }
.notif-wrap { position: relative; }
.notif-menu { right: 0; top: 46px; width: 360px; padding: 0; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-list { max-height: 380px; overflow-y: auto; }
.notif-item { display: flex !important; gap: 10px; padding: 11px 14px !important; border-radius: 0 !important; border-bottom: 1px solid var(--border) !important; align-items: flex-start !important; }
.notif-item.unread { background: color-mix(in srgb, var(--blue-50) 60%, transparent); }
.notif-item .ni-ico { width: 30px; height: 30px; border-radius: 8px; background: var(--blue-50); color: var(--blue); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-item .ni-ico svg { width: 15px; height: 15px; }
.notif-item strong { display: block; font-size: 13px; font-weight: 600; }
.notif-item span { display: block; color: var(--muted); font-size: 12.5px; }
.notif-empty { padding: 26px; text-align: center; color: var(--muted); font-size: 13px; }
.notif-foot { display: block !important; text-align: center !important; padding: 10px !important; color: var(--blue) !important; font-size: 13px; justify-content: center !important; }
@keyframes pop { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .15s; }
.modal-box { background: var(--surface); border-radius: 16px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg); max-height: calc(100vh - 40px); overflow-y: auto; animation: pop .18s ease; }
.modal-box.modal-sm { max-width: 400px; padding: 24px; text-align: center; }
.modal-box.modal-lg { max-width: 900px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.modal-ico { width: 48px; height: 48px; border-radius: 50%; background: var(--red-bg); color: var(--red); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.modal-sm h3 { font-size: 17px; margin-bottom: 6px; }
.modal-actions { display: flex; gap: 8px; justify-content: center; margin-top: 20px; }
@keyframes fade { from { opacity: 0; } }
.toasts { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { display: flex; align-items: flex-start; gap: 10px; min-width: 280px; max-width: 400px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--blue); border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow-lg); font-size: 13.5px; animation: slidein .25s ease; }
.toast.success { border-left-color: var(--green); } .toast.success svg { color: var(--green); }
.toast.error { border-left-color: var(--red); } .toast.error svg { color: var(--red); }
.toast.warning { border-left-color: #f59e0b; } .toast.warning svg { color: #f59e0b; }
.toast.info svg { color: var(--blue); }
.toast.hide { opacity: 0; transform: translateX(20px); transition: all .25s; }
@keyframes slidein { from { opacity: 0; transform: translateX(30px); } }

/* ---------- State ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-ico { width: 56px; height: 56px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.empty-ico svg { width: 24px; height: 24px; }
.empty h4 { color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty p { max-width: 380px; margin: 0 auto 16px; font-size: 13.5px; }
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: 10px; font-size: 13.5px; align-items: flex-start; border: 1px solid; }
.alert svg { margin-top: 1px; }
.alert-info { background: var(--blue-50); border-color: var(--blue-100); color: var(--navy); } html.dark .alert-info { color: var(--text); }
.alert-warning { background: var(--amber-bg); border-color: color-mix(in srgb, var(--amber) 25%, transparent); color: var(--amber); }
.alert-danger { background: var(--red-bg); border-color: color-mix(in srgb, var(--red) 25%, transparent); color: var(--red); }
.alert-success { background: var(--green-bg); border-color: color-mix(in srgb, var(--green) 25%, transparent); color: var(--green); }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- List & timeline ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; align-items: center; padding: 12px 20px; border-bottom: 1px solid var(--border); color: inherit; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--surface-2); color: inherit; }
.li-ico { width: 34px; height: 34px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; color: var(--text-2); flex-shrink: 0; }
.li-ico svg { width: 16px; height: 16px; }
.li-main { flex: 1; min-width: 0; }
.li-main strong { display: block; font-weight: 500; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-main span { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ''; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { position: absolute; left: -26px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border-2); }
.tl-item.done .tl-dot { border-color: var(--blue); background: var(--blue); box-shadow: inset 0 0 0 3px var(--surface); }
.tl-item.todo { opacity: .55; }
.tl-item strong { font-size: 13.5px; font-weight: 600; display: block; }
.tl-item span { color: var(--muted); font-size: 12.5px; }
.tl-item p { font-size: 13.5px; margin-top: 4px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.meta { display: grid; grid-template-columns: 150px 1fr; gap: 10px 14px; font-size: 14px; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; color: var(--text); word-break: break-word; }
.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; padding: 16px; }
.quick a { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); font-weight: 500; font-size: 13.5px; transition: border-color .15s, background .15s; }
.quick a:hover { border-color: var(--blue); background: var(--blue-50); color: var(--blue); }
.quick a svg { color: var(--blue); }
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 220px; }

/* ---------- Editor surat ---------- */
.editor-layout { display: grid; grid-template-columns: minmax(380px, 1fr) minmax(0, 1.1fr); gap: 18px; align-items: start; }
.editor-panel { display: flex; flex-direction: column; gap: 18px; }
.preview-panel { position: sticky; top: 82px; }
.preview-scroll { background: #e9edf3; border-radius: var(--radius); border: 1px solid var(--border); padding: 18px; overflow: auto; max-height: calc(100vh - 150px); }
html.dark .preview-scroll { background: #0a1020; }
.preview-scale { transform-origin: top left; }
.paper-shadow { box-shadow: 0 4px 18px rgba(15,23,42,.16); }
.rte { border: 1px solid var(--border-2); border-radius: 10px; overflow: hidden; background: var(--surface); }
.rte-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--border); background: var(--surface-2); align-items: center; }
.rte-bar button { width: 30px; height: 30px; border: 0; background: none; border-radius: 6px; color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.rte-bar button:hover, .rte-bar button.on { background: var(--surface); color: var(--blue); box-shadow: var(--shadow); }
.rte-bar button svg { width: 16px; height: 16px; }
.rte-bar select { height: 30px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--text); font: inherit; font-size: 12.5px; padding: 0 6px; }
.rte-sep { width: 1px; height: 20px; background: var(--border-2); margin: 0 4px; }
.rte-area { min-height: 300px; max-height: 560px; overflow-y: auto; padding: 16px 18px; outline: none; font-family: 'Times New Roman', serif; font-size: 15px; line-height: 1.6; color: #111; background: #fff; }
html.dark .rte-area { background: #fdfdfd; }
.rte-area table { border-collapse: collapse; width: 100%; }
.rte-area td, .rte-area th { border: 1px dashed #c3cad6; padding: 4px 6px; min-width: 30px; }
.rte-area p { margin: 0 0 6px; }
.rte-area img { max-width: 100%; }
.save-state { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.save-state .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); }
.save-state.saving .dot { background: #f59e0b; }
.save-state.error .dot { background: var(--red); }
.number-preview { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--surface-2); border: 1px dashed var(--border-2); border-radius: 8px; padding: 8px 12px; font-size: 13.5px; color: var(--navy); }
html.dark .number-preview { color: #93b4ff; }
.mobile-switch { display: none; }
.ph-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ph-chips button { font: 12px ui-monospace, Menlo, monospace; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); border-radius: 6px; padding: 3px 7px; cursor: pointer; }
.ph-chips button:hover { border-color: var(--blue); color: var(--blue); }
.sig-preview { border: 1px dashed var(--border-2); border-radius: 10px; padding: 16px; background: #fff; color: #000; font-family: 'Times New Roman', serif; text-align: center; width: 300px; max-width: 100%; }
.img-box { width: 150px; height: 100px; border: 1px dashed var(--border-2); border-radius: 10px; display: flex; align-items: center; justify-content: center; background: #fff; overflow: hidden; }
.img-box img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- Login ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 36px 32px; box-shadow: var(--shadow); }
.auth-brand { text-align: center; margin-bottom: 26px; }
.auth-brand img { width: 56px; height: 56px; margin-bottom: 12px; }
.auth-brand h1 { font-size: 22px; color: var(--navy); letter-spacing: .02em; }
html.dark .auth-brand h1 { color: #fff; }
.auth-brand p { color: var(--muted); font-size: 13.5px; }
.auth-brand .school { margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); letter-spacing: .03em; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 42px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px; display: flex; }
.auth-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: 22px; }

.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 600; flex-shrink: 0; object-fit: cover; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 64px; height: 64px; font-size: 20px; }
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.kv-mini { display: flex; gap: 18px; flex-wrap: wrap; }
.kv-mini div { display: flex; flex-direction: column; }
.kv-mini span { font-size: 12px; color: var(--muted); }
.kv-mini strong { font-size: 14px; font-weight: 600; }
.progress { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: var(--blue); border-radius: 3px; }
.settings-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 22px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: 82px; }
.settings-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: var(--text-2); font-weight: 500; font-size: 13.5px; }
.settings-nav a:hover { background: var(--surface); color: var(--text); }
.settings-nav a.active { background: var(--surface); color: var(--blue); box-shadow: var(--shadow); border: 1px solid var(--border); }
.settings-nav svg { width: 16px; height: 16px; }
.pdf-frame { width: 100%; height: 72vh; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.img-preview { max-width: 100%; border: 1px solid var(--border); border-radius: 10px; }

/* ---------- Responsif ---------- */
.only-mobile { display: none; }
@media (max-width: 1180px) {
  .grid-main { grid-template-columns: 1fr; }
  .editor-layout { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
  .mobile-switch { display: inline-flex; margin-bottom: 14px; }
  .editor-layout[data-view="form"] .preview-panel { display: none; }
  .editor-layout[data-view="preview"] .editor-panel { display: none; }
}
@media (max-width: 960px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .settings-nav a { white-space: nowrap; }
}
@media (max-width: 860px) {
  :root, html.collapsed { --sb-w: 250px; }
  html.collapsed .sb-brand-text, html.collapsed .sb-label, html.collapsed .sb-user-text, html.collapsed .sb-user-caret { display: initial; }
  html.collapsed .sb-brand { flex-direction: row; padding: 18px 16px 14px; }
  html.collapsed .sb-link { justify-content: flex-start; padding: 9px 12px; }
  html.collapsed .sb-badge { position: static; }
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .sb-overlay.open { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 35; }
  .sb-collapse { display: none; }
  .main { margin-left: 0; }
  .only-mobile { display: inline-flex; }
  .hide-mobile { display: none !important; }
  .topbar { padding: 0 16px; }
  .content { padding: 18px 16px 40px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .meta { grid-template-columns: 1fr; gap: 2px; }
  .meta dd { margin-bottom: 10px; }
  .notif-menu { position: fixed; left: 12px; right: 12px; top: 60px; width: auto; }
  .table th, .table td { padding: 11px 12px; }
  .hide-sm { display: none; }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .toast { max-width: none; }
}
@media print {
  .sidebar, .topbar, .no-print, .toasts { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  body { background: #fff; }
}
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; flex-wrap: wrap; font-size: 13px; }
.pager { display: flex; gap: 4px; }
.pg { min-width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; border: 1px solid var(--border); color: var(--text-2); font-size: 13px; padding: 0 8px; background: var(--surface); }
.pg svg { width: 15px; height: 15px; }
a.pg:hover { border-color: var(--blue); color: var(--blue); }
.pg.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.pg.disabled { opacity: .4; }
.pg.dots { border: 0; background: none; }

/* ===== Perbaikan tampilan (v1.1) ===== */
.sb-brand { padding: 18px 18px 16px; gap: 11px; }
.sb-brand-text strong { font-size: 16px; line-height: 1.2; }
.sb-brand-text span { white-space: normal; overflow: visible; text-overflow: clip; font-size: 10.5px; line-height: 1.3; margin-top: 2px; letter-spacing: .02em; }
.sb-logo { width: 36px; height: 36px; }
.topbar .sb-collapse { margin: 0; padding: 0; width: 38px; height: 38px; transform: none; }
html.collapsed .topbar .sb-collapse svg { transform: scaleX(-1); }
html.collapsed .sb-brand { flex-direction: row; justify-content: center; padding: 18px 0 16px; }
.content { max-width: none; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 16px; }
.stat { padding: 16px 18px; gap: 10px; }
.stat-num { font-size: 26px; }
.trend { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-box .empty, .card-body > .empty { padding: 28px 10px; }

@media (max-width: 860px) { .topbar .sb-collapse { display: none !important; } }
.sb-brand { padding: 18px 14px 16px 16px; gap: 10px; }
.sb-brand-text span { white-space: nowrap; font-size: 10px; letter-spacing: 0; font-weight: 600; }
/* Perbaikan kotak upload (label harus berupa blok) */
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; width: 100%; min-height: 150px; padding: 26px 18px; text-align: center; }
.dropzone svg { margin-bottom: 4px; }
.dropzone strong { margin: 0; font-size: 14px; }
.dropzone span { display: block; font-size: 12.5px; }
.dropzone + .file-list:empty { display: none; }

.grid-stats { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* ===== Perbaikan tampilan HP: cegah konten melebar keluar layar ===== */
html, body { max-width: 100%; overflow-x: hidden; }
.grid > *, .card, .stack > *, .li-main, .tb-title { min-width: 0; }
.grid-2, .grid-3, .grid-main { grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)); }
.grid-3 { --cols: 3; }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 1180px) { .grid-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 960px) { .grid-3 { --cols: 2; } }
@media (max-width: 860px) {
  .grid-2, .grid-3, .grid-main, .form-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stat { padding: 14px; }
  .stat-num { font-size: 22px; }
  .topbar { height: auto; min-height: 60px; padding: 10px 14px; gap: 10px; }
  .tb-title h1 { font-size: 16px; }
  .tb-title p { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tb-actions { gap: 6px; }
  .icon-btn { width: 36px; height: 36px; }
  .card-head { padding: 14px 16px; }
  .card-body { padding: 16px; }
  .list-item { padding: 12px 16px; }
  .empty { padding: 28px 16px; }
  .empty h4 { font-size: 14px; }
  .chart-box { height: 220px; }
  .page-head { align-items: stretch; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .tabs { margin-left: -16px; margin-right: -16px; padding: 0 16px; }
  .filters .input, .filters .select { flex: 1 1 140px; min-width: 0; }
  .meta { grid-template-columns: minmax(0, 1fr); }
  .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 380px) { .grid-stats { grid-template-columns: minmax(0, 1fr); } }
