/* Pegasus GL Web */
:root {
  --bg: #f4f5f3;
  --surface: #ffffff;
  --ink: #26313a;
  --ink-soft: #64707a;
  --line: #dcdfd9;
  --accent: #0e6e64;
  --accent-dark: #0a544c;
  --accent-soft: #e2efec;
  --debit: #8a4a2c;
  --credit: #2c6b46;
  --danger: #a33327;
  --topbar: #24313a;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 'Segoe UI', system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Top bar */
.topbar { display: flex; align-items: center; gap: 20px; background: var(--topbar);
  color: #eef0eb; padding: 0 18px; height: 52px; position: sticky; top: 0; z-index: 50; }
.brand { font-size: 17px; letter-spacing: .02em; white-space: nowrap; }
.brand b { color: #7fd4c8; }
.topbar nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.topbar nav a { color: #c3ccc9; padding: 6px 12px; border-radius: 6px; white-space: nowrap; }
.topbar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.topbar nav a.active { background: var(--accent); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.year-form select { background: #33424d; color: #eef0eb; border: 1px solid #46565f;
  border-radius: 6px; padding: 5px 8px; font-size: 13px; }
.user { font-size: 13px; color: #aeb9b4; }
.logout { color: #aeb9b4; font-size: 16px; }

main { max-width: 1180px; margin: 0 auto; padding: 22px 18px 60px; }
.foot { text-align: center; color: var(--ink-soft); font-size: 12px; padding: 14px; }

h1 { font-size: 22px; margin: 0 0 4px; }
.sub { color: var(--ink-soft); margin: 0 0 18px; }

/* Cards / panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px 18px; margin-bottom: 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat .lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.stat .val { font-size: 22px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* Toolbar / filters */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 14px; }
.toolbar .fld { display: flex; flex-direction: column; gap: 3px; }
.toolbar label { font-size: 11.5px; color: var(--ink-soft); }
input[type=text], input[type=date], input[type=number], select, textarea {
  border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; font: inherit;
  background: #fff; color: var(--ink); }
input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.btn { display: inline-block; background: var(--accent); color: #fff; border: 0; border-radius: 7px;
  padding: 8px 16px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--accent-dark); text-decoration: none; }
.btn.secondary { background: #e8eae6; color: var(--ink); }
.btn.secondary:hover { background: #dcdfd9; }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 4px 10px; font-size: 12.5px; font-weight: 500; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Tables */
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
table.grid { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.grid th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-soft); background: #fafbf9; padding: 9px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap; position: sticky; top: 52px; }
table.grid td { padding: 7px 12px; border-bottom: 1px solid #edefe9; vertical-align: top; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid tr:hover td { background: #f7f9f6; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.code { font-family: Consolas, monospace; font-size: 12.5px; white-space: nowrap; }
.deb { color: var(--debit); }
.cre { color: var(--credit); }
tr.grade1 td { font-weight: 700; background: #eef1ec; }
tr.grade2 td { font-weight: 600; }
tr.grade3 td { color: #3c4954; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); background: #fafbf9; }
.badge { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent-dark); }
.badge.gray { background: #eceee9; color: var(--ink-soft); }

/* Pagination */
.pager { display: flex; gap: 4px; margin-top: 12px; flex-wrap: wrap; }
.pager a, .pager span { padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pager span.cur { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Entry form */
#lines { width: 100%; border-collapse: collapse; }
#lines th { font-size: 11.5px; text-transform: uppercase; color: var(--ink-soft); text-align: left; padding: 4px 6px; }
#lines td { padding: 3px 4px; }
#lines input { width: 100%; }
#lines input.amount { text-align: right; font-variant-numeric: tabular-nums; }
#lines .accname { font-size: 12px; color: var(--ink-soft); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 280px; }
.totals { display: flex; gap: 26px; justify-content: flex-end; padding: 10px 6px; font-size: 15px;
  font-variant-numeric: tabular-nums; }
.totals .ok { color: var(--credit); font-weight: 700; }
.totals .bad { color: var(--danger); font-weight: 700; }

/* Autocomplete */
.ac-list { position: absolute; z-index: 100; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.12); max-height: 260px; overflow-y: auto;
  min-width: 380px; }
.ac-item { padding: 6px 10px; cursor: pointer; display: flex; gap: 10px; font-size: 13px; }
.ac-item .c { font-family: Consolas, monospace; color: var(--accent-dark); white-space: nowrap; }
.ac-item.sel, .ac-item:hover { background: var(--accent-soft); }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--topbar); }
.login-box { background: #fff; border-radius: 12px; padding: 34px 36px; width: 360px; }
.login-box h1 { text-align: center; }
.login-box .fld { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.login-box input { width: 100%; }
.login-box .btn { width: 100%; margin-top: 6px; }
.err { background: #fbe9e7; color: var(--danger); border: 1px solid #f0c3bd;
  border-radius: 7px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px; }
.msg-ok { background: var(--accent-soft); color: var(--accent-dark); border: 1px solid #bfe0da;
  border-radius: 7px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(20,28,33,.5); z-index: 200;
  display: flex; align-items: flex-start; justify-content: center; padding-top: 8vh; }
.modal { background: #fff; border-radius: 12px; padding: 22px 24px; width: 560px; max-width: 94vw; }
.modal h2 { margin: 0 0 14px; font-size: 17px; }
.modal .row { display: flex; gap: 10px; margin-bottom: 10px; }
.modal .fld { flex: 1; display: flex; flex-direction: column; gap: 3px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.hidden { display: none !important; }

@media print {
  .topbar, .toolbar, .foot, .btn, .pager { display: none !important; }
  main { max-width: none; padding: 0; }
  .tablewrap { border: 0; }
  table.grid th { position: static; }
}
