/* =========================================================
   SPT OP — Design tokens
   ========================================================= */

@import url('https://cdnjs.cloudflare.com/ajax/libs/ibm-plex/6.4.0/css/ibm-plex-sans/latest/ibm-plex-sans.min.css');
@import url('https://cdnjs.cloudflare.com/ajax/libs/ibm-plex/6.4.0/css/ibm-plex-mono/latest/ibm-plex-mono.min.css');

:root {
  --ink-900: #142032;
  --ink-800: #1E3350;
  --ink-700: #2A4468;
  --paper: #F3F4F1;
  --surface: #FFFFFF;
  --border: #E1E3DE;
  --text: #191C1F;
  --text-muted: #676D73;
  --accent: #3C7A5C;
  --accent-soft: #E7F0EA;
  --warning: #9A5B12;
  --warning-soft: #FBF0DF;
  --danger: #A93226;
  --danger-soft: #FBEAE8;

  --font-ui: 'IBM Plex Sans', -apple-system, sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  --sidebar-w: 248px;
  --topbar-h: 64px;
  --radius: 6px;
}

* { box-sizing: border-box; }

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

a { color: inherit; }

/* ---------------------------------------------------------
   Shell layout
   --------------------------------------------------------- */

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------------------------------------------------------
   Sidebar
   --------------------------------------------------------- */

