/* Hisab Kitab Pro — clean accounting UI, Manager.io style. Supports RTL for Urdu. */
:root {
  --bg: #f1f4f9;
  --panel: #ffffff;
  --ink: #1c2733;
  --muted: #6b7a90;
  --line: #e2e8f0;
  --brand: #1f6feb;
  --brand-dk: #1857b8;
  --green: #16803c;
  --green-bg: #e7f6ec;
  --red: #c03535;
  --red-bg: #fdecec;
  --amber: #b7791f;
  --amber-bg: #fdf3e0;
  --blue-bg: #e9f1fd;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 42, 80, .08), 0 4px 14px rgba(16, 42, 80, .06);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Segoe UI", "Noto Sans", "Jameel Noori Nastaleeq", Tahoma, Arial, sans-serif;
  font-size: 14px; line-height: 1.5;
}
#app { display: flex; height: 100vh; overflow: hidden; }

/* ---------- sidebar ---------- */
#sidebar {
  width: 248px; flex: 0 0 248px; background: #16283f; color: #dbe5f1;
  display: flex; flex-direction: column; overflow-y: auto;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 16px 14px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-logo {
  width: 40px; height: 40px; border-radius: 10px; flex: 0 0 40px;
  background: linear-gradient(135deg, #2f81f7, #1f6feb); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 17px;
}
.brand-name { font-weight: 700; font-size: 15px; color: #fff; }
.brand-sub { font-size: 11px; color: #9fb3cc; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
#nav { flex: 1; padding: 10px 8px; }
.nav-group { margin-bottom: 14px; }
.nav-group > .nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: #8fa5bf;
  padding: 6px 12px 4px;
}
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin: 1px 4px;
  border-radius: 8px; color: #dbe5f1; text-decoration: none; font-size: 13.5px; cursor: pointer;
  border: none; background: none; width: calc(100% - 8px); text-align: start; font-family: inherit;
}
.nav-link:hover { background: rgba(255,255,255,.08); }
.nav-link.active { background: var(--brand); color: #fff; font-weight: 600; }
.nav-link .ico { width: 20px; text-align: center; opacity: .9; }
.side-foot { display: flex; gap: 8px; padding: 12px; border-top: 1px solid rgba(255,255,255,.1); align-items: center; }
.side-foot .ver { margin-left: auto; font-size: 11px; color: #9fb3cc; opacity: .8; }

/* ---------- main ---------- */
#main { flex: 1; overflow-y: auto; padding: 22px 26px 60px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; margin: 0; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card h2 { font-size: 15px; margin: 0 0 12px; }
.card h3 { font-size: 13.5px; margin: 0 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.grid { display: grid; gap: 14px; }
.grid.c2 { grid-template-columns: repeat(2, 1fr); }
.grid.c3 { grid-template-columns: repeat(3, 1fr); }
.grid.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid.c4 { grid-template-columns: repeat(2, 1fr); } .grid.c3 { grid-template-columns: repeat(2, 1fr); } }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.stat .lbl { font-size: 12px; color: var(--muted); }
.stat .val { font-size: 21px; font-weight: 700; margin-top: 2px; }
.stat .val.green { color: var(--green); } .stat .val.red { color: var(--red); } .stat .val.blue { color: var(--brand); }
.stat .hint { font-size: 11.5px; color: var(--muted); }

/* ---------- tables ---------- */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl th { text-align: start; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  padding: 9px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:hover td { background: #f7fafd; }
.tbl tr.total td { font-weight: 700; border-top: 2px solid var(--line); background: #f7fafd; }
.tbl tr.subhead td { font-weight: 700; background: #eef3f9; }
.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl th.num { text-align: end; }
a.link { color: var(--brand); text-decoration: none; cursor: pointer; }
a.link:hover { text-decoration: underline; }

/* ---------- forms ---------- */
.fgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 16px; }
.fgrid.c3 { grid-template-columns: repeat(3, 1fr); }
.fgrid.c4 { grid-template-columns: repeat(4, 1fr); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.input, select.input, textarea.input {
  font-family: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid #c6d2e0;
  border-radius: 8px; background: #fff; color: var(--ink); width: 100%;
}
.input:focus { outline: 2px solid rgba(31,111,235,.35); border-color: var(--brand); }
textarea.input { resize: vertical; min-height: 64px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { min-width: 150px; }

/* ---------- buttons ---------- */
.btn {
  font-family: inherit; font-size: 13.5px; font-weight: 600; padding: 8px 16px; border-radius: 8px;
  border: 1px solid transparent; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand); color: #fff; text-decoration: none;
}
.btn:hover { background: var(--brand-dk); }
.btn.secondary { background: #e8eef6; color: var(--ink); }
.btn.secondary:hover { background: #dbe5f3; }
.btn.ghost { background: transparent; color: #dbe5f1; border-color: rgba(255,255,255,.25); }
.btn.ghost:hover { background: rgba(255,255,255,.1); }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #a32c2c; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- badges / misc ---------- */
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 20px; white-space: nowrap; }
.badge.green { background: var(--green-bg); color: var(--green); }
.badge.red { background: var(--red-bg); color: var(--red); }
.badge.amber { background: var(--amber-bg); color: var(--amber); }
.badge.blue { background: var(--blue-bg); color: var(--brand); }
.badge.gray { background: #edf1f6; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 34px 10px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.mt { margin-top: 12px; } .mb { margin-bottom: 12px; }
.right { text-align: end; } .center { text-align: center; }
.warn-box { background: var(--amber-bg); border: 1px solid #ecd9a8; color: #7a5410; border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; font-size: 13px; }

/* ---------- modal ---------- */
#modalRoot:empty { display: none; }
.mback { position: fixed; inset: 0; background: rgba(15, 30, 50, .5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.25); width: 560px; max-width: 100%; }
.modal.wide { width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-x { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 18px; border-top: 1px solid var(--line); }

/* ---------- toast ---------- */
#toastRoot { position: fixed; bottom: 22px; inset-inline-start: 50%; transform: translateX(50%); z-index: 99; display: flex; flex-direction: column; gap: 8px; align-items: center; }
[dir="rtl"] #toastRoot { transform: translateX(-50%); }
.toast { background: #16283f; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13.5px; box-shadow: var(--shadow); animation: tin .25s ease; max-width: 480px; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* ---------- invoice print ---------- */
#printArea { display: none; }
.inv { max-width: 760px; margin: 0 auto; background: #fff; color: #111; font-size: 14px; }
.inv-head { display: flex; justify-content: space-between; border-bottom: 3px solid #16283f; padding-bottom: 12px; margin-bottom: 16px; }
.inv-biz { font-size: 22px; font-weight: 800; }
.inv-title { font-size: 26px; font-weight: 800; color: #16283f; text-align: end; }
.inv-meta { display: flex; justify-content: space-between; margin-bottom: 14px; }
.inv table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.inv th { background: #16283f; color: #fff; padding: 8px; text-align: start; font-size: 12.5px; }
.inv td { border-bottom: 1px solid #ddd; padding: 8px; }
.inv .totals { width: 280px; margin-inline-start: auto; }
.inv .totals td { border: none; padding: 4px 8px; }
.inv .grand td { font-weight: 800; font-size: 16px; border-top: 2px solid #16283f; }
.inv-foot { margin-top: 26px; font-size: 12px; color: #555; }

/* ---------- report print ---------- */
.rep-head { text-align: center; margin-bottom: 14px; }
.rep-head h2 { margin: 0; font-size: 19px; }
.rep-head .sub { color: var(--muted); font-size: 12.5px; }

@media print {
  body { background: #fff; }
  #app, #modalRoot, #toastRoot { display: none !important; }
  #printArea { display: block !important; }
  .inv, .rep-print { box-shadow: none; }
}

/* ---------- RTL ---------- */
[dir="rtl"] .tbl th, [dir="rtl"] .tbl td { text-align: right; }
[dir="rtl"] .tbl th.num, [dir="rtl"] .num { text-align: left; }
[dir="rtl"] #sidebar { font-size: 14.5px; }
