:root {
  --brand: #0f9b6e;
  --brand-dark: #0b7a56;
  --brand-light: #e6f7f0;
  --ink: #0b1120;
  --ink-soft: #1b2740;
  --paper: #f5f7fa;
  --card: #ffffff;
  --border: #e6e9ee;
  --text: #1a2233;
  --text-muted: #667085;
  --gold: #d4a94c;
  --red: #d0392b;
  --blue: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--paper);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }

/* ================= Login ================= */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
@media (max-width: 900px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
}

.login-brand {
  position: relative;
  overflow: hidden;
  background: radial-gradient(1200px 800px at 15% 15%, #12312a 0%, var(--ink) 55%),
              linear-gradient(160deg, var(--ink) 0%, #0d1a2b 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 56px;
}
.login-brand::before, .login-brand::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .35;
  animation: drift 18s ease-in-out infinite alternate;
}
.login-brand::before {
  width: 420px; height: 420px;
  background: var(--brand);
  top: -120px; right: -120px;
}
.login-brand::after {
  width: 360px; height: 360px;
  background: var(--gold);
  bottom: -140px; left: -80px;
  animation-delay: -9s;
}
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(30px, -20px) scale(1.08); }
}

.login-brand-top { position: relative; z-index: 1; display: flex; align-items: center; gap: 14px; }
.login-brand-tagline { position: relative; z-index: 1; max-width: 420px; }
.login-brand-tagline h1 { font-size: 34px; line-height: 1.25; margin: 0 0 14px; font-weight: 700; letter-spacing: -.01em; }
.login-brand-tagline p { font-size: 15px; color: rgba(255,255,255,.7); margin: 0; }
.login-brand-foot { position: relative; z-index: 1; font-size: 12px; color: rgba(255,255,255,.5); }

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background: var(--card);
}
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.01em; }
.login-card .sub { color: var(--text-muted); font-size: 14px; margin: 0 0 32px; }

.field { margin-bottom: 18px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 7px; }
.field input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14.5px;
  font-family: var(--font);
  transition: border-color .15s, box-shadow .15s;
  background: #fbfcfd;
}
.field input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-light);
  background: #fff;
}

.btn-block { width: 100%; }
.login-hint {
  margin-top: 22px;
  font-size: 12.5px;
  color: var(--text-muted);
  background: var(--paper);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}

.alert { padding: 11px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 18px; font-weight: 500; }
.alert-error { background: #fdedec; color: var(--red); border: 1px solid #f6cfc9; }
.alert-success { background: #e9f9f1; color: #0d7a4f; border: 1px solid #bfe9d3; }

/* ================= Brand mark ================= */
.brandmark {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--brand), var(--brand-dark));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -.02em;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(15,155,110,.35);
}
.brandmark img { width: 100%; height: 100%; object-fit: cover; border-radius: 10px; }
.brandname { font-weight: 700; font-size: 16px; color: #fff; letter-spacing: -.01em; }

/* ================= App shell ================= */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--ink);
  color: #b9c2d4;
  display: flex;
  flex-direction: column;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.06); }
.sidebar-brand .brandname { font-size: 15px; line-height: 1.25; }

