/* JN1 BILLING & INVOICE MANAGEMENT SYSTEM
   Tema: Modern Enterprise SaaS — Clean Corporate — Red & White. */
:root {
  --brand: #C62828;
  --brand-600: #B71C1C;
  --brand-700: #8E1B1B;
  --brand-soft: #FDECEC;
  --brand-soft-2: #FBDCDC;
  --brand-line: #F3C6C6;
  --bg: #F7F8FA;
  --white: #FFFFFF;
  --ink: #1F2937;
  --ink-2: #4B5563;
  --muted: #6B7280;
  --line: #E5E7EB;
  --line-2: #EEF0F3;
  --green: #16A34A;
  --green-soft: #ECFDF5;
  --green-line: #BBF7D0;
  --blue: #2563EB;
  --blue-soft: #EFF6FF;
  --blue-line: #BFDBFE;
  --orange: #EA580C;
  --orange-soft: #FFF7ED;
  --orange-line: #FED7AA;
  --teal: #0D9488;
  --teal-soft: #F0FDFA;
  --teal-line: #99F6E4;
  --red: #DC2626;
  --red-soft: #FEF2F2;
  --red-line: #FECACA;
  --gray-soft: #F3F4F6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 26px -12px rgba(16, 24, 40, 0.14);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --sidebar-w: 258px;
  --font: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4, h5 { margin: 0; font-weight: 700; color: var(--ink); letter-spacing: -0.01em; }
p { margin: 0; }
button { font-family: inherit; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #D5D8DE; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #BFC4CC; background-clip: content-box; }

/* ================================ SHELL ================================ */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--white);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 40; transition: transform .22s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 11px; padding: 18px 18px 16px; border-bottom: 1px solid var(--line-2);
  min-height: 72px;
}
.sidebar-brand img { width: 40px; height: 40px; object-fit: contain; border-radius: 9px; }
.sidebar-brand .brand-text { min-width: 0; }
.sidebar-brand .brand-title { font-size: 15px; font-weight: 800; color: var(--brand-700); letter-spacing: -0.01em; line-height: 1.2; }
.sidebar-brand .brand-sub { font-size: 10.5px; color: var(--muted); font-weight: 600; letter-spacing: .04em; text-transform: uppercase; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 10px 18px; }
.nav-group { margin-bottom: 14px; }
.nav-group-label { font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: #9CA3AF; padding: 6px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 10px;
  color: var(--ink-2); font-size: 13px; font-weight: 600; margin-bottom: 2px; position: relative;
  text-decoration: none; transition: background .15s, color .15s;
}
.nav-item:hover { background: #F6F7F9; color: var(--ink); text-decoration: none; }
.nav-item.active { background: var(--brand-soft); color: var(--brand-700); }
.nav-item.active::before {
  content: ''; position: absolute; left: -10px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand);
}
.nav-item svg { color: #9CA3AF; }
.nav-item.active svg { color: var(--brand); }
.nav-badge {
  margin-left: auto; background: var(--brand); color: #fff; font-size: 10.5px; font-weight: 700;
  min-width: 19px; height: 19px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; padding: 0 6px;
}
.sidebar-foot { border-top: 1px solid var(--line-2); padding: 12px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: #FAFAFB; border: 1px solid var(--line-2); }
.user-chip .u-name { font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .u-role { font-size: 10.5px; color: var(--muted); text-transform: capitalize; }
.logout-btn { margin-left: auto; background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; display: inline-flex; }
.logout-btn:hover { background: var(--brand-soft); color: var(--brand); }
.avatar {
  width: 34px; height: 34px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-700);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 800; flex: none;
  border: 1px solid var(--brand-line);
}
.avatar.sm { width: 30px; height: 30px; border-radius: 9px; font-size: 11px; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }
.topbar {
  height: 68px; background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px;
  padding: 0 26px; position: sticky; top: 0; z-index: 30;
}
.hamburger { display: none; background: transparent; border: 1px solid var(--line); border-radius: 9px; width: 38px; height: 38px; cursor: pointer; color: var(--ink-2); }
.page-title { font-size: 16px; font-weight: 800; letter-spacing: -0.01em; }
.page-crumb { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.topbar-date { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; background: #F6F7F9; padding: 7px 11px; border-radius: 9px; border: 1px solid var(--line-2); font-weight: 600; }
.icon-btn {
  position: relative; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: #F8F9FB; color: var(--brand); }
.icon-btn .dot-badge {
  position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--brand);
  color: #fff; font-size: 10px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px; border: 2px solid #fff;
}
.content { padding: 26px; flex: 1; min-width: 0; }
.backdrop { display: none; }
.bottomnav { display: none; }

/* ================================ TYPO ================================ */
.section-title { font-size: 14.5px; font-weight: 800; }
.section-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 700; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.req { color: var(--brand); margin-left: 2px; }

/* ================================ CARDS ================================ */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-pad { padding: 20px; }
.card-h { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line-2); }
.card-h .grow { min-width: 0; flex: 1; }
.card-b { padding: 20px; }
.card-f { padding: 14px 20px; border-top: 1px solid var(--line-2); background: #FCFCFD; border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 10px; 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-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-split { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

/* KPI */
.kpi { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 17px 18px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.kpi::after { content: ''; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--line); }
.kpi.tone-brand::after { background: var(--brand); }
.kpi.tone-green::after { background: var(--green); }
.kpi.tone-blue::after { background: var(--blue); }
.kpi.tone-orange::after { background: var(--orange); }
.kpi.tone-red::after { background: var(--red); }
.kpi.tone-teal::after { background: var(--teal); }
.kpi.tone-gray::after { background: #9CA3AF; }
.kpi .kpi-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.kpi .kpi-value { font-size: 23px; font-weight: 800; letter-spacing: -0.02em; margin-top: 8px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.kpi .kpi-hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.kpi .kpi-value.money { font-size: 20px; }
.kpi .kpi-icon { position: absolute; top: 14px; right: 14px; width: 34px; height: 34px; border-radius: 10px; background: var(--gray-soft); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; }
.kpi.tone-brand .kpi-icon { background: var(--brand-soft); color: var(--brand); }
.kpi.tone-green .kpi-icon { background: var(--green-soft); color: var(--green); }
.kpi.tone-blue .kpi-icon { background: var(--blue-soft); color: var(--blue); }
.kpi.tone-orange .kpi-icon { background: var(--orange-soft); color: var(--orange); }
.kpi.tone-red .kpi-icon { background: var(--red-soft); color: var(--red); }
.kpi.tone-teal .kpi-icon { background: var(--teal-soft); color: var(--teal); }

/* ================================ BUTTONS ================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px; border-radius: 9px; border: 1px solid transparent;
  font-size: 13px; font-weight: 700; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(142, 27, 27, .25); }
.btn-primary:hover:not(:disabled) { background: var(--brand-600); }
.btn-outline { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-outline:hover:not(:disabled) { border-color: #CFD4DC; background: #FAFAFB; color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover:not(:disabled) { background: #F3F4F6; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #B91C1C; }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15803D; }
.btn-soft { background: var(--brand-soft); color: var(--brand-700); border-color: var(--brand-line); }
.btn-soft:hover:not(:disabled) { background: var(--brand-soft-2); }
.btn-sm { height: 31px; padding: 0 11px; font-size: 12px; border-radius: 8px; }
.btn-xs { height: 29px; padding: 0 10px; font-size: 11.5px; border-radius: 7px; gap: 5px; }
.btn-block { width: 100%; }
.btn-icon { width: 32px; height: 32px; padding: 0; border-radius: 8px; background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.btn-icon:hover:not(:disabled) { background: #F8F9FB; color: var(--brand); }
.btn-icon.danger:hover { background: var(--red-soft); color: var(--red); border-color: var(--red-line); }

/* ================================ FORMS ================================ */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > label { font-size: 12px; font-weight: 700; color: var(--ink-2); display: flex; align-items: center; gap: 4px; }
.field .help { font-size: 11px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; height: 39px; border: 1px solid var(--line); border-radius: 9px; padding: 0 11px;
  font-size: 13px; font-family: inherit; color: var(--ink); background: #fff; transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 92px; padding: 10px 11px; line-height: 1.55; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(198, 40, 40, .12); }
.input:disabled, .select:disabled, .textarea:disabled { background: #F9FAFB; color: var(--muted); cursor: not-allowed; }
.input.money, .input.num { text-align: right; font-variant-numeric: tabular-nums; }
.input.sm { height: 34px; font-size: 12.5px; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.input-group { display: flex; align-items: stretch; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.input-group:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(198, 40, 40, .12); }
.input-group .prefix { display: inline-flex; align-items: center; padding: 0 10px; background: #F9FAFB; border-right: 1px solid var(--line); font-size: 12.5px; color: var(--muted); font-weight: 700; }
.input-group .input { border: 0; border-radius: 0; height: 37px; }
.input-group .input:focus { box-shadow: none; }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); cursor: pointer; }
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 38px; height: 22px; border-radius: 12px; background: #D7DBE0; position: relative; transition: background .18s; flex: none; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .18s; }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(16px); }
.hint-box { display: flex; gap: 9px; padding: 11px 13px; border-radius: 10px; font-size: 12px; line-height: 1.55; background: var(--blue-soft); border: 1px solid var(--blue-line); color: #1E40AF; }
.hint-box.warn { background: var(--orange-soft); border-color: var(--orange-line); color: #9A3412; }
.hint-box.danger { background: var(--red-soft); border-color: var(--red-line); color: #991B1B; }
.hint-box.ok { background: var(--green-soft); border-color: var(--green-line); color: #166534; }
.hint-box svg { margin-top: 1px; }

/* Combo (searchable dropdown) */
.combo { position: relative; }
.combo-input { padding-right: 34px; cursor: text; }
.combo-toggle { position: absolute; right: 4px; top: 4px; width: 30px; height: 30px; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; }
.combo-toggle:hover { background: var(--gray-soft); }
.combo-list {
  position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; right: 0; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 30px -8px rgba(16,24,40,.25);
  max-height: 270px; overflow-y: auto; padding: 5px;
}
.combo-list[hidden] { display: none; }
.combo-list.up { top: auto; bottom: calc(100% + 4px); }
.combo-opt { padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 12.8px; display: flex; gap: 8px; align-items: center; }
.combo-opt:hover, .combo-opt.hl { background: var(--brand-soft); }
.combo-opt .o-code { font-weight: 800; font-size: 11.5px; color: var(--brand-700); }
.combo-opt .o-sub { font-size: 11px; color: var(--muted); }
.combo-opt.empty { color: var(--muted); cursor: default; font-size: 12px; }
.combo-opt.add { color: var(--brand-700); font-weight: 700; border-top: 1px solid var(--line-2); margin-top: 4px; padding-top: 9px; }
.combo-value { display: none; }
.combo-meta { font-size: 11.5px; color: var(--muted); }

/* ================================ BADGES ================================ */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3.5px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; border: 1px solid transparent; white-space: nowrap; line-height: 1.35;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.gray { background: var(--gray-soft); color: #4B5563; border-color: #E5E7EB; }
.badge.blue { background: var(--blue-soft); color: #1D4ED8; border-color: var(--blue-line); }
.badge.red { background: var(--red-soft); color: #B91C1C; border-color: var(--red-line); }
.badge.green { background: var(--green-soft); color: #15803D; border-color: var(--green-line); }
.badge.orange { background: var(--orange-soft); color: #C2410C; border-color: var(--orange-line); }
.badge.teal { background: var(--teal-soft); color: #0F766E; border-color: var(--teal-line); }
.badge.plain { background: #fff; color: var(--ink-2); border-color: var(--line); }
.chip { display: inline-block; background: #F3F4F6; border: 1px solid var(--line); color: var(--ink-2); border-radius: 7px; padding: 2px 7px; font-size: 11px; font-weight: 600; margin: 0 4px 4px 0; }
.pill { display: inline-flex; align-items: center; gap: 5px; background: var(--brand-soft); color: var(--brand-700); border: 1px solid var(--brand-line); padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.pill.gray { background: var(--gray-soft); color: var(--ink-2); border-color: var(--line); }

/* ================================ TABLES ================================ */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.dt { width: 100%; border-collapse: collapse; font-size: 12.8px; }
table.dt thead th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 800; padding: 11px 12px; background: #FAFAFB; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.dt thead th:first-child { border-top-left-radius: 0; }
table.dt tbody td { padding: 11px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; color: var(--ink-2); }
table.dt tbody tr:last-child td { border-bottom: 0; }
table.dt tbody tr:hover { background: #FCFCFD; }
table.dt tbody tr.clickable { cursor: pointer; }
table.dt td.num, table.dt th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.dt td.center, table.dt th.center { text-align: center; }
table.dt .cell-strong { font-weight: 700; color: var(--ink); }
table.dt .cell-sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
table.dt .cell-actions { display: flex; gap: 6px; justify-content: flex-end; }
.table-empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.table-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line-2); background: #FCFCFD; font-size: 12px; color: var(--muted); }
.pager { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.pager button { min-width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-size: 12px; font-weight: 700; cursor: pointer; padding: 0 8px; }
.pager button:hover:not(:disabled) { border-color: var(--brand-line); color: var(--brand); }
.pager button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager button:disabled { opacity: .45; cursor: not-allowed; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line-2); }
.toolbar .search { position: relative; flex: 1; min-width: 180px; max-width: 340px; }
.toolbar .search svg { position: absolute; left: 10px; top: 11px; color: var(--muted); }
.toolbar .search .input { padding-left: 32px; }
.toolbar .select { width: auto; min-width: 140px; }

/* ================================ STEPPER ================================ */
.stepper { display: flex; flex-direction: column; gap: 0; }
.step { display: flex; gap: 12px; position: relative; padding-bottom: 16px; }
.step:last-child { padding-bottom: 0; }
.step::before { content: ''; position: absolute; left: 13px; top: 28px; bottom: 0; width: 2px; background: var(--line); }
.step:last-child::before { display: none; }
.step .marker {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); background: #fff;
  display: inline-flex; align-items: center; justify-content: center; flex: none; color: #9CA3AF; font-size: 11px; font-weight: 800; z-index: 1;
}
.step.done .marker { background: var(--green); border-color: var(--green); color: #fff; }
.step.done::before { background: var(--green-line); }
.step.current .marker { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 4px rgba(198,40,40,.09); }
.step.blocked .marker { border-color: var(--red); color: var(--red); background: var(--red-soft); }
.step .step-body { min-width: 0; padding-top: 2px; }
.step .step-title { font-size: 12.8px; font-weight: 700; color: var(--ink); }
.step.pending .step-title { color: #9CA3AF; font-weight: 600; }
.step .step-meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Timeline */
.timeline { position: relative; padding-left: 4px; }
.tl-item { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ''; position: absolute; left: 11px; top: 26px; bottom: 0; width: 2px; background: var(--line-2); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 24px; height: 24px; border-radius: 8px; background: var(--gray-soft); color: var(--ink-2); display: inline-flex; align-items: center; justify-content: center; flex: none; z-index: 1; }
.tl-dot.ok { background: var(--green-soft); color: var(--green); }
.tl-dot.err { background: var(--red-soft); color: var(--red); }
.tl-dot.info { background: var(--blue-soft); color: var(--blue); }
.tl-dot.warn { background: var(--orange-soft); color: var(--orange); }
.tl-dot.brand { background: var(--brand-soft); color: var(--brand); }
.tl-body { min-width: 0; }
.tl-title { font-size: 12.8px; font-weight: 700; }
.tl-meta { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.tl-note { font-size: 12px; color: var(--ink-2); margin-top: 5px; background: #FAFAFB; border: 1px solid var(--line-2); border-radius: 8px; padding: 7px 9px; white-space: pre-wrap; }

/* ================================ MODAL / TOAST ================================ */
.modal-back { position: fixed; inset: 0; background: rgba(17, 24, 39, .48); backdrop-filter: blur(2px); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 18px; overflow-y: auto; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 520px; box-shadow: 0 24px 60px -12px rgba(16,24,40,.4); animation: pop .16s ease-out; }
.modal.wide { max-width: 900px; }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-h { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line-2); }
.modal-h h3 { font-size: 15px; }
.modal-h p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.modal-x { margin-left: auto; border: 1px solid var(--line); background: #fff; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; }
.modal-x:hover { background: var(--gray-soft); }
.modal-b { padding: 20px; max-height: 68vh; overflow-y: auto; }
.modal-f { padding: 14px 20px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 10px; background: #FCFCFD; border-radius: 0 0 16px 16px; flex-wrap: wrap; }
.toast-root { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 9px; max-width: 380px; }
.toast { display: flex; align-items: flex-start; gap: 9px; background: #111827; color: #F9FAFB; padding: 11px 14px; border-radius: 11px; font-size: 12.8px; box-shadow: 0 12px 30px -8px rgba(0,0,0,.4); animation: toastIn .18s ease-out; }
.toast.ok { background: #14532D; }
.toast.err { background: #7F1D1D; }
.toast .t-icon { margin-top: 1px; }
@keyframes toastIn { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ================================ MISC ================================ */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty-icon { width: 54px; height: 54px; border-radius: 16px; background: var(--brand-soft); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 12px; }
.empty h3 { font-size: 14.5px; margin-bottom: 4px; color: var(--ink); }
.empty p { font-size: 12.5px; max-width: 420px; margin: 0 auto 14px; line-height: 1.6; }
.skeleton-line { height: 14px; border-radius: 6px; background: linear-gradient(90deg, #F1F2F4 25%, #E8EAED 37%, #F1F2F4 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; margin-bottom: 10px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.divider { height: 1px; background: var(--line-2); margin: 4px 0; }
.kv { display: grid; grid-template-columns: 132px 1fr; gap: 7px 12px; font-size: 12.8px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; color: var(--ink); font-weight: 600; word-break: break-word; }
.kv-list { display: flex; flex-direction: column; gap: 9px; }
.kv-row { display: flex; justify-content: space-between; gap: 12px; font-size: 12.8px; }
.kv-row .k { color: var(--muted); font-weight: 600; }
.kv-row .v { font-weight: 700; text-align: right; }
.totals-box { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #FCFCFD; }
.totals-box .t-row { display: flex; justify-content: space-between; padding: 10px 14px; font-size: 12.8px; border-bottom: 1px solid var(--line-2); }
.totals-box .t-row:last-child { border-bottom: 0; }
.totals-box .t-row.grand { background: var(--brand-soft); font-weight: 800; color: var(--brand-700); font-size: 14px; }
.totals-box .t-row .label { color: var(--ink-2); }
.totals-box .t-row.grand .label { color: var(--brand-700); }
.totals-box .t-row .val { font-variant-numeric: tabular-nums; font-weight: 700; }
.chart-bars { display: flex; align-items: flex-end; gap: 10px; height: 148px; padding: 10px 4px 0; }
.chart-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.chart-col .bar-track { width: 100%; display: flex; align-items: flex-end; height: 110px; }
.chart-col .bar { width: 100%; max-width: 44px; margin: 0 auto; background: linear-gradient(180deg, #E45757, #C62828); border-radius: 6px 6px 2px 2px; min-height: 3px; transition: height .3s; }
.chart-col .bar-lbl { font-size: 10px; color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 100%; }
.chart-col .bar-val { font-size: 10px; font-weight: 700; color: var(--ink-2); }
.hbars { display: flex; flex-direction: column; gap: 11px; }
.hbar { display: grid; grid-template-columns: 118px 1fr auto; gap: 10px; align-items: center; font-size: 12px; }
.hbar .hb-label { color: var(--ink-2); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .hb-track { background: #F1F2F4; height: 9px; border-radius: 6px; overflow: hidden; }
.hbar .hb-fill { height: 100%; background: linear-gradient(90deg, #E45757, #C62828); border-radius: 6px; }
.hbar .hb-val { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); font-size: 11.5px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { padding: 9px 14px; font-size: 12.8px; font-weight: 700; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; background: transparent; border-top: 0; border-left: 0; border-right: 0; white-space: nowrap; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab:hover { color: var(--ink); }
.subtabs { display: inline-flex; background: #F3F4F6; border-radius: 9px; padding: 3px; gap: 3px; }
.subtabs button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; font-size: 12px; font-weight: 700; color: var(--muted); cursor: pointer; }
.subtabs button.active { background: #fff; color: var(--brand); box-shadow: var(--shadow-sm); }
.actions-bar { display: flex; gap: 9px; flex-wrap: wrap; }
.doc-frame { width: 100%; height: 74vh; border: 1px solid var(--line); border-radius: 10px; background: #F1F2F4; }
.upload-box { border: 1.5px dashed #D5D8DE; border-radius: 12px; padding: 22px; text-align: center; background: #FCFCFD; cursor: pointer; transition: border-color .15s, background .15s; }
.upload-box:hover, .upload-box.drag { border-color: var(--brand); background: var(--brand-soft); }
.upload-box .ub-icon { width: 42px; height: 42px; border-radius: 12px; background: #fff; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; color: var(--brand); margin-bottom: 8px; }
/* Rincian layanan: deskripsi panjang & preview ringkas */
.item-desc-input { min-height: 44px; height: auto; padding: 8px 10px; line-height: 1.5; resize: vertical; }
.item-desc-text {
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  white-space: pre-wrap; word-break: break-word; line-height: 1.5;
}
.items-table td { vertical-align: top; }
.items-editor .table-wrap { overflow: visible; }
/* Modal rincian layanan: ruang vertikal lebih lega agar dropdown di dalam tabel terlihat */
.modal.items-modal { max-width: 1140px; }
.modal.items-modal .modal-b { max-height: 86vh; min-height: min(72vh, 700px); }
.modal.items-modal .items-table { table-layout: fixed; width: 100%; }
.modal.items-modal .items-table td, .modal.items-modal .items-table th { word-break: break-word; }
@media (max-width: 900px) {
  .modal.items-modal .modal-b { max-height: 80vh; min-height: 64vh; }
  .modal.items-modal .items-table { table-layout: auto; }
}
.cache-banner {
  display: flex; gap: 9px; align-items: flex-start; padding: 10px 12px; margin-bottom: 14px;
  border: 1px solid var(--teal-line); background: var(--teal-soft); border-radius: 10px; font-size: 12px; color: #0F766E;
}
.cache-banner .cb-ic { margin-top: 1px; }
.cache-banner .cb-sub { display: block; color: #0F766E; opacity: .85; font-size: 11.5px; margin-top: 2px; }
.cache-banner b { color: #115E59; }
.autosave-state {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700;
  padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: #FAFAFB; color: var(--muted); white-space: nowrap;
}
.autosave-state[data-state="saved"] { background: var(--green-soft); border-color: var(--green-line); color: #15803D; }
.autosave-state[data-state="local"] { background: var(--blue-soft); border-color: var(--blue-line); color: #1D4ED8; }
.autosave-state[data-state="saving"], .autosave-state[data-state="pending"] { background: var(--orange-soft); border-color: var(--orange-line); color: #C2410C; }
.autosave-state[data-state="error"] { background: var(--red-soft); border-color: var(--red-line); color: #B91C1C; }
.autosave-state[data-state="restored"] { background: var(--teal-soft); border-color: var(--teal-line); color: #0F766E; }
@media (max-width: 760px) {
  .autosave-state { font-size: 11px; padding: 4px 8px; white-space: normal; }
}
.progress { height: 6px; background: #F1F2F4; border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: var(--brand); transition: width .2s; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.file-row .fi { width: 34px; height: 34px; border-radius: 9px; background: var(--brand-soft); color: var(--brand); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.notif-item { display: flex; gap: 11px; padding: 14px 16px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.notif-item:hover { background: #FCFCFD; }
.notif-item.unread { background: #FFFBFB; }
.notif-item.unread .n-title { font-weight: 800; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-top: 6px; flex: none; }
.notif-item.read .notif-dot { background: transparent; border: 1px solid var(--line); }
.n-title { font-size: 12.8px; font-weight: 700; }
.n-body { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.n-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(122px, 1fr)); gap: 10px; }
.preset { border: 1.5px solid var(--line); border-radius: 10px; padding: 10px; cursor: pointer; background: #fff; text-align: left; }
.preset.active { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(198,40,40,.09); }
.preset .p-name { font-size: 11.5px; font-weight: 800; }
.preset .p-swatch { height: 26px; border-radius: 6px; margin-top: 7px; display: flex; overflow: hidden; }
.preset .p-swatch i { flex: 1; }
.color-input { display: flex; align-items: center; gap: 8px; }
.color-input input[type=color] { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 9px; padding: 3px; background: #fff; cursor: pointer; }
.color-input input[type=text] { flex: 1; }
.opt-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.opt-row:last-child { border-bottom: 0; }
.opt-row .opt-label { flex: 1; font-size: 12.8px; font-weight: 600; }
.opt-row .opt-help { font-size: 11px; color: var(--muted); font-weight: 400; }

/* ================================ LOGIN ================================ */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 0.95fr; }
.auth-visual {
  position: relative; overflow: hidden; padding: 46px 52px; display: flex; flex-direction: column;
  background: radial-gradient(1100px 600px at 10% 5%, #D4312F 0%, #C62828 42%, #8E1B1B 100%); color: #fff;
}
.auth-visual::before { content: ''; position: absolute; width: 460px; height: 460px; border-radius: 50%; right: -160px; bottom: -160px; background: rgba(255,255,255,.07); }
.auth-visual::after { content: ''; position: absolute; width: 280px; height: 280px; border-radius: 50%; right: 70px; top: -120px; background: rgba(255,255,255,.06); }
.auth-brand { display: flex; align-items: center; gap: 12px; position: relative; z-index: 1; }
.auth-brand img { width: 46px; height: 46px; border-radius: 11px; background: rgba(255,255,255,.12); padding: 3px; }
.auth-brand .ab-title { font-size: 16px; font-weight: 800; }
.auth-brand .ab-sub { font-size: 11px; opacity: .82; letter-spacing: .08em; text-transform: uppercase; }
.auth-hero { margin-top: auto; position: relative; z-index: 1; max-width: 460px; }
.auth-hero h1 { font-size: 33px; line-height: 1.18; letter-spacing: -0.02em; margin-bottom: 14px; }
.auth-hero p { font-size: 14px; line-height: 1.7; opacity: .9; }
.auth-points { margin-top: 26px; display: flex; flex-direction: column; gap: 12px; }
.auth-point { display: flex; gap: 10px; font-size: 12.8px; align-items: flex-start; opacity: .95; }
.auth-point .ap-ic { width: 26px; height: 26px; border-radius: 8px; background: rgba(255,255,255,.16); display: inline-flex; align-items: center; justify-content: center; flex: none; }
.auth-foot { margin-top: 32px; font-size: 11px; opacity: .7; position: relative; z-index: 1; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: #fff; }
.auth-card { width: 100%; max-width: 386px; }
.auth-card h2 { font-size: 22px; letter-spacing: -0.02em; }
.auth-card .sub { font-size: 13px; color: var(--muted); margin: 6px 0 24px; }
.auth-field { margin-bottom: 15px; }
.auth-field label { display: block; font-size: 12px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.auth-actions { margin-top: 20px; }
.auth-alert { display: none; padding: 10px 12px; border-radius: 9px; font-size: 12.4px; margin-bottom: 14px; line-height: 1.5; }
.auth-alert.show { display: block; background: var(--red-soft); border: 1px solid var(--red-line); color: #991B1B; }
.auth-alert.show.ok { background: var(--green-soft); border-color: var(--green-line); color: #166534; }
.auth-hint { margin-top: 22px; padding: 13px 14px; border-radius: 10px; background: #FAFAFB; border: 1px solid var(--line); font-size: 11.8px; color: var(--ink-2); line-height: 1.6; }
.auth-hint b { color: var(--brand-700); }
.auth-hint code { background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 1px 5px; font-size: 11px; }
.pass-toggle, .pw-toggle { position: absolute; right: 7px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; line-height: 0; }
.pass-toggle:hover, .pw-toggle:hover { background: var(--gray-soft); color: var(--ink-2); }
.pw-toggle.on { color: var(--brand); }
.pw-wrap { position: relative; display: block; width: 100%; }
.pw-wrap > .input, .pw-wrap > input { padding-right: 40px; }
.pw-wrap .input { padding-right: 40px; }

/* ================================ RESPONSIVE ================================ */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1024px) {
  .grid-split { grid-template-columns: minmax(0, 1fr); }
  .sidebar { transform: translateX(-100%); box-shadow: 0 0 40px rgba(0,0,0,.18); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .hamburger { display: inline-flex; align-items: center; justify-content: center; }
  .backdrop { display: block; position: fixed; inset: 0; background: rgba(17,24,39,.35); z-index: 35; opacity: 0; pointer-events: none; transition: opacity .2s; }
  .backdrop.show { opacity: 1; pointer-events: auto; }
  .content { padding: 20px 18px 84px; }
  .topbar { padding: 0 18px; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
}
@media (max-width: 900px) {
  /* tabel menjadi kartu agar tidak ada scroll horizontal di tablet & ponsel */
  table.dt.responsive thead { display: none; }
  table.dt.responsive tbody tr { display: block; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; padding: 6px 10px; background: #fff; box-shadow: var(--shadow-sm); }
  table.dt.responsive tbody td { display: flex; justify-content: space-between; gap: 12px; padding: 7px 2px; border-bottom: 1px dashed var(--line-2); text-align: right; }
  table.dt.responsive tbody td:last-child { border-bottom: 0; }
  table.dt.responsive tbody td::before { content: attr(data-label); font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: left; flex: none; }
  table.dt.responsive tbody td.cell-actions { justify-content: flex-end; }
  table.dt.responsive tbody td.cell-actions::before { content: ''; }
  table.dt.responsive tbody tr:hover { background: #fff; }
}
@media (max-width: 760px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .content { padding: 16px 14px 86px; }
  .topbar { height: 60px; padding: 0 14px; gap: 10px; }
  .page-title { font-size: 14.5px; }
  .page-crumb { font-size: 11px; }
  .topbar-date { display: none; }
  .card-pad { padding: 16px; }
  .card-h { padding: 14px 16px; }
  .card-b { padding: 16px; }
  .kpi { padding: 14px 15px; }
  .kpi .kpi-value { font-size: 20px; }
  .kpi .kpi-icon { width: 30px; height: 30px; top: 12px; right: 12px; }
  .bottomnav {
    display: block; position: fixed; bottom: 0; left: 0; right: 0; z-index: 45;
    background: rgba(255,255,255,.97); border-top: 1px solid var(--line); backdrop-filter: blur(8px);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav-inner { display: flex; justify-content: space-around; gap: 2px; }
  .bottomnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: 9px; font-size: 9.8px; font-weight: 700; color: var(--muted); flex: 1; text-decoration: none; }
  .bottomnav a.active { color: var(--brand); background: var(--brand-soft); }
  .toolbar { padding: 12px; }
  .toolbar .search { max-width: none; }
  .toolbar .select { min-width: 0; flex: 1; }
  .actions-bar { width: 100%; }
  .actions-bar .btn { flex: 1; }
  .modal-back { padding: 0; align-items: flex-end; }
  .modal { max-width: none; border-radius: 16px 16px 0 0; }
  .modal-b { max-height: 66vh; }
  .modal-f { border-radius: 0; }
  .toast-root { left: 12px; right: 12px; bottom: 78px; max-width: none; }
  .kv { grid-template-columns: 108px 1fr; }
  .hbar { grid-template-columns: 88px 1fr auto; }
  .chart-bars { height: 132px; }
}

/* ================================ PRINT ================================ */
@media print {
  .sidebar, .topbar, .bottomnav, .toast-root, .modal-back { display: none !important; }
  .main { margin-left: 0; }
  .content { padding: 0; }
  body { background: #fff; }
}
