:root {
  --navy-900: #131c33;
  --navy-800: #1b2a4a;
  --navy-700: #24365f;
  --gold-500: #dfa14b;
  --gold-600: #c88a36;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --border: #e2e6ed;
  --text: #1c2333;
  --text-muted: #6b7280;
  --success: #2e7d5b;
  --success-bg: #e6f4ee;
  --danger: #c1443d;
  --danger-bg: #fbeae9;
  --warn: #b8862b;
  --warn-bg: #fbf1de;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(19, 28, 51, 0.06), 0 4px 12px rgba(19, 28, 51, 0.04);
  --font-display: "Poppins", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  margin: 0 0 4px;
  font-weight: 600;
}
p {
  margin: 0;
}
a {
  color: inherit;
}
button {
  font-family: inherit;
  cursor: pointer;
}
input,
select,
textarea {
  font-family: inherit;
}

/* ---- Login screen ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(
    circle at 20% 20%,
    var(--navy-700),
    var(--navy-900) 60%
  );
}
.login-card {
  width: 380px;
  background: var(--surface);
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.login-brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 6px;
}
.login-brand .mark {
  color: var(--gold-600);
  font-family: var(--font-display);
  font-weight: 700;
}
.login-sub {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-bottom: 28px;
}
.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.field input,
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fbfbfd;
}
.field input:focus,
.field select:focus {
  outline: 2px solid var(--gold-500);
  outline-offset: 1px;
  border-color: var(--gold-500);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  transition:
    transform 0.05s ease,
    filter 0.15s ease;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  background: var(--navy-800);
  color: #fff;
}
.btn-primary:hover {
  filter: brightness(1.15);
}
.btn-gold {
  background: var(--gold-500);
  color: #241505;
}
.btn-gold:hover {
  filter: brightness(1.08);
}
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
}
.btn-outline:hover {
  border-color: var(--navy-700);
}
.btn-danger {
  background: var(--danger-bg);
  color: var(--danger);
}
.btn-danger:hover {
  filter: brightness(0.97);
}
.btn-block {
  width: 100%;
}
.btn-sm {
  padding: 6px 10px;
  font-size: 12.5px;
  border-radius: 6px;
}
.error-msg {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}
.success-msg {
  background: var(--success-bg);
  color: var(--success);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}
.login-hint {
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ---- App shell ---- */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--navy-900);
  color: #cdd6e8;
  display: flex;
  flex-direction: column;
  padding: 22px 14px;
}
.sidebar-brand {
  display: flex;
  align-items: baseline;
  gap: 6px;
  padding: 0 10px 22px;
}
.sidebar-brand .mark {
  color: var(--gold-500);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
}
.sidebar-brand .rest {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  color: #fff;
}
.nav-group {
  margin-bottom: 6px;
}
.nav-group-label {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6f7c99;
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13.5px;
  color: #cdd6e8;
  text-decoration: none;
  cursor: pointer;
  margin-bottom: 2px;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.nav-item.active {
  background: var(--gold-500);
  color: #241505;
  font-weight: 600;
}
.sidebar-footer {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-user {
  font-size: 12.5px;
  color: #a9b4cc;
  margin-bottom: 8px;
}
.sidebar-user strong {
  display: block;
  color: #fff;
  font-size: 13.5px;
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}
.topbar h2 {
  font-size: 17px;
}
.content {
  padding: 24px;
  flex: 1;
  overflow-y: auto;
}

/* ---- Cards / tables ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card h3 {
  font-size: 14.5px;
  margin-bottom: 12px;
}
.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-card .label {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.stat-card .value {
  font-size: 22px;
  font-weight: 700;
  font-family: var(--font-display);
}
.stat-card .accent {
  color: var(--gold-600);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
thead th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
}
tbody td {
  padding: 10px;
  border-bottom: 1px solid #f0f1f5;
}
tbody tr:hover {
  background: #fafbfd;
}
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-success {
  background: var(--success-bg);
  color: var(--success);
}
.badge-danger {
  background: var(--danger-bg);
  color: var(--danger);
}
.badge-warn {
  background: var(--warn-bg);
  color: var(--warn);
}
.badge-muted {
  background: #eef0f4;
  color: var(--text-muted);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.toolbar .left {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.tag-input {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  background: #fbfbfd;
}
.tag-input input {
  border: none;
  background: transparent;
  padding: 9px 10px;
  font-size: 13.5px;
  flex: 1;
}
.tag-input input:focus {
  outline: none;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state .icon {
  font-size: 30px;
  margin-bottom: 10px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(19, 28, 51, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  width: 420px;
  max-width: 92vw;
  background: #fff;
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
  max-height: 88vh;
  overflow-y: auto;
}
.modal h3 {
  margin-bottom: 16px;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.tab {
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active {
  color: var(--navy-800);
  border-color: var(--gold-500);
}

.nota-preview {
  font-family: "Courier New", monospace;
  font-size: 12.5px;
  background: #fbfbfd;
  border: 1px dashed var(--border);
  padding: 16px;
  border-radius: 8px;
}
.nota-preview .center {
  text-align: center;
}
.nota-preview .line {
  border-top: 1px dashed #999;
  margin: 8px 0;
}
.nota-preview .row {
  display: flex;
  justify-content: space-between;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 140px;
  padding-top: 10px;
}
.bar-chart .bar {
  flex: 1;
  background: linear-gradient(180deg, var(--gold-500), var(--gold-600));
  border-radius: 4px 4px 0 0;
  position: relative;
  min-height: 2px;
}
.bar-chart .bar span {
  position: absolute;
  top: -18px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 10.5px;
  color: var(--text-muted);
}
.bar-labels {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.bar-labels span {
  flex: 1;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
}

/* ===== Table scroll wrapper for wide tables ===== */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table-wrap table {
  min-width: 700px;
}

/* ===== Saldo 2-column grid layout ===== */
.saldo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.saldo-grid .card {
  margin-bottom: 0;
}
@media (max-width: 700px) {
  .saldo-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Riwayat Saldo card items ===== */
.saldo-riwayat-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  background: var(--surface);
}
.saldo-riwayat-item:last-child {
  margin-bottom: 0;
}
.saldo-riwayat-item .riwayat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}
.saldo-riwayat-item .riwayat-waktu {
  font-size: 11.5px;
  color: var(--text-muted);
}
.saldo-riwayat-item .riwayat-shift {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.saldo-riwayat-item .riwayat-nominal {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font-display);
  margin: 6px 0;
}
.saldo-riwayat-item .riwayat-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.saldo-riwayat-item .riwayat-detail .label {
  color: var(--text-muted);
  font-size: 11px;
}
.saldo-riwayat-item .riwayat-user {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: right;
}

/* ===== Saldo table compact styling ===== */
table.table-saldo {
  font-size: 12.5px;
  width: 100%;
}
table.table-saldo th,
table.table-saldo td {
  padding: 6px 8px;
  white-space: nowrap;
}
table.table-saldo th {
  font-size: 10.5px;
}
table.table-saldo td.td-center {
  text-align: center;
}
table.table-saldo td.td-nominal {
  text-align: right;
  font-weight: 600;
  white-space: nowrap;
}
table.table-saldo td.td-saldo {
  font-size: 11.5px;
  white-space: nowrap;
  text-align: center;
}
table.table-saldo td.td-nowrap {
  white-space: nowrap;
}

@media (max-width: 860px) {
  .sidebar {
    display: none;
  }
  .content {
    padding: 16px;
  }
}

@media print {
  body * {
    visibility: hidden;
  }

  #nota-container,
  #nota-container * {
    visibility: visible;
  }

  #nota-container {
    position: absolute;
    left: 0;
    top: 0;
    width: 80mm;
  }

  .btn {
    display: none !important;
  }
}