.sidebar nav { padding: 14px 10px; flex: 1; overflow-y: auto; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #5b6579; padding: 14px 12px 6px; }
.nav-section:first-child { padding-top: 4px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #b9c2d4;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
}
.sidebar nav a .ico { width: 18px; text-align: center; opacity: .85; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar nav a.active .ico { opacity: 1; }

.nav-logout {
  margin: 12px;
  padding: 10px 12px;
  background: transparent;
  border: 1px solid rgba(255,255,255,.12);
  color: #b9c2d4;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-size: 13.5px;
  font-family: var(--font);
}
.nav-logout:hover { background: rgba(255,255,255,.06); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--card);
  padding: 16px 28px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.topbar-title { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.topbar-user { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 10px; }
.user-chip {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--brand-light); color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.content { padding: 26px 28px; flex: 1; }
.app-footer { padding: 16px 28px; font-size: 12px; color: var(--text-muted); text-align: center; }

/* ================= Cards / stats ================= */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: var(--brand);
}
.stat-card.c-blue::before { background: var(--blue); }
.stat-card.c-gold::before { background: var(--gold); }
.stat-card.c-red::before { background: var(--red); }
.stat-card .label { font-size: 11.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-card .value { font-size: 23px; font-weight: 700; margin-top: 8px; letter-spacing: -.01em; }
.stat-card .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 22px;
}
.panel h2 { margin: 0 0 16px; font-size: 15px; font-weight: 700; }
.panel-flex { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.panel-flex h2 { margin: 0; }

/* ================= Tables ================= */
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 560px; }
.data-table th, .data-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.data-table th { background: var(--paper); font-weight: 700; color: var(--ink-soft); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.data-table tbody tr:hover { background: #fafcfe; }
.text-right { text-align: right; }
.debit { color: var(--red); font-weight: 600; }
.credit { color: #0d7a4f; font-weight: 600; }
.muted { color: var(--text-muted); }

/* ================= Page header ================= */
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-header h1 { font-size: 21px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.page-header .crumb { font-size: 12.5px; color: var(--text-muted); margin-bottom: 4px; }

/* ================= Buttons ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 8px; border: none;
  background: var(--brand); color: #fff; text-decoration: none;
  font-size: 13.5px; font-weight: 600; cursor: pointer;
  font-family: var(--font);
  transition: background .15s, transform .1s;
}
.btn:hover { background: var(--brand-dark); }
.btn:active { transform: scale(.98); }
.btn-secondary { background: var(--paper); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #eceff3; }
.btn-danger { background: #fdedec; color: var(--red); border: 1px solid #f6cfc9; }
.btn-danger:hover { background: #fbdedb; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.actions-cell { display: flex; gap: 6px; }

/* ================= Forms ================= */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; margin-bottom: 14px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: 12.5px; margin-bottom: 6px; color: var(--ink-soft); font-weight: 600; }
.form-group input, .form-group select, .form-group textarea {
  padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 13.5px; font-family: var(--font); background: #fbfcfd;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); background: #fff;
}

.alert-inline { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; font-weight: 500; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge-customer { background: #e6f0ff; color: #1a5fd1; }
.badge-supplier { background: #fff2e0; color: #b8641b; }
.badge-expense { background: #f3e6ff; color: #7d2fc7; }
.badge-other { background: var(--paper); color: #556; }
.badge-received { background: #e9f9f1; color: #0d7a4f; }
.badge-paid { background: #fff2e0; color: #b8641b; }

.line-items-table input { width: 100%; padding: 7px 9px; border: 1.5px solid var(--border); border-radius: 6px; font-size: 13px; }
.line-items-table td { padding: 6px; }
.line-items-total { text-align: right; font-size: 15px; font-weight: 700; margin-top: 8px; }
.line-items-total .amt { font-size: 20px; color: var(--brand-dark); }

.empty-state { padding: 40px 20px; text-align: center; color: var(--text-muted); font-size: 14px; }

/* ================= Pagination ================= */
.pagination { display: flex; gap: 6px; justify-content: flex-end; margin-top: 16px; }
.pagination a, .pagination span {
  padding: 6px 11px; border-radius: 6px; font-size: 13px; text-decoration: none;
  border: 1px solid var(--border); color: var(--text);
}
.pagination a:hover { background: var(--paper); }
.pagination .active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ================= Report cards ================= */
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.report-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; text-decoration: none; color: var(--text); box-shadow: var(--shadow);
  transition: transform .12s, box-shadow .12s;
}
.report-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.report-card .ico { font-size: 22px; margin-bottom: 10px; }
.report-card h3 { margin: 0 0 6px; font-size: 14.5px; }
.report-card p { margin: 0; font-size: 12.5px; color: var(--text-muted); }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.filter-bar .form-group { margin-bottom: 0; }

@media print {
  .sidebar, .topbar, .app-footer, .no-print { display: none !important; }
  .content { padding: 0; }
  .app-shell { display: block; }
  .panel { box-shadow: none; border: none; }
}
