:root {
  font-family: Inter, "Segoe UI", sans-serif;
  color: #10192d;
  background: #f2f4f9;
  --ink: #10192d;
  --sidebar: #10182b;
  --muted: #62718d;
  --line: #e0e5ef;
  --orange: #345ee5;
  --orange-hover: #274fc9;
  --green: #3159ce;
  --green-light: #eaf0ff;
  --rail-width: 244px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; }
button, input, select, textarea { font: inherit; }
button {
  padding: .65rem 1rem;
  border: 1px solid transparent;
  border-radius: 9px;
  background: var(--orange);
  color: white;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}
button:hover { background: var(--orange-hover); }
button:disabled { opacity: .6; cursor: wait; }
button.light { background: white; color: var(--green); border-color: var(--line); }
button.light:hover { background: var(--green-light); }
:is(button, input, select, textarea, a):focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }

.sidebar { padding: .85rem 1.25rem; background: var(--sidebar); color: white; border-bottom: 3px solid var(--orange); }
.brand { display: flex; align-items: center; gap: .85rem; }
.brand img { display: block; width: 5.25rem; height: auto; border-radius: 8px; }
.brand strong { font-size: 1.125rem; }
.signed-in .sidebar {
  position: fixed;
  display: flex;
  flex-direction: column;
  inset: 0 auto 0 0;
  width: var(--rail-width);
  overflow-y: auto;
  padding: 1.45rem 1rem;
  border-bottom: 0;
}
.signed-in .brand { flex-direction: column; gap: .5rem; padding: .15rem .4rem .9rem; margin-bottom: .9rem; }
.signed-in .brand img { width: min(100%, 218px); border-radius: 12px; }
.signed-in .brand strong { color: #e4edef; }
.sidebar :focus-visible { outline-color: var(--orange); }
nav { display: grid; gap: .27rem; }
nav button {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .62rem .92rem;
  background: transparent;
  color: #e4edef;
  font-size: .94rem;
  text-align: left;
  white-space: normal;
}
nav button:hover { background: #222d46; }
nav button[aria-current="page"] { background: #345ee5; color: white; box-shadow: none; }
.nav-icon { flex: 0 0 1.2rem; font-size: 1.1rem; color: #c9d7ff; text-align: center; }

main { min-width: 0; padding: 0 clamp(1rem, 3.3vw, 3.4rem) 3rem; }
.signed-in main { margin-left: var(--rail-width); }
.workspace-bar, .heading, .dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.workspace-bar { min-height: 3.9rem; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.workspace-bar strong { color: var(--ink); font-weight: 650; }
.workspace-bar span[aria-hidden] { margin: 0 .35rem; }
.heading { padding: 1.9rem 0 1.4rem; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.8rem, 4vw, 2.7rem); letter-spacing: -.05em; line-height: 1.08; }
h2 { font-size: 1.08rem; letter-spacing: -.015em; }
.heading p { color: var(--muted); margin-top: .58rem; line-height: 1.55; }
.filters { display: flex; align-items: end; gap: .75rem; flex-wrap: wrap; padding: .8rem 1rem; margin-bottom: 1rem; border: 1px solid var(--line); border-radius: 12px; background: white; }
.filters select { min-width: 12.5rem; }
#date-caption { align-self: center; color: var(--muted); }
#date-caption:empty { display: none; }
label { display: grid; gap: .35rem; font-size: .94rem; font-weight: 650; }
input, select, textarea { width: 100%; min-width: 0; padding: .6rem; border: 1px solid #aebfc2; border-radius: 8px; background: white; color: inherit; }
textarea { min-height: 5rem; resize: vertical; }
select { appearance: none; padding-right: 2rem; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) center, calc(100% - 11px) center; background-size: 5px 5px; background-repeat: no-repeat; }
.panel, .summary article { background: white; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 2px 5px #10182b0d; }
.summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.summary:empty { display: none; }
.summary article { padding: 1rem 1.15rem; min-width: 0; }
.metric-icon { display: grid; place-items: center; width: 33px; height: 33px; border-radius: 9px; background: var(--green-light); color: var(--green); font-weight: 800; }
.summary article:nth-child(3n + 1) .metric-icon { background: #eaf0ff; color: #3159ce; }
.summary p { margin: .65rem 0 .3rem; color: var(--muted); font-size: .92rem; }
.summary strong { display: block; font-size: clamp(1.12rem, 2.35vw, 1.8rem); letter-spacing: -.035em; overflow-wrap: anywhere; }
.summary small { display: block; margin-top: .32rem; color: var(--muted); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 1rem; }
#report-panels:not(.split) #cash-panel { margin-bottom: 1rem; }
.table-wrap { overflow: auto; }
.purchase-report { margin-top: 1rem; }
.purchase-report header small { display: block; color: var(--muted); margin-top: .35rem; }
.purchase-report-filters { display: flex; flex-wrap: wrap; gap: 1rem; padding: 1rem 1.15rem; }
.purchase-report-filters label { min-width: 12rem; }
.report-note { padding: .85rem 1.15rem; color: var(--muted); font-size: .875rem; }
.table-wrap header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; padding: 1rem 1.15rem; border-bottom: 1px solid var(--line); }
.table-wrap header button { padding: .35rem .55rem; font-size: .88rem; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: .9rem; }
th, td { padding: .74rem .95rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f5f7fb; color: var(--muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
td button { padding: .3rem .6rem; }
td a { color: var(--green); }
.licence-company { display: inline-flex; align-items: center; gap: .6rem; margin-bottom: 1rem; padding: .55rem .7rem; border: 1px solid #a8c098; border-radius: 9px; background: var(--green-light); }
.licence-company img { display: block; object-fit: contain; border-radius: 5px; }
.licence-identity strong, .licence-identity small { display: block; }
.licence-identity small, .licence-identity details { margin-top: .2rem; color: var(--muted); }
.licence-identity summary { cursor: pointer; }
.licence-identity details p { margin-top: .35rem; }
.licence-status { display: inline-block; padding: .25rem .48rem; border-radius: 6px; white-space: nowrap; }
.licence-status.active { color: #175840; background: #e3f2e9; }
.licence-status.due { color: #744508; background: #fff0d9; }
.licence-status.expired { color: #922b30; background: #fbe8e7; }
.licence-actions { display: flex; flex-wrap: wrap; gap: .32rem; }
.licence-actions button { white-space: nowrap; }
.negative, .error { color: #a32b31; }
.error:not(:empty), #status:not(:empty) { margin: .65rem 0; }
#status { color: var(--muted); }

.login { max-width: 420px; padding: 1.6rem; margin: 8vh auto; border-top: 4px solid var(--orange); }
body:not(.signed-in) main { margin-inline: auto; }
.login form { display: grid; gap: 1rem; margin-top: 1rem; }
#login-status:empty, .login .error:empty { display: none; }
.account-actions { display: grid; gap: .9rem; margin-top: auto; padding-top: .9rem; }
.account-profile { display: flex; align-items: center; gap: .65rem; border-top: 1px solid #34405a; padding: .95rem .35rem 0; }
.account-profile strong, .account-profile small { display: block; overflow-wrap: anywhere; }
.account-profile strong { font-size: .875rem; }
.account-profile small { margin-top: .2rem; color: #c7d7db; font-size: .82rem; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; flex: none; background: #345ee5; }
.account-actions button { background: transparent; color: #e4edef; border-color: #3d555d; text-align: left; }
.account-actions button:hover { background: #222d46; }
dialog { width: min(640px, calc(100% - 2rem)); max-height: 90vh; border: 1px solid var(--line); border-radius: 15px; padding: 1.25rem; color: inherit; }
dialog::backdrop { background: #10262eb3; }
#document-viewer { width: min(960px, calc(100% - 2rem)); }
#document-preview { margin-top: 1rem; }
#document-preview img { display: block; max-width: 100%; max-height: 72vh; margin: auto; object-fit: contain; }
.pdf-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; margin-bottom: .65rem; }
.pdf-toolbar button { padding: .35rem .55rem; }
.pdf-toolbar [role="status"] { margin-inline: .45rem auto; }
.pdf-page { max-height: 68vh; overflow: auto; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #eef3f1; }
.pdf-page canvas { display: block; margin: auto; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: .85rem; margin: 1rem 0; }
.fields .wide { grid-column: 1 / -1; }
.gst-rows { display: grid; gap: .75rem; }
.gst-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: .65rem; align-items: end; }
@media (max-width: 480px) { .gst-row { grid-template-columns: 1fr; } }
.daily-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: .65rem; margin: 0; padding: .8rem; background: #eef3f1; border-radius: 9px; }
.daily-totals dt { color: var(--muted); font-size: .875rem; }
.daily-totals dd { margin: .25rem 0 0; font-weight: 700; overflow-wrap: anywhere; }
.hint { font-size: .875rem; color: var(--muted); }

@media (max-width: 1000px) {
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .signed-in .sidebar { position: static; width: auto; padding: 1rem; }
  .signed-in .brand { padding: 0; }
  .signed-in .brand img { width: min(100%, 9rem); }
  .signed-in main { margin-left: 0; }
  .signed-in nav { display: flex; overflow: auto; }
  .signed-in nav button { white-space: nowrap; }
  .account-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
  .account-profile { display: none; }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .heading { align-items: flex-start; flex-direction: column; }
  .filters input { max-width: 10rem; }
}
@media (max-width: 420px) {
  .fields { grid-template-columns: 1fr; }
  .summary { gap: .65rem; }
  .summary article { padding: .75rem; }
  .workspace-bar time { font-size: .8rem; }
}
@media (max-width: 365px) {
  .summary { grid-template-columns: minmax(0, 1fr); }
}
.permission-row td { background: #fafbfe; padding-top: .4rem; }
.permission-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr)); gap: .7rem; }
.permission-grid label span { font-size: .84rem; color: var(--muted); }
.permission-grid select { padding-top: .45rem; padding-bottom: .45rem; }
.permission-actions { display: flex; align-items: center; gap: .8rem; margin-top: .75rem; flex-wrap: wrap; }
.permission-actions small { color: var(--muted); }
