:root {
  --erp-primary: #1a237e;
  --erp-primary-light: #534bae;
  --erp-sidebar: #0d1117;
  --erp-sidebar-hover: #161b22;
  --erp-sidebar-text: #c9d1d9;
  --erp-sidebar-active: #1f6feb;
  --erp-accent: #4caf50;
  --erp-danger: #f44336;
  --erp-warning: #ff9800;
  --erp-info: #0288d1;
  --erp-card-bg: #ffffff;
  --erp-body-bg: #f4f6f9;
  --erp-border: #e3e6ec;
  --sidebar-w: 256px;
}

* { box-sizing: border-box; }

body {
  background: var(--erp-body-bg);
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  color: #1f2937;
  margin: 0;
}

/* ---------------- Layout shell ---------------- */
.erp-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--erp-sidebar);
  color: var(--erp-sidebar-text);
  overflow-y: auto;
  z-index: 1040;
  transition: transform .25s ease;
}
.erp-sidebar::-webkit-scrollbar { width: 6px; }
.erp-sidebar::-webkit-scrollbar-thumb { background: #30363d; border-radius: 3px; }

.erp-brand {
  display: flex; align-items: center; gap: .6rem;
  padding: 1.1rem 1.25rem;
  font-weight: 700; font-size: 1.15rem; color: #fff;
  border-bottom: 1px solid #21262d;
  letter-spacing: .3px;
}
.erp-brand .logo-badge {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--erp-sidebar-active), var(--erp-primary-light));
  display: grid; place-items: center; color: #fff; font-size: 1.1rem;
}

.erp-nav { padding: .5rem 0 2rem; list-style: none; margin: 0; }
.erp-nav .nav-section {
  padding: .9rem 1.25rem .35rem;
  font-size: .68rem; text-transform: uppercase; letter-spacing: .08em;
  color: #6e7681; font-weight: 600;
}
.erp-nav a {
  display: flex; align-items: center; gap: .7rem;
  padding: .55rem 1.25rem;
  color: var(--erp-sidebar-text); text-decoration: none;
  font-size: .9rem; border-left: 3px solid transparent;
}
.erp-nav a:hover { background: var(--erp-sidebar-hover); color: #fff; }
.erp-nav a.active {
  background: var(--erp-sidebar-hover); color: #fff;
  border-left-color: var(--erp-sidebar-active);
}
.erp-nav a i { width: 18px; text-align: center; font-size: 1rem; }
.erp-nav .submenu { list-style: none; margin: 0; padding: 0; background: #010409; }
.erp-nav .submenu a { padding-left: 3rem; font-size: .85rem; }
.erp-nav .has-sub > a::after {
  content: "\F282"; font-family: "bootstrap-icons"; margin-left: auto;
  font-size: .7rem; transition: transform .2s;
}
.erp-nav .has-sub.open > a::after { transform: rotate(90deg); }

/* ---------------- Topbar ---------------- */
.erp-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.erp-topbar {
  background: #fff;
  height: 60px;
  display: flex; align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--erp-border);
  position: sticky; top: 0; z-index: 1030;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.erp-topbar .page-title { font-weight: 600; font-size: 1.05rem; margin: 0; color: #111827; }
.erp-topbar .breadcrumb { margin: 0; font-size: .78rem; }
.erp-content { padding: 1.5rem; flex: 1; }

.erp-user-chip {
  display: flex; align-items: center; gap: .5rem;
  cursor: pointer; padding: .3rem .5rem; border-radius: 8px;
}
.erp-user-chip:hover { background: var(--erp-body-bg); }
.erp-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--erp-primary); color: #fff;
  display: grid; place-items: center; font-weight: 600;
}

/* ---------------- Cards / KPIs ---------------- */
.card { border: 1px solid var(--erp-border); border-radius: 12px; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--erp-border); font-weight: 600; }

.kpi-card {
  background: #fff; border-radius: 12px; padding: 1.1rem 1.25rem;
  border: 1px solid var(--erp-border); height: 100%;
  position: relative; overflow: hidden;
}
.kpi-card .kpi-icon {
  position: absolute; right: 1rem; top: 1rem;
  width: 44px; height: 44px; border-radius: 10px;
  display: grid; place-items: center; font-size: 1.3rem; color: #fff;
}
.kpi-card .kpi-label { color: #6b7280; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi-card .kpi-value { font-size: 1.5rem; font-weight: 700; color: #111827; margin: .25rem 0; }
.kpi-card .kpi-trend { font-size: .8rem; }
.bg-grad-blue   { background: linear-gradient(135deg,#1a237e,#534bae); }
.bg-grad-green  { background: linear-gradient(135deg,#2e7d32,#66bb6a); }
.bg-grad-orange { background: linear-gradient(135deg,#e65100,#ff9800); }
.bg-grad-red    { background: linear-gradient(135deg,#b71c1c,#ef5350); }
.bg-grad-teal   { background: linear-gradient(135deg,#00695c,#26a69a); }
.bg-grad-purple { background: linear-gradient(135deg,#4a148c,#ab47bc); }

/* ---------------- Tables ---------------- */
.table { font-size: .875rem; }
.table > thead { background: #f8f9fb; }
.table > thead th { font-weight: 600; color: #475467; text-transform: uppercase; font-size: .72rem; letter-spacing: .03em; border-bottom: 2px solid var(--erp-border); }
.table-hover tbody tr:hover { background: #f6f9ff; }
.amount { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }

/* ---------------- Buttons ---------------- */
.btn-primary { background: var(--erp-primary); border-color: var(--erp-primary); }
.btn-primary:hover { background: #151c66; border-color: #151c66; }
.btn-erp-soft { background: #eef2ff; color: var(--erp-primary); border: 1px solid #dfe6ff; }

/* ---------------- Forms ---------------- */
.form-label { font-size: .82rem; font-weight: 600; color: #374151; margin-bottom: .25rem; }
.form-control, .form-select { font-size: .875rem; }
.required::after { content: " *"; color: var(--erp-danger); }

/* ---------------- Auth ---------------- */
.auth-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 10% -10%, #283593 0%, transparent 55%),
              radial-gradient(1000px 500px at 110% 110%, #1f6feb 0%, transparent 50%),
              #0d1117;
  padding: 1rem;
}
.auth-card {
  width: 100%; max-width: 410px; background: #fff;
  border-radius: 16px; padding: 2.25rem; box-shadow: 0 24px 60px rgba(0,0,0,.35);
}
.auth-logo { width: 56px; height: 56px; border-radius: 14px;
  background: linear-gradient(135deg, var(--erp-primary), var(--erp-sidebar-active));
  display: grid; place-items: center; color: #fff; font-size: 1.6rem; margin: 0 auto 1rem; }

/* ---------------- Misc ---------------- */
.report-table td, .report-table th { padding: .4rem .6rem; }
.section-total td { font-weight: 700; border-top: 2px solid #111827; border-bottom: 2px solid #111827; }
.tree-toggle { cursor: pointer; user-select: none; }
.coa-row[data-header="1"] { background: #f3f4f6; font-weight: 600; }

@media (max-width: 991px) {
  .erp-sidebar { transform: translateX(-100%); }
  .erp-sidebar.show { transform: translateX(0); }
  .erp-main { margin-left: 0; }
}

/* Print */
@media print {
  .erp-sidebar, .erp-topbar, .no-print { display: none !important; }
  .erp-main { margin-left: 0; }
  .erp-content { padding: 0; }
  body { background: #fff; }
}
