/* =========================================================
   HutangPiutang — Tema Neobrutalism
   Palet: krem dasar, aksen kuning/hijau/merah muda, garis tebal hitam,
   bayangan keras (hard shadow), tanpa gradasi, tanpa border-radius besar.
   ========================================================= */

:root {
  --ink: #111111;
  --bg: #F5F1E8;
  --surface: #FFFFFF;
  --yellow: #FFD447;
  --pink: #FF6B9D;
  --green: #7DDE92;
  --blue: #6EC6FF;
  --red: #FF5A5A;
  --purple: #B39CFF;
  --border-w: 3px;
  --shadow-off: 5px;
  --radius: 2px;
  --font-display: 'Space Grotesk', 'Arial Black', sans-serif;
  --font-body: 'Work Sans', 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  margin: 0 0 .5em;
  line-height: 1.15;
}

a { color: inherit; text-decoration: none; }

.hard-border {
  border: var(--border-w) solid var(--ink);
  border-radius: var(--radius);
}

.hard-shadow {
  box-shadow: var(--shadow-off) var(--shadow-off) 0 0 var(--ink);
}

.hard-shadow-sm {
  box-shadow: 3px 3px 0 0 var(--ink);
}

/* =========================
   LAYOUT
   ========================= */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--ink);
  color: #fff;
  border-right: var(--border-w) solid var(--ink);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}

.sidebar-brand {
  padding: 22px 20px;
  border-bottom: var(--border-w) solid #333;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand .logo-box {
  background: var(--yellow);
  color: var(--ink);
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  border: 2.5px solid #fff;
  transform: rotate(-4deg);
}

.sidebar-brand span {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.2rem;
  color: #fff;
}

.sidebar-nav {
  padding: 16px 12px;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 8px;
  color: #ddd;
  font-weight: 600;
  border: 2.5px solid transparent;
}

.sidebar-nav a .ico { font-size: 1.1rem; width: 22px; text-align: center; }

.sidebar-nav a:hover {
  background: #222;
  color: #fff;
}

.sidebar-nav a.active {
  background: var(--yellow);
  color: var(--ink);
  border-color: #fff;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: var(--border-w) solid #333;
}

.sidebar-user {
  display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
}

.sidebar-user .avatar {
  width: 34px; height: 34px;
  background: var(--pink);
  border: 2px solid #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--ink);
  flex-shrink: 0;
}

