/* Financial Management Tool — shared styles */
* { box-sizing: border-box; }
:root {
  --brand: #1e7f4f; --brand-dk: #14603a; --ink: #1c2733; --mut: #66738a;
  --bg: #f2f5f8; --card: #ffffff; --line: #e3e8ee; --bad: #c0392b; --warn: #b8860b;
}
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Arial, sans-serif; }
a { color: var(--brand); }

/* header / nav */
#nav { background: linear-gradient(120deg, var(--brand-dk), var(--brand)); color: #fff; padding: 14px 22px 0; }
.brand { display: flex; align-items: center; gap: 12px; padding-bottom: 10px; }
.logo { width: 44px; height: 44px; border-radius: 10px; background: rgba(255,255,255,.16);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; letter-spacing: .5px; }
.bname { font-size: 18px; font-weight: 700; }
.bsub { font-size: 12px; opacity: .85; }
#nav nav { display: flex; gap: 4px; flex-wrap: wrap; }
#nav nav a { color: #eaf4ee; text-decoration: none; padding: 9px 16px; border-radius: 8px 8px 0 0; font-weight: 600; font-size: 13px; }
#nav nav a:hover { background: rgba(255,255,255,.12); }
#nav nav a.on { background: var(--bg); color: var(--brand-dk); }
.warn { background: #fff3cd; color: #7a5c00; padding: 6px 12px; border-radius: 6px; margin: 8px 0; font-size: 12px; }

/* layout */
main.wrap, main#app { max-width: 1180px; margin: 0 auto; padding: 20px 22px 60px; }
h1 { font-size: 22px; margin: 6px 0 16px; }
h2 { font-size: 15px; margin: 0 0 12px; color: var(--brand-dk); }
.muted { color: var(--mut); font-weight: 400; }
.small { font-size: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin-bottom: 18px; box-shadow: 0 1px 2px rgba(16,32,48,.04); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid2 .card { margin-bottom: 0; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } }
.rowflex { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.scrollx { overflow-x: auto; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--mut); border-radius: 10px; padding: 12px 14px; }
.kpi.good { border-left-color: var(--brand); }
.kpi.bad { border-left-color: var(--bad); }
.klabel { font-size: 12px; color: var(--mut); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.kval { font-size: 21px; font-weight: 700; margin: 2px 0; }
.ksub { font-size: 12px; color: var(--mut); }
.bignum { font-size: 24px; font-weight: 700; margin: 6px 0; }

/* tables */
table.tbl { border-collapse: collapse; width: 100%; font-size: 13px; }
.tbl th, .tbl td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.tbl th { color: var(--mut); font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.pos { color: var(--brand-dk); } .neg { color: var(--bad); }
.totalrow td { font-weight: 700; border-top: 2px solid #c9d2dc; background: #f7fafc; }
.totalrow.net td { background: #eef7f1; }
.grouprow td { background: #eef2f6; font-weight: 700; color: var(--brand-dk); font-size: 12px; }
.muted2 td { color: var(--mut); font-style: italic; }
.sticky { position: sticky; left: 0; background: #fff; z-index: 2; min-width: 190px; white-space: normal !important; }
.totalrow .sticky, .grouprow .sticky { background: inherit; }
.tagwarn { background: #fff3cd; color: #7a5c00; padding: 1px 7px; border-radius: 10px; font-size: 11.5px; }
.acts { white-space: nowrap; }

/* forms */
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; align-items: end; }
.form.grid3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; font-weight: 600; color: var(--mut); }
input, select { padding: 8px 10px; border: 1px solid #c9d2dc; border-radius: 8px; font: inherit; color: var(--ink); background: #fff; min-width: 0; }
input:focus, select:focus { outline: 2px solid #bfe3d0; border-color: var(--brand); }
input.cell { width: 96px; padding: 4px 6px; text-align: right; border-radius: 6px; }
input.cell.wide { width: 100%; text-align: left; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; grid-column: 1 / -1; margin-top: 4px; }
.btn { background: var(--brand); color: #fff; border: none; border-radius: 8px; padding: 9px 18px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--brand-dk); }
.btn.ghost { background: #fff; color: var(--brand-dk); border: 1px solid var(--brand); }
.btn.danger { background: #fff; color: var(--bad); border: 1px solid var(--bad); }
.btn.filebtn { position: relative; overflow: hidden; display: inline-block; }
.btn.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.mini { border: 1px solid #c9d2dc; background: #fff; border-radius: 6px; padding: 2px 8px; cursor: pointer; font-size: 12px; }
.mini:hover { border-color: var(--brand); color: var(--brand-dk); }
.mini.danger { color: var(--bad); }
.warntext { color: var(--bad); font-weight: 600; }

/* charts */
svg.chart { width: 100%; height: auto; display: block; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--mut); margin-bottom: 4px; }
.legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* reports */
.report { padding: 28px 34px; }
.rhead { text-align: center; margin-bottom: 18px; }
.rname { font-size: 19px; font-weight: 800; letter-spacing: .3px; }
.rtitle { font-size: 15px; font-weight: 700; color: var(--brand-dk); margin-top: 2px; }
.rperiod { font-size: 13px; margin-top: 2px; }
.rstd { font-size: 11px; color: var(--mut); margin-top: 4px; }
table.rtbl { width: 100%; max-width: 720px; margin: 0 auto; border-collapse: collapse; font-size: 13.5px; }
.rtbl td, .rtbl th { padding: 5px 8px; }
.rtbl th { border-bottom: 1.5px solid var(--ink); font-size: 12px; }
.rtbl .sect td { font-weight: 800; padding-top: 14px; text-transform: uppercase; font-size: 12px; letter-spacing: .4px; }
.rtbl .sect2 td { font-weight: 700; padding-top: 8px; }
.rtbl .sub td { font-weight: 700; border-top: 1px solid #98a4b5; }
.rtbl .strong td { font-weight: 800; border-top: 1px solid #98a4b5; }
.rtbl .grand td { font-weight: 800; border-top: 2px solid var(--ink); border-bottom: 3px double var(--ink); }
.rnote { max-width: 720px; margin: 14px auto 0; font-size: 12px; color: var(--mut); }
.rfoot { max-width: 720px; margin: 22px auto 0; font-size: 11px; color: var(--mut); border-top: 1px solid var(--line); padding-top: 8px; text-align: center; }

/* print */
@media print {
  #nav, .no-print, h1.no-print { display: none !important; }
  body { background: #fff; }
  main#app { padding: 0; max-width: none; }
  .card { border: none; box-shadow: none; padding: 0; }
  .report { padding: 0; }
}

/* ---- login & user chip (unified system) ---- */
body.loginbg { display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: linear-gradient(135deg, #14603a, #1e7f4f 55%, #2a9d64); }
.loginbox { background: #fff; border-radius: 16px; padding: 34px 38px; width: 380px; max-width: 92vw;
  box-shadow: 0 18px 50px rgba(8, 40, 24, .35); display: flex; flex-direction: column; gap: 12px; }
.loginbox h1 { font-size: 19px; margin: 0; text-align: center; }
.loginbox .lsub { margin: 0 0 4px; text-align: center; color: var(--mut); font-size: 12.5px; }
.loginbox .lnote { margin: 6px 0 0; color: var(--mut); font-size: 11.5px; text-align: center; }
.logo.lbig { width: 62px; height: 62px; font-size: 20px; margin: 0 auto; background: var(--brand); color: #fff; }
.lerr { color: var(--bad); font-size: 12.5px; font-weight: 600; text-align: center; min-height: 16px; }
.btn.lwide { width: 100%; padding: 11px; font-size: 15px; }
.uchip { text-align: right; line-height: 1.25; margin-right: 2px; }
.uchip b { display: block; font-size: 13px; }
.uchip span { font-size: 11px; opacity: .85; }
.cswitch { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.4);
  border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 12.5px; max-width: 240px; }
.cswitch option { color: var(--ink); }
.mini.light { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.4); padding: 5px 10px; }
.mini.light:hover { background: rgba(255,255,255,.28); color: #fff; }
#nav .brand { flex-wrap: wrap; gap: 10px; }

/* ---- documents & print (enhancement) ---- */
.rtitle { text-transform: uppercase; }
.doctbl { margin-top: 14px; }
.docmeta { margin-top: 10px; }
.docmeta td { border: none; }
.docsign { margin-top: 34px; }
.docsign td { border: none; padding-top: 24px; font-size: 12.5px; color: var(--mut); }
.tagme { background: #d9efe3; color: var(--brand-dk); padding: 1px 7px; border-radius: 10px; font-size: 11px; }
@media print {
  body.printdoc #app > :not(#docviewwrap) { display: none !important; }
  body.printdoc .kpis, body.printdoc h1 { display: none !important; }
  #docviewwrap .card { border: none; box-shadow: none; }
}

/* ---- password eye & login links ---- */
.pwwrap { display: flex; gap: 6px; }
.pwwrap input { flex: 1; min-width: 0; }
.eye { border: 1px solid #c9d2dc; background: #fff; border-radius: 8px; padding: 0 10px; cursor: pointer; font-size: 14px; }
.eye:hover { border-color: var(--brand); }
.llink { display: block; text-align: center; font-size: 13px; margin-top: 2px; }

/* ---- party form modal ---- */
.pmodal { position: fixed; inset: 0; background: rgba(12, 30, 20, .45); z-index: 90;
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.pbox { background: #fff; border-radius: 14px; padding: 22px 26px; width: 520px; max-width: 94vw;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 18px 50px rgba(8, 40, 24, .4); }
.payinfo { border-top: 1px solid var(--line); padding-top: 8px; }

/* ---- company logo ---- */
.logo.haslogo { background: #fff; padding: 3px; }
.logo.haslogo img { width: 100%; height: 100%; object-fit: contain; border-radius: 7px; display: block; }
.doclogo { height: 60px; max-width: 220px; object-fit: contain; display: block; margin: 0 auto 6px; }
.logoprev { height: 46px; border: 1px solid var(--line); border-radius: 6px; padding: 2px; background: #fff; }

/* ---- standard document letterhead (proforma invoice format) ---- */
.lhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 6px; }
.lhead-logo { max-height: 86px; max-width: 220px; object-fit: contain; }
.lhead-noimg { width: 72px; height: 72px; border-radius: 12px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px; }
.lhead-co { text-align: right; font-size: 12.5px; line-height: 1.45; color: var(--ink); }
.lhead-name { font-weight: 800; font-size: 15px; letter-spacing: .3px; }
.lhead-rule { border-bottom: 3px solid var(--brand-dk); margin-bottom: 14px; }
.dtitle { text-align: center; font-size: 17px; font-weight: 800; letter-spacing: 1px; color: var(--brand-dk); text-transform: uppercase; margin: 8px 0 14px; }
.dmeta { display: flex; justify-content: space-between; gap: 24px; margin-bottom: 8px; flex-wrap: wrap; }
.dbill { min-width: 240px; }
.dbill-name { font-weight: 700; font-size: 13.5px; margin: 2px 0; }
.dref { text-align: right; font-size: 13px; line-height: 1.7; }
.dref span { color: var(--mut); }
.dsect, h3.dsect { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--brand-dk); margin: 16px 0 4px; }
.rtbl .nte { width: 46px; color: var(--mut); font-size: 12px; }
.rtbl .notetext { white-space: normal; color: var(--ink); font-size: 12.5px; padding-bottom: 10px; }
.rtbl thead th { vertical-align: bottom; }