.sidebar {
  background: var(--ink-900);
  color: #D9DEE6;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar__brand {
  padding: 22px 24px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar__mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.sidebar__title { font-weight: 600; font-size: 14.5px; color: #fff; letter-spacing: 0.01em; }
.sidebar__subtitle { font-size: 11.5px; color: #8D96A5; margin-top: 1px; }

.sidebar__nav { flex: 1; padding: 14px 12px; overflow-y: auto; }

.sidebar__section-label { font-size: 11px; color: #6E7787; padding: 14px 12px 6px; font-weight: 500; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; border-radius: var(--radius);
  color: #C4CBD6; text-decoration: none; font-size: 13.5px;
  cursor: pointer; border: none; background: none;
  width: 100%; text-align: left; font-family: var(--font-ui);
  margin-bottom: 2px;
}

.nav-item svg { flex-shrink: 0; opacity: 0.85; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.is-active { background: var(--ink-700); color: #fff; }
.nav-item.is-active svg { opacity: 1; }

.sidebar__footer {
  padding: 14px 20px 18px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12px; color: #8D96A5;
}
.sidebar__footer strong { color: #D9DEE6; display: block; font-size: 13px; margin-bottom: 1px; }

/* ---------------------------------------------------------
   Main column
   --------------------------------------------------------- */

.main { min-width: 0; display: flex; flex-direction: column; }

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

.topbar__title { font-size: 16px; font-weight: 600; }
.topbar__controls { display: flex; align-items: center; gap: 10px; }

select, input[type=text], input[type=number], input[type=date] {
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

select:focus, input:focus, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.content { padding: 28px 32px 60px; flex: 1; }

/* ---------------------------------------------------------
   Cards / summary tiles
   --------------------------------------------------------- */

.tile-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px; margin-bottom: 24px;
}

.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.tile__label { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.tile__value { font-family: var(--font-mono); font-size: 20px; font-weight: 500; letter-spacing: -0.01em; }
.tile__value.is-positive { color: var(--accent); }
.tile__value.is-negative { color: var(--danger); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 20px; }
.panel__header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.panel__header h3 { margin: 0; font-size: 14px; font-weight: 600; }
.panel__body { padding: 4px 0; }

/* ---------------------------------------------------------
   Tables
   --------------------------------------------------------- */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--text-muted); font-size: 12px; padding: 10px 18px; border-bottom: 1px solid var(--border); }
td { padding: 10px 18px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
.num { font-family: var(--font-mono); text-align: right; white-space: nowrap; }
.text-muted { color: var(--text-muted); }
tbody tr:hover { background: #FAFAF9; }

/* ---------------------------------------------------------
   Buttons
   --------------------------------------------------------- */

.btn {
  font-family: var(--font-ui); font-size: 13px; font-weight: 500;
  padding: 8px 14px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer;
}
.btn:hover { background: #F5F5F3; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn--primary:hover { background: #336B4F; }
.btn--ghost { border-color: transparent; background: transparent; }
.btn--ghost:hover { background: #F0F0EE; }

/* ---------------------------------------------------------
   Badges
   --------------------------------------------------------- */

.badge { display: inline-block; font-size: 11.5px; padding: 2px 9px; border-radius: 100px; font-weight: 500; }
.badge--ok { background: var(--accent-soft); color: var(--accent); }
.badge--warn { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }

.empty-state { padding: 48px 24px; text-align: center; color: var(--text-muted); font-size: 13.5px; }

/* ---------------------------------------------------------
   Modal
   --------------------------------------------------------- */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 32, 50, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 8vh 20px;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border-radius: 10px;
  width: 100%;
  max-width: 420px;
  max-height: 84vh;
  box-shadow: 0 20px 50px rgba(20, 32, 50, 0.25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal > form {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.modal__header {
  flex-shrink: 0;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}

.modal__header h3 { margin: 0; font-size: 15px; font-weight: 600; }

.modal__close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 18px; line-height: 1;
  padding: 4px;
}
.modal__close:hover { color: var(--text); }

.modal__body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 22px; }
.modal__footer { flex-shrink: 0; padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

.form-group { margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label {
  display: block; font-size: 12.5px; font-weight: 500;
  color: var(--text-muted); margin-bottom: 5px;
}
.form-group select, .form-group input { width: 100%; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Rupiah input with fixed "Rp" prefix */
.currency-input { position: relative; }
.currency-input span {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 13px; color: var(--text-muted);
  pointer-events: none;
}
.currency-input input {
  width: 100%; padding-left: 32px;
  font-family: var(--font-mono); text-align: right;
}

.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 6px; }

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* ---------------------------------------------------------
   Row actions (edit/hapus per baris tabel)
   --------------------------------------------------------- */

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.btn--sm {
  padding: 4px 9px;
  font-size: 12px;
}

.btn--danger-text { color: var(--danger); }
.btn--danger-text:hover { background: var(--danger-soft); }

/* ---------------------------------------------------------
   Client context banner — penanda client & tahun yang aktif
   --------------------------------------------------------- */

.client-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--accent-soft);
  border: 1px solid #CFE3D8;
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 20px;
}

.client-banner__avatar {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 15px;
  flex-shrink: 0;
}

.client-banner__name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.client-banner__meta {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 1px;
}

.client-banner__year {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid #CFE3D8;
  padding: 5px 12px;
  border-radius: 100px;
  white-space: nowrap;
}

/* Label kecil di atas dropdown topbar, supaya jelas fungsinya */
.topbar__field { display: flex; flex-direction: column; gap: 3px; }
.topbar__field-label { font-size: 10.5px; color: var(--text-muted); font-weight: 500; }

/* ---------------------------------------------------------
   Workspace lock — client harus dibuka dulu sebelum menu lain aktif
   --------------------------------------------------------- */

.nav-item.is-disabled {
  color: #4C5566;
  cursor: not-allowed;
  opacity: 0.55;
}
.nav-item.is-disabled:hover { background: none; color: #4C5566; }

.client-banner__close {
  font-size: 12px;
  font-family: var(--font-ui);
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 11px;
  border-radius: 100px;
  cursor: pointer;
  margin-left: 8px;
}
.client-banner__close:hover { background: #F5F5F3; color: var(--text); }

.topbar__lock-hint {
  font-size: 12.5px;
  color: var(--text-muted);
}

/* ---------------------------------------------------------
   Cash Flow → Harta link section (di dalam modal transaksi)
   --------------------------------------------------------- */

.checkbox-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 500; color: var(--text);
  cursor: pointer;
}
.checkbox-label input[type=checkbox] { width: auto; margin: 0; }

.asset-link-box {
  border: 1px dashed #CFE3D8;
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 4px;
}
.asset-link-box .form-group:last-child { margin-bottom: 0; }

/* ---------------------------------------------------------
   Login screen
   --------------------------------------------------------- */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink-900);
}

.login-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 32px 30px;
  width: 100%;
  max-width: 340px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.35);
}

.sidebar__footer #currentUserRole {
  display: block;
  text-transform: capitalize;
}

/* ---------------------------------------------------------
   Tabel perbandingan multi-tahun (scroll horizontal)
   --------------------------------------------------------- */

.table-scroll { overflow-x: auto; }
.table-scroll table { min-width: max-content; }
.table-scroll th, .table-scroll td { white-space: nowrap; }
.table-scroll th:first-child, .table-scroll td:first-child {
  position: sticky; left: 0; background: var(--surface); z-index: 1;
  box-shadow: 1px 0 0 var(--border);
}

/* ---------------------------------------------------------
   Cetak Formulir 1770-IV
   --------------------------------------------------------- */

.form1770 { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 32px; }
.form1770 h2 { font-size: 15px; margin: 0 0 2px; text-align: center; }
.form1770 .form1770__subtitle { text-align: center; font-size: 12.5px; color: var(--text-muted); margin-bottom: 18px; }
.form1770 .form1770__meta { font-size: 13px; margin-bottom: 4px; }
.form1770 .form1770__meta strong { display: inline-block; min-width: 160px; }
.form1770 h3 { font-size: 13.5px; margin: 22px 0 8px; }
.form1770 table { border: 1px solid #333; }
.form1770 th, .form1770 td { border: 1px solid #333; padding: 5px 8px; font-size: 12px; }
.form1770 th { background: #F0F0EE; text-align: center; }
.form1770 .num { font-family: var(--font-mono); }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .app-shell { display: block !important; }
  .content { padding: 0 !important; }
  .form1770 { border: none; padding: 0; }
  body { background: #fff; }
}
