/* ============ ECO MHR ERP — design system ============ */
:root {
  --bg: #eef1f5;
  --card: #ffffff;
  --border: #dde4ec;
  --navy: #14315c;
  --blue: #2563eb;
  --teal: #0d9488;
  --amber: #d97706;
  --red: #dc2626;
  --green: #15803d;
  --text: #1c2b3a;
  --muted: #5a6b7f;
  --shadow: 0 1px 3px rgba(20, 49, 92, .07), 0 4px 14px rgba(20, 49, 92, .05);
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
  overflow-x: hidden;
}
a { color: var(--blue); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 14px; padding: 9px 10px;
  border: 1px solid #c9d4e0; border-radius: 8px; width: 100%;
  background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(37, 99, 235, .25); border-color: var(--blue); }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin: 10px 0 4px; }
.boot-splash { padding: 60px; text-align: center; color: var(--muted); }

/* ---------- layout shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 218px; background: var(--navy); color: #cdd9ec; flex-shrink: 0;
  padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { color: #fff; font-weight: 700; font-size: 15px; padding: 4px 10px 16px; line-height: 1.3; }
.sidebar .brand small { display: block; color: #8fa7c9; font-weight: 400; font-size: 11px; }
.sidebar a.navlink {
  display: block; color: #cdd9ec; padding: 9px 10px; border-radius: 8px;
  font-size: 13.5px; margin-bottom: 2px;
}
.sidebar a.navlink:hover { background: rgba(255,255,255,.08); }
.sidebar a.navlink.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.main { flex: 1; min-width: 0; padding: 18px 22px 90px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px; gap: 10px; flex-wrap: wrap;
}
.topbar h1 { font-size: 19px; color: var(--navy); }
.topbar .meta { color: var(--muted); font-size: 12px; }

.mobile-topbar { display: none; }
.bottomnav { display: none; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; margin-bottom: 14px;
}
.card h3 { font-size: 14px; color: var(--navy); margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card h3 .sub { font-size: 11px; color: var(--muted); font-weight: 400; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

/* ---------- KPI cards ---------- */
.kpi {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px;
}
.kpi .k-label { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; display: flex; align-items: center; gap: 6px; }
.kpi .k-value { font-size: 21px; font-weight: 700; color: var(--navy); margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.kpi .k-sub .up { color: var(--green); } .kpi .k-sub .down { color: var(--red); } .kpi .k-sub .neutral { color: var(--muted); }
.badge {
  display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 7px;
  border-radius: 999px; letter-spacing: .03em;
}
.badge.amb { background: #fef3c7; color: #92400e; }
.badge.grn { background: #dcfce7; color: #166534; }
.badge.red { background: #fee2e2; color: #991b1b; }
.badge.blu { background: #dbeafe; color: #1e40af; }

/* ---------- cash & bank panel ---------- */
.cashpanel { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.cashpanel .cp-title { font-size: 12px; color: #9db4d6; margin-bottom: 8px; }
.cashpanel .cp-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.cashpanel .cp-item .v { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.cashpanel .cp-item .l { font-size: 11px; color: #9db4d6; margin-top: 3px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 14px; border-radius: 8px; border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; background: var(--navy); color: #fff;
}
.btn:hover { filter: brightness(1.08); }
.btn.sec { background: #fff; color: var(--navy); border-color: var(--border); }
.btn.teal { background: var(--teal); }
.btn.red { background: var(--red); }
.btn.amb { background: var(--amber); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.quick-actions { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 14px; }

/* ---------- tables & stacked cards ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 2px solid var(--border); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid #edf1f6; vertical-align: top; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: #f6f9fd; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl tfoot td { font-weight: 700; border-top: 2px solid var(--border); }

.txn-cards { display: none; }
.txn {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 12px; margin-bottom: 8px; box-shadow: var(--shadow);
}
.txn .t-top { display: flex; justify-content: space-between; gap: 8px; }
.txn .t-no { font-weight: 700; color: var(--navy); font-size: 13px; }
.txn .t-amt { font-weight: 700; font-variant-numeric: tabular-nums; }
.txn .t-mid { color: var(--text); font-size: 13px; margin-top: 4px; }
.txn .t-sub { color: var(--muted); font-size: 11.5px; margin-top: 4px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(15, 30, 55, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px 12px; z-index: 100; overflow-y: auto;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 620px;
  padding: 20px; box-shadow: 0 12px 40px rgba(0,0,0,.25); margin-bottom: 40px;
}
.modal h2 { font-size: 16px; color: var(--navy); margin-bottom: 12px; }
.modal .m-actions { display: flex; gap: 8px; margin-top: 16px; justify-content: flex-end; flex-wrap: wrap; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 12px; }
fieldset.adv { border: 1px dashed var(--border); border-radius: 10px; padding: 10px 12px; margin-top: 12px; }
fieldset.adv legend { font-size: 12px; font-weight: 700; color: var(--muted); padding: 0 6px; }
.chkline { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; }
.chkline input { width: auto; }

/* ---------- toast ---------- */
#toasts { position: fixed; bottom: 76px; left: 50%; transform: translateX(-50%); z-index: 200; width: min(420px, 92vw); }
.toast {
  background: #1f2937; color: #fff; padding: 11px 14px; border-radius: 10px;
  margin-top: 8px; font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.toast.err { background: #991b1b; }
.toast.ok { background: #14532d; }

/* ---------- dashboard specifics ---------- */
.period-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; font-size: 12.5px; font-weight: 600; color: var(--muted);
}
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.chart-box { position: relative; height: 220px; }
.chart-box.tall { height: 260px; }
.legend-list { margin-top: 10px; font-size: 12.5px; }
.legend-list .li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid #f0f3f8; gap: 8px; }
.legend-list .dot { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 7px; }
.agebar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; margin: 8px 0; }
.agebar span { display: block; }
.attn-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid #f0f3f8; cursor: pointer;
}
.attn-item .a-l { font-size: 13px; }
.attn-item .a-r { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.collapse-head { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
.muted { color: var(--muted); } .small { font-size: 12px; } .num { font-variant-numeric: tabular-nums; }
.neg { color: var(--red); } .pos { color: var(--green); }
.empty-state { text-align: center; color: var(--muted); padding: 28px 10px; font-size: 13px; }
.warn-strip { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; padding: 10px 12px; border-radius: 10px; font-size: 13px; margin-bottom: 12px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: #fff; border-radius: 14px; box-shadow: var(--shadow); padding: 28px; width: 100%; max-width: 380px; border: 1px solid var(--border); }
.login-card h1 { font-size: 19px; color: var(--navy); }
.login-card p { color: var(--muted); font-size: 12.5px; margin: 4px 0 14px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.tab { padding: 7px 12px; border-radius: 8px; font-size: 12.5px; font-weight: 600; background: #fff; border: 1px solid var(--border); color: var(--muted); }
.tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ---------- responsive: phones ---------- */
@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { padding: 12px 12px 92px; }
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--navy); color: #fff; padding: 12px 14px;
    position: sticky; top: 0; z-index: 50; margin: -12px -12px 12px;
  }
  .mobile-topbar .mt-title { font-size: 14px; font-weight: 700; line-height: 1.25; }
  .mobile-topbar .mt-title small { display: block; font-weight: 400; font-size: 10.5px; color: #9db4d6; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: #fff; border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .bottomnav a { flex: 1; text-align: center; font-size: 11px; color: var(--muted); padding: 6px 2px; border-radius: 8px; font-weight: 600; }
  .bottomnav a.active { color: var(--navy); background: #eef3fb; }
  .bottomnav a .ic { display: block; font-size: 17px; margin-bottom: 1px; }
  .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; }
  .quick-actions { grid-template-columns: repeat(3, 1fr); }
  .tbl-wrap.desktop-tbl { display: none; }
  .txn-cards { display: block; }
  .cashpanel .cp-item .v { font-size: 16.5px; }
  .kpi .k-value { font-size: 18px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .chart-box { height: 200px; }
}
@media (max-width: 380px) {
  .kpi .k-value { font-size: 16.5px; }
  .cashpanel .cp-item .v { font-size: 15px; }
}

/* ---------- print ---------- */
@media print {
  .sidebar, .bottomnav, .mobile-topbar, .btn, .period-chips, .quick-actions { display: none !important; }
  body { background: #fff; }
  .card, .kpi { box-shadow: none; border: 1px solid #ccc; }
  .main { padding: 0; }
}
