/* =====================================================================
   MANAJEMEN KEUANGAN SEKOLAH - SMK TERPADU LAMPANG
   ===================================================================== */

:root {
  --primary: #0f766e;
  --primary-dark: #0b5c56;
  --accent: #f59e0b;
  --ink: #0b2230;
  --ink-soft: #334d5c;
  --muted: #64798a;
  --line: #e3ebe9;
  --bg: #f4f8f8;
  --white: #fff;
  --sidebar: #062a2f;
  --green: #047857;
  --danger: #b91c1c;
  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 24px 50px -38px rgba(6, 42, 47, 0.55);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

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

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

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 800; letter-spacing: -0.02em; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0; padding: 0; }
small { font-size: 12px; }

/* ------------------------------------------------------------------
   TATA LETAK
------------------------------------------------------------------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: 262px;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  color: rgba(255, 255, 255, 0.72);
  background: var(--sidebar);
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 8px 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
}

.sidebar-mark { display: grid; place-items: center; color: var(--accent); flex: none; }

.sidebar-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 9px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.95);
}

.sidebar-brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sidebar-brand-text strong { color: #fff; font-size: 13.5px; }
.sidebar-brand-text small { font-size: 11px; color: rgba(255, 255, 255, 0.5); }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.16); border-radius: 6px; }

.sidebar-label {
  padding: 13px 10px 5px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.34);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.72);
  transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-link svg { flex: none; opacity: 0.8; }
.sidebar-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.sidebar-link.is-active { background: var(--primary); color: #fff; }
.sidebar-link.is-active svg { opacity: 1; }

.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  display: grid;
  gap: 4px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px 2px;
  min-width: 0;
}

.sidebar-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sidebar-user-text strong { color: #fff; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-user-text small { font-size: 10.5px; color: rgba(255, 255, 255, 0.46); }

.avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  flex: none;
}

.sidebar-logout:hover { background: rgba(185, 28, 28, 0.22); color: #fff; }

.app-main { flex: 1; min-width: 0; margin-left: 262px; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { font-size: 19px; }
.topbar-title p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-left: 16px;
  border-left: 1px solid var(--line);
}

.topbar-user-text { display: flex; flex-direction: column; line-height: 1.25; }
.topbar-user-text strong { font-size: 13px; }
.topbar-user-text small { font-size: 11px; color: var(--muted); }

.burger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 40px;
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}

.burger span { height: 2px; border-radius: 2px; background: var(--ink); }

.app-content { flex: 1; padding: 26px 28px 42px; }

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 28px;
  border-top: 1px solid var(--line);
  background: #fff;
  font-size: 12.5px;
  color: var(--muted);
}

.alert {
  border-radius: var(--radius-sm);
  padding: 12px 15px;
  font-size: 14px;
  margin-bottom: 18px;
  border: 1px solid transparent;
}

.alert-success { background: #ecfdf5; border-color: #bbf7d0; color: #065f46; }
.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* ------------------------------------------------------------------
   KARTU & KPI
------------------------------------------------------------------- */

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 22px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.card-head h2 { font-size: 16px; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.card-body { padding: 22px; }
.card-body-flush { padding: 0; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
  margin-bottom: 22px;
}

.kpi {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.kpi-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(15, 118, 110, 0.09);
  color: var(--primary);
  flex: none;
}

.kpi-icon.warn { background: rgba(245, 158, 11, 0.14); color: #b45309; }
.kpi-icon.red { background: #fef2f2; color: var(--danger); }
.kpi-icon.green { background: #ecfdf5; color: var(--green); }

.kpi-value { display: block; font-size: 21px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.2; }
.kpi-label { font-size: 12px; color: var(--muted); font-weight: 600; }

.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

.list-simple { list-style: none; }

.list-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.list-item:first-child { padding-top: 0; }
.list-item:last-child { border-bottom: 0; padding-bottom: 0; }
.list-item strong { display: block; font-size: 13.5px; font-weight: 700; }
.list-item small { display: block; font-size: 11.8px; color: var(--muted); margin-top: 1px; }
.list-item .list-meta { flex: none; font-size: 12px; color: var(--ink-soft); font-weight: 700; white-space: nowrap; text-align: right; }
.list-empty { margin: 0; font-size: 13.5px; color: var(--muted); }

/* ------------------------------------------------------------------
   TABEL
------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 13.6px; }

.table th {
  text-align: left;
  padding: 11px 16px;
  background: #f8fbfb;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover { background: #fbfdfd; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .cell-title { font-weight: 700; max-width: 320px; }
.table .cell-sub { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.table tfoot td { font-weight: 800; background: #f8fbfb; border-top: 2px solid var(--line); }

.actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-green { background: #ecfdf5; color: #047857; }
.badge-amber { background: #fffbeb; color: #b45309; }
.badge-red { background: #fef2f2; color: #b91c1c; }
.badge-gray { background: #f1f5f7; color: #526b7a; }
.badge-teal { background: rgba(15, 118, 110, 0.1); color: var(--primary); }

/* ------------------------------------------------------------------
   TOMBOL
------------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 10px;
  font: inherit;
  font-size: 13.2px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 14px 24px -18px rgba(15, 118, 110, 0.9); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #241809; }
.btn-outline { background: #fff; border-color: var(--line); color: var(--ink-soft); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: rgba(15, 118, 110, 0.05); }
.btn-danger { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 7px 12px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ------------------------------------------------------------------
   FORMULIR & TOOLBAR
------------------------------------------------------------------- */

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .full, .grid-3 > .full, .grid-4 > .full { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field label { font-size: 12.2px; font-weight: 700; color: var(--ink-soft); }

.field input[type="text"],
.field input[type="password"],
.field input[type="email"],
.field input[type="number"],
.field input[type="date"],
.field input[type="tel"],
.field input[type="url"],
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fbfdfd;
  font: inherit;
  font-size: 13.8px;
  color: var(--ink);
}

.field textarea { min-height: 92px; resize: vertical; }

.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364798a' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  background-size: 15px;
  cursor: pointer;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.field .hint { font-size: 11.5px; color: var(--muted); }

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}

.toolbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-actions .btn { flex: none; }

.search {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 4px 4px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
}

.search input { border: 0; outline: none; background: transparent; font: inherit; font-size: 13px; color: var(--ink); width: 180px; }
.search button { border: 0; border-radius: 999px; padding: 7px 14px; background: var(--primary); color: #fff; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }

.filter-pills { display: flex; gap: 5px; flex-wrap: wrap; }
.filter-pill {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
}
.filter-pill:hover { border-color: var(--primary); color: var(--primary); }
.filter-pill.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }

.empty { padding: 44px 22px; text-align: center; color: var(--muted); font-size: 13.8px; }

.pagination { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; padding: 16px 22px; border-top: 1px solid var(--line); }
.page-link {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-soft);
}
.page-link:hover { border-color: var(--primary); color: var(--primary); }
.page-link.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-dots { display: grid; place-items: center; min-width: 26px; color: var(--muted); }

/* ------------------------------------------------------------------
   GRAFIK SEDERHANA
------------------------------------------------------------------- */

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  height: 190px;
  padding: 10px 4px 0;
}

.chart-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; height: 100%; min-width: 0; }