.sidebar-user .nama { font-size: .85rem; color: #fff; font-weight: 600; }
.sidebar-user .role { font-size: .72rem; color: #999; text-transform: uppercase; letter-spacing: .04em; }

.btn-logout-side {
  display: block;
  text-align: center;
  background: var(--red);
  color: var(--ink);
  font-weight: 700;
  padding: 10px;
  border: 2.5px solid #fff;
}

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

.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: var(--surface);
  border-bottom: var(--border-w) solid var(--ink);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.hamburger {
  background: var(--yellow);
  border: 2.5px solid var(--ink);
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  cursor: pointer;
}

.page-wrap {
  padding: 26px 32px 60px;
  max-width: 1200px;
  width: 100%;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 24px;
}

.page-header h1 { font-size: 1.8rem; }
.page-header .subtitle { color: #555; font-weight: 500; margin-top: -8px; }

/* =========================
   COMPONENTS
   ========================= */

.card {
  background: var(--surface);
  border: var(--border-w) solid var(--ink);
  box-shadow: var(--shadow-off) var(--shadow-off) 0 0 var(--ink);
  padding: 20px;
  margin-bottom: 22px;
}

.card-flat {
  background: var(--surface);
  border: var(--border-w) solid var(--ink);
  padding: 20px;
  margin-bottom: 22px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 26px;
}

.stat-card {
  border: var(--border-w) solid var(--ink);
  box-shadow: var(--shadow-off) var(--shadow-off) 0 0 var(--ink);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.stat-card .label {
  font-weight: 700;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-bottom: 6px;
}

.stat-card .value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
}

.stat-card .desc { font-size: .8rem; margin-top: 4px; font-weight: 500; opacity: .8;}

.stat-card.c-yellow { background: var(--yellow); }
.stat-card.c-pink { background: var(--pink); }
.stat-card.c-green { background: var(--green); }
.stat-card.c-blue { background: var(--blue); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-weight: 700;
  padding: 11px 18px;
  border: var(--border-w) solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 4px 4px 0 0 var(--ink);
  transition: transform .08s ease, box-shadow .08s ease;
  font-size: .92rem;
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 0 var(--ink);
}

.btn-sm { padding: 7px 12px; font-size: .82rem; box-shadow: 3px 3px 0 0 var(--ink); }
.btn-sm:active { box-shadow: 1px 1px 0 0 var(--ink); }

.btn-primary { background: var(--yellow); }
.btn-success { background: var(--green); }
.btn-danger { background: var(--red); }
.btn-info { background: var(--blue); }
.btn-pink { background: var(--pink); }
.btn-outline { background: var(--surface); }
.btn-block { width: 100%; justify-content: center; }

.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: .74rem;
  font-weight: 700;
  border: 2px solid var(--ink);
  text-transform: uppercase;
  letter-spacing: .02em;
}
.badge-red { background: var(--red); }
.badge-yellow { background: var(--yellow); }
.badge-green { background: var(--green); }
.badge-gray { background: #ddd; }
.badge-tipe-pel { background: var(--blue); }
.badge-tipe-sup { background: var(--purple); }

/* Forms */
label { display: block; font-weight: 700; margin-bottom: 6px; font-size: .88rem; }
.form-group { margin-bottom: 18px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.form-control, select.form-control, textarea.form-control {
  width: 100%;
  padding: 11px 12px;
  border: var(--border-w) solid var(--ink);
  background: var(--surface);
  font-family: var(--font-body);
  font-size: .95rem;
  color: var(--ink);
}

.form-control:focus {
  outline: none;
  box-shadow: 3px 3px 0 0 var(--ink);
}

textarea.form-control { resize: vertical; min-height: 80px; }

.helper-text { font-size: .78rem; color: #666; margin-top: 4px; }

/* Table */
.table-wrap {
  overflow-x: auto;
  border: var(--border-w) solid var(--ink);
  box-shadow: var(--shadow-off) var(--shadow-off) 0 0 var(--ink);
}

table.tbl {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
  background: var(--surface);
}

table.tbl th {
  text-align: left;
  background: var(--ink);
  color: #fff;
  padding: 12px 14px;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  white-space: nowrap;
}

table.tbl td {
  padding: 12px 14px;
  border-bottom: 2px solid #eee;
  font-size: .92rem;
  vertical-align: middle;
}

table.tbl tbody tr:hover { background: #FBF8F0; }
table.tbl tbody tr:last-child td { border-bottom: none; }

.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }

/* Alert / Flash */
.alert {
  border: var(--border-w) solid var(--ink);
  padding: 14px 16px;
  margin-bottom: 20px;
  font-weight: 600;
  box-shadow: 4px 4px 0 0 var(--ink);
}
.alert-success { background: var(--green); }
.alert-error { background: var(--red); }
.alert-info { background: var(--blue); }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  border: var(--border-w) dashed var(--ink);
}
.empty-state .emoji { font-size: 2.6rem; margin-bottom: 10px; }
.empty-state p { font-weight: 600; margin-bottom: 16px; }

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-wrap::before,
.login-wrap::after {
  content: '';
  position: absolute;
  border: var(--border-w) solid var(--ink);
}
.login-wrap::before {
  width: 160px; height: 160px;
  background: var(--yellow);
  top: -50px; left: -50px;
  transform: rotate(15deg);
}
.login-wrap::after {
  width: 220px; height: 220px;
  background: var(--pink);
  bottom: -80px; right: -80px;
  transform: rotate(20deg);
}

.login-card {
  background: var(--surface);
  border: var(--border-w) solid var(--ink);
  box-shadow: 8px 8px 0 0 var(--ink);
  padding: 36px 32px;
  width: 100%;
  max-width: 400px;
  position: relative;
  z-index: 2;
}

.login-card .logo-box {
  background: var(--ink);
  color: var(--yellow);
  width: 54px; height: 54px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.4rem;
  margin-bottom: 18px;
  border: 3px solid var(--ink);
}

.login-card h1 { font-size: 1.5rem; margin-bottom: 4px; }
.login-card .sub { color: #666; font-weight: 500; margin-bottom: 26px; font-size: .9rem; }

.login-hint {
  margin-top: 20px;
  font-size: .8rem;
  color: #666;
  background: #FBF3D9;
  border: 2px solid var(--ink);
  padding: 10px 12px;
}

/* Faktur cetak */
.faktur-doc {
  max-width: 780px;
  margin: 0 auto;
  background: #fff;
  border: var(--border-w) solid var(--ink);
  box-shadow: var(--shadow-off) var(--shadow-off) 0 0 var(--ink);
  padding: 36px;
}
.faktur-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: var(--border-w) solid var(--ink);
  padding-bottom: 20px; margin-bottom: 24px;
  flex-wrap: wrap; gap: 16px;
}
.faktur-head .brand { font-family: var(--font-display); font-size: 1.5rem; }
.faktur-meta { text-align: right; }
.faktur-meta .no { font-family: var(--font-display); font-size: 1.2rem; }
.faktur-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 24px; }
.faktur-parties h4 { font-size: .78rem; text-transform: uppercase; color: #777; margin-bottom: 6px; }
.faktur-total-row td { font-family: var(--font-display); font-size: 1.1rem; }
.print-bar { max-width: 780px; margin: 0 auto 16px; display: flex; justify-content: flex-end; gap: 10px; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  .faktur-doc { box-shadow: none; border: 2px solid #000; margin: 0; max-width: 100%; }
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  align-items: flex-end;
}
.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 160px; }

/* Item rows (form faktur) */
.item-row {
  display: grid;
  grid-template-columns: 1fr 90px 130px 130px 40px;
  gap: 10px;
  margin-bottom: 10px;
  align-items: start;
}
.item-row-head {
  display: grid;
  grid-template-columns: 1fr 90px 130px 130px 40px;
  gap: 10px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #666;
  margin-bottom: 8px;
}
.btn-remove-item {
  background: var(--red);
  border: 2.5px solid var(--ink);
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 2px 2px 0 0 var(--ink);
}
.item-subtotal-display {
  padding: 11px 12px;
  border: var(--border-w) solid var(--ink);
  background: #F5F1E8;
  font-weight: 700;
  font-size: .92rem;
}
.item-total-bar {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  padding-top: 14px;
  margin-top: 6px;
  border-top: 2.5px dashed var(--ink);
  font-family: var(--font-display);
  font-size: 1.15rem;
}

/* Dashboard recent list */
.recent-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 2px solid #eee;
  gap: 10px;
  flex-wrap: wrap;
}
.recent-item:last-child { border-bottom: none; }
.recent-item .nm { font-weight: 700; }
.recent-item .sub { font-size: .78rem; color: #777; }

.two-col {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 22px;
}

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}

/* Mobile overlay for sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 95;
}
.sidebar-overlay.show { display: block; }

/* =========================
   RESPONSIVE
   ========================= */
@media (max-width: 900px) {
  .two-col { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar { display: flex; }
  .page-wrap { padding: 20px 16px 50px; }
  .item-row, .item-row-head {
    grid-template-columns: 1fr;
  }
  .item-row { border-bottom: 2.5px dashed var(--ink); padding-bottom: 12px; }
  .item-row-head { display: none; }
  .btn-remove-item { width: 100%; }
  .faktur-doc { padding: 20px; }
  .faktur-parties { grid-template-columns: 1fr; }
  .stat-card .value { font-size: 1.4rem; }
}

@media (max-width: 480px) {
  .login-card { padding: 26px 20px; }
  .page-header h1 { font-size: 1.5rem; }
}