.chart-pair { display: flex; align-items: flex-end; gap: 3px; height: 100%; }

.chart-bar { flex: 1; border-radius: 5px 5px 2px 2px; min-height: 2px; }
.chart-bar.in { background: var(--primary); }
.chart-bar.out { background: var(--accent); }

.chart-label { text-align: center; font-size: 10.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

/* ------------------------------------------------------------------
   LOGIN & HALAMAN SEDERHANA
------------------------------------------------------------------- */

.simple-body { background: var(--bg); min-height: 100vh; }
.simple-wrap { max-width: 460px; margin: 0 auto; padding: 48px 18px 60px; }
.simple-wide { max-width: 820px; }

.login-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 34px 30px;
  box-shadow: 0 40px 70px -55px rgba(6, 42, 47, 0.6);
}

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-brand-mark { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 13px; background: var(--primary); color: #fff; flex: none; }
.login-brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.login-brand-text strong { font-size: 15px; }
.login-brand-text small { font-size: 11.5px; color: var(--muted); }

.login-card h1 { font-size: 20px; }
.login-sub { margin: 5px 0 22px; font-size: 13px; color: var(--muted); }

.login-form { display: grid; gap: 14px; }

.login-foot { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--muted); }
.login-foot a { color: var(--primary); font-weight: 700; }

/* ------------------------------------------------------------------
   KUITANSI CETAK
------------------------------------------------------------------- */

.kuitansi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 34px;
  max-width: 780px;
  margin: 0 auto;
}

.kuitansi-head { display: flex; justify-content: space-between; gap: 20px; border-bottom: 2px solid var(--ink); padding-bottom: 16px; margin-bottom: 22px; }
.kuitansi-head h2 { font-size: 18px; }
.kuitansi-head p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.kuitansi-no { text-align: right; flex: none; }
.kuitansi-no strong { display: block; font-size: 15px; }
.kuitansi-no small { font-size: 11.5px; color: var(--muted); }

.kuitansi-table { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-bottom: 18px; }
.kuitansi-table th, .kuitansi-table td { border: 1px solid var(--line); padding: 9px 12px; text-align: left; vertical-align: top; }
.kuitansi-table th { background: #f8fbfb; width: 190px; font-weight: 700; color: var(--ink-soft); font-size: 12.5px; }

.kuitansi-total { border-top: 2px solid var(--ink); padding-top: 12px; display: flex; justify-content: space-between; font-weight: 800; font-size: 15px; }

.kuitansi-sign { display: flex; justify-content: space-between; gap: 20px; margin-top: 46px; font-size: 13px; text-align: center; }
.kuitansi-sign div { flex: 1; }
.kuitansi-sign span { display: block; margin-top: 62px; border-top: 1px solid var(--ink); padding-top: 6px; }

.kuitansi-note { margin-top: 20px; font-size: 11.5px; color: var(--muted); text-align: center; }

/* ------------------------------------------------------------------
   RESPONSIF
------------------------------------------------------------------- */

@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 1000px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1); box-shadow: 20px 0 50px -30px rgba(0, 0, 0, 0.6); }
  .sidebar-open .sidebar { transform: none; }
  body.sidebar-open::after { content: ""; position: fixed; inset: 0; z-index: 35; background: rgba(4, 24, 27, 0.45); }
  .app-main { margin-left: 0; }
  .burger { display: flex; }
  .topbar { padding: 13px 18px; }
  .app-content { padding: 20px 18px 34px; }
  .app-footer { padding: 14px 18px; }
  .topbar-user-text { display: none; }
}

@media (max-width: 820px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .card-head, .toolbar { padding: 15px 18px; }
  .card-body { padding: 18px; }
  .search { width: 100%; }
  .search input { width: 100%; }
  .kuitansi { padding: 22px 18px; }
}

@media (max-width: 560px) {
  .topbar-title p { display: none; }
  .topbar-title h1 { font-size: 16.5px; }
  .table th, .table td { padding: 10px 11px; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn { flex: 1; }
  .form-actions .btn { width: 100%; }
  .kuitansi-head { flex-direction: column; }
  .kuitansi-no { text-align: left; }
  .chart-bars { gap: 6px; }
}

/* ------------------------------------------------------------------
   CETAK
------------------------------------------------------------------- */

@media print {
  body { background: #fff; }
  .sidebar, .topbar, .app-footer, .no-print, .alert { display: none !important; }
  .app-main { margin: 0; }
  .app-content { padding: 0; }
  .kuitansi { border: 0; padding: 0; max-width: none; }
  .card { border: 0; }
  .card-head { padding: 0 0 12px; }
  .card-body { padding: 0; }
  .table th { background: #f3f4f6 !important; }
}
