@font-face { font-family: "Lato"; src: url("fonts/Lato-Regular.ttf"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Lato"; src: url("fonts/Lato-Bold.ttf"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Lato"; src: url("fonts/Lato-Black.ttf"); font-weight: 900; font-style: normal; font-display: swap; }
@font-face { font-family: "Lato"; src: url("fonts/Lato-Italic.ttf"); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  --navy: #123239;
  --navy-2: #1b4a52;
  --teal: #1f6f6b;
  --teal-dark: #155956;
  --teal-soft: #e8f4f2;
  --gold: #e8c477;
  --bg: #eef2f4;
  --surface: #ffffff;
  --text: #1d2733;
  --muted: #6b7a89;
  --line: #dfe6ec;
  --line-soft: #edf1f5;
  --green: #2f7d5b;
  --green-soft: #e9f6ef;
  --amber: #b7791f;
  --amber-soft: #fff5e0;
  --red: #b23b3b;
  --red-soft: #fceeee;
  --blue: #2b5f9e;
  --blue-soft: #eaf1fa;
  --shadow: 0 8px 28px rgba(18, 50, 57, .10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: "Lato", "DejaVu Sans", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
/* Teal is invisible on the dark navy surfaces — use gold there. */
.demo-strip :focus-visible, .sidebar :focus-visible, .toast :focus-visible { outline-color: var(--gold); }
h1[tabindex="-1"]:focus { outline: none; }
[aria-invalid="true"] { border-color: var(--red) !important; box-shadow: 0 0 0 3px rgba(178,59,59,.15) !important; }
h1, h2, h3, p { margin-top: 0; }
.ic { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
.muted { color: var(--muted); }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }

/* ---------- Demo strip ---------- */
.demo-strip {
  min-height: 32px;
  background: #0c2429;
  color: #c8dadd;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 16px;
  font-size: 11px;
  position: sticky;
  top: 0;
  z-index: 70;
}
.demo-pill {
  background: var(--gold);
  color: var(--navy);
  font-weight: 900;
  font-size: 9px;
  letter-spacing: 1px;
  padding: 3px 7px;
  border-radius: 4px;
  flex: 0 0 auto;
}
.demo-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.demo-spacer { flex: 1; }
.demo-btn {
  background: transparent;
  border: 1px solid #2b535a;
  color: #d9e7e9;
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 10.5px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.demo-btn:hover { background: #17383f; }
.demo-btn .ic { width: 13px; height: 13px; }

/* ---------- Shell ---------- */
.app { display: flex; min-height: calc(100vh - 32px); }
.sidebar {
  width: 236px;
  flex: 0 0 236px;
  background: var(--navy);
  color: #d9e7e9;
  padding: 22px 14px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 32px;
  height: calc(100vh - 32px);
  overflow-y: auto;
  scrollbar-width: none;
  z-index: 40;
}
.sidebar::-webkit-scrollbar { display: none; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--gold); color: var(--navy);
  display: grid; place-items: center;
  font-weight: 900; font-size: 16px; letter-spacing: -.5px;
  flex: 0 0 34px;
}
.brand-name { font-size: 15px; font-weight: 900; color: #fff; line-height: 1.1; }
.brand-sub { font-size: 10.5px; color: #9fb9bd; margin-top: 2px; }

.nav-label {
  font-size: 9.5px; letter-spacing: 1.4px; text-transform: uppercase;
  color: #7fa0a5; padding: 0 10px 8px; font-weight: 700;
}
.nav-label-gap { margin-top: 20px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 7px;
  color: #c8dadd; font-size: 12.8px; font-weight: 700;
  background: transparent; border: 0; text-align: left;
}
.nav-item .ic { opacity: .9; }
.nav-item:hover { background: #173f47; color: #fff; }
.nav-item.active { background: #1b4a52; color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.nav-item .badge {
  margin-left: auto; background: var(--gold); color: var(--navy);
  border-radius: 999px; font-size: 10.5px; font-weight: 900;
  padding: 2px 6px; min-width: 20px; text-align: center;
}
.sidebar .spacer { flex: 1; min-height: 28px; }
.side-help {
  border-top: 1px solid #245158; padding: 12px 10px 10px;
  font-size: 10.5px; color: #9fb9bd; line-height: 1.7;
}
.side-help b { color: #fff; display: block; font-size: 11.5px; margin-bottom: 2px; }
.side-help kbd { font-family: inherit; font-size: 9.5px; background: #1b4148; border-radius: 4px; padding: 1px 4px; color: #e7f1f2; }
.side-feedback {
  display: flex; align-items: center; gap: 7px;
  width: 100%; border: 1px solid #2b535a; background: transparent;
  color: #d9e7e9; border-radius: 7px; padding: 8px 9px;
  font-size: 11px; font-weight: 700; margin: 0 0 10px;
}
.side-feedback:hover { background: #17383f; }
.side-feedback .ic { width: 14px; height: 14px; }
.side-user { display: flex; align-items: center; gap: 9px; padding: 10px 8px 0; border-top: 1px solid #245158; }
.avatar {
  width: 31px; height: 31px; border-radius: 50%;
  background: #d9e7e9; color: var(--navy);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 900; flex: 0 0 31px;
}
.avatar.dark { background: #2b5a62; color: #fff; }
.side-user .who { font-size: 11.5px; font-weight: 700; color: #fff; line-height: 1.2; }
.side-user .role { font-size: 10px; color: #9fb9bd; margin-top: 1px; }
.nav-backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  min-height: 64px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 10px 26px;
  position: sticky; top: 32px; z-index: 30;
}
.menu-btn {
  display: none; width: 36px; height: 36px; border: 1px solid var(--line);
  background: #fff; border-radius: 8px; place-items: center; color: #40505e;
}
.crumb { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.crumb b { color: var(--text); }
.search {
  flex: 1; max-width: 550px; height: 38px;
  background: #f4f7f9; border: 1px solid var(--line);
  border-radius: 9px; display: flex; align-items: center; gap: 9px;
  padding: 0 11px; color: var(--muted); font-size: 12.5px;
  cursor: text;
}
.search:focus-within { border-color: var(--teal); background: #fff; box-shadow: 0 0 0 3px rgba(31,111,107,.18); }
.search .ic { width: 16px; height: 16px; opacity: .7; }
.search input {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: 0;
  color: var(--text); font-size: 12.5px;
}
.search input::placeholder { color: #8b99a6; }
.search kbd {
  font-family: inherit; font-size: 9.5px; color: #7b8a99;
  background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 2px 5px;
  white-space: nowrap;
}
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; display: grid; place-items: center; position: relative; color: #4c5b6a;
}
.icon-btn:hover { background: #f6f9fa; border-color: #cbd8de; }
.dot {
  position: absolute; top: 7px; right: 7px; width: 7px; height: 7px;
  background: var(--red); border: 1.5px solid #fff; border-radius: 50%;
}

.content { flex: 1; padding: 24px 26px 48px; }
.page { max-width: 1380px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.kicker {
  font-size: 9.5px; letter-spacing: 1.3px; text-transform: uppercase;
  color: var(--teal); font-weight: 900; margin-bottom: 5px;
}
h1 { font-size: 26px; line-height: 1.1; margin: 0 0 4px; font-weight: 900; letter-spacing: -.35px; }
.sub { color: var(--muted); font-size: 12.5px; margin: 0; }
.head-actions { margin-left: auto; display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }

/* ---------- Buttons / controls ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 8px; padding: 9px 13px; font-size: 12px; font-weight: 700;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #f7fafb; border-color: #cfdce2; }
.btn .ic { width: 15px; height: 15px; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--teal); }
.btn.ghost:hover { background: var(--teal-soft); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-soft); border-color: #efcaca; }
.btn.lg { padding: 10px 16px; font-size: 12.5px; border-radius: 9px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.select { position: relative; display: inline-flex; align-items: center; }
.select select {
  appearance: none; -webkit-appearance: none;
  height: 33px; border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 0 28px 0 10px; font-size: 11.5px; color: #41505f;
  max-width: 210px; cursor: pointer;
}
.select .ic { position: absolute; right: 8px; width: 13px; height: 13px; opacity: .65; pointer-events: none; }
.select select:hover { border-color: #cfdce2; }

/* ---------- KPI ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 15px; min-width: 0;
}
.stat .n { font-size: 21px; font-weight: 900; letter-spacing: -.4px; }
.stat .l { font-size: 10.5px; color: var(--muted); margin-top: 1px; }
.stat.warn .n { color: var(--amber); }
.stat.bad .n { color: var(--red); }

.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; background: #e3eaee; padding: 3px; border-radius: 9px; flex-wrap: wrap; }
.tab {
  padding: 7px 11px; border-radius: 7px; font-size: 11.5px; font-weight: 700; color: #5b6b7c;
  background: transparent; border: 0;
}
.tab:hover { color: var(--navy); }
.tab.active { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(18,50,57,.10); }
.tab .count { color: var(--teal); margin-left: 4px; }
.filters { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  overflow: auto;
}
table { width: 100%; border-collapse: collapse; }
.table-wrap > table { min-width: 900px; }
thead th {
  text-align: left; font-size: 10px; letter-spacing: .8px; text-transform: uppercase;
  color: var(--muted); font-weight: 900; padding: 11px 14px;
  background: #f8fafb; border-bottom: 1px solid var(--line); white-space: nowrap;
}
thead th.right { text-align: right; }
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; font-size: 12px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.hot { background: #fbfdfc; box-shadow: inset 3px 0 0 var(--teal); }
tbody tr[data-action] { cursor: pointer; }
tbody tr[data-action]:hover { background: #f6faf9; }
.doc-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
.doc-ico {
  width: 30px; height: 34px; border-radius: 6px; background: #eef4f6;
  border: 1px solid #d8e2e7; display: grid; place-items: center; color: var(--teal); flex: 0 0 30px;
}
.doc-ico .ic { width: 16px; height: 16px; }
.doc-title { font-weight: 700; font-size: 12.3px; margin-bottom: 1px; line-height: 1.25; }
.doc-meta { color: var(--muted); font-size: 10.7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 330px; }
.mobile-meta { display: none; }
.type { font-size: 10.5px; font-weight: 700; color: #4d5d6c; background: #f3f6f8; border-radius: 6px; padding: 3px 7px; white-space: nowrap; display: inline-block; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 999px;
  padding: 4px 8px; font-size: 10.5px; font-weight: 900; white-space: nowrap;
}
.chip:before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.chip.amber { background: var(--amber-soft); color: #9a6516; }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.gray { background: #f0f3f6; color: #5d6c7b; }
.owner { display: flex; align-items: center; gap: 6px; font-size: 11px; white-space: nowrap; }
.owner-dept { font-size: 9.5px; color: var(--muted); margin: 2px 0 0 29px; line-height: 1.2; white-space: nowrap; }
.owner .avatar { width: 23px; height: 23px; flex-basis: 23px; font-size: 8.5px; }
.due { font-size: 11px; font-weight: 700; white-space: nowrap; }
.due.late { color: var(--red); }
.due.soon { color: var(--amber); }
.row-act { color: #7b8a99; text-align: right; white-space: nowrap; }
.row-open {
  border: 1px solid var(--line); background: #fff; border-radius: 6px;
  padding: 5px 8px; font-size: 10.5px; font-weight: 700; color: #536473;
}
.row-open:hover { border-color: #bfd0d7; color: var(--teal); }
.pagination {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  font-size: 10.5px; color: var(--muted); border-top: 1px solid var(--line); background: #fbfcfd;
  flex-wrap: wrap;
}
.pagination .pages { margin-left: auto; display: flex; gap: 4px; }
.page-n {
  min-width: 28px; height: 28px; border-radius: 6px; display: grid; place-items: center;
  border: 1px solid var(--line); background: #fff; font-size: 11px; color: var(--text);
}
.page-n:hover:not(.active) { border-color: #bfd0d7; color: var(--teal); }
.page-n.active { background: var(--teal); border-color: var(--teal); color: #fff; font-weight: 900; }
.footnote { font-size: 10.5px; color: var(--muted); margin-top: 8px; }
.footnote kbd { font-family: inherit; background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; }
.empty {
  background: #fff; border: 1px dashed #cfdce2; border-radius: 11px;
  padding: 48px 24px; text-align: center; color: var(--muted);
}
.empty .doc-ico { margin: 0 auto 10px; width: 42px; height: 48px; }
.empty b { display: block; color: var(--text); font-size: 14px; margin-bottom: 3px; }

/* ---------- Registry ---------- */
.summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.sum-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px; }
.sum-card .n { font-size: 20px; font-weight: 900; letter-spacing: -.4px; }
.sum-card .l { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.sum-card .sub2 { font-size: 9.5px; color: var(--teal); margin-top: 5px; font-weight: 700; }
.reg-filters { display: flex; gap: 8px; align-items: center; margin: 0 0 12px; flex-wrap: wrap; }
.reg-filters .search { height: 34px; max-width: 320px; background: #fff; }
.reg-filters .select select { height: 34px; }

/* ---------- Document ---------- */
.doc-head {
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  padding: 14px 18px; margin-bottom: 12px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.doc-head-main { display: flex; align-items: center; gap: 11px; min-width: 0; }
.doc-head .doc-ico { width: 38px; height: 42px; flex-basis: 38px; }
.doc-head h1 { font-size: 21px; margin: 0 0 3px; }
.doc-head .meta-line { font-size: 11px; color: var(--muted); display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.doc-head .amount { margin-left: 14px; font-size: 22px; font-weight: 900; letter-spacing: -.4px; white-space: nowrap; }
.doc-head .amount small { display: block; font-size: 9.5px; color: var(--muted); font-weight: 400; letter-spacing: 0; }
.doc-head .meta-line b { color: var(--text); }
.doc-actions { margin-left: auto; display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.doc-alert {
  background: var(--red-soft); border: 1px solid #efcaca; color: #7d2a2a;
  border-radius: 9px; padding: 10px 14px; margin: -4px 0 12px; font-size: 12px;
}
.doc-alert b { color: var(--red); margin-right: 6px; }
.back {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--teal);
  font-weight: 700; margin-bottom: 9px; background: transparent; border: 0; padding: 0;
}
.back:hover { text-decoration: underline; }
.back .ic { width: 14px; height: 14px; }

.doc-grid { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 12px; align-items: start; }
.preview {
  background: #dfe6eb; border: 1px solid var(--line); border-radius: 11px;
  padding: 12px; min-width: 0; max-height: calc(100vh - 185px); overflow: auto;
}
.preview-bar { display: flex; align-items: center; gap: 7px; font-size: 10.5px; color: #5b6b7c; padding: 0 2px 9px; }
.preview-bar .spacer { flex: 1; }
.preview-page {
  background: #fff; border-radius: 3px; box-shadow: 0 3px 14px rgba(18,50,57,.16);
  margin: 0 auto; width: 100%; max-width: 620px; padding: 34px 38px;
  color: #1d2733;
}
.preview-nav { display: flex; justify-content: center; align-items: center; gap: 12px; padding-top: 9px; font-size: 10px; color: #4d5d6c; }
.page-btn { width: 24px; height: 22px; background: #fff; border: 1px solid #cfdbe2; border-radius: 5px; display: grid; place-items: center; color: #4d5d6c; }
.page-btn:hover { border-color: #aebfc8; }

.inv-top { display: flex; justify-content: space-between; gap: 18px; border-bottom: 2px solid #123239; padding-bottom: 12px; }
.inv-brand { font-size: 15px; font-weight: 900; letter-spacing: .3px; }
.inv-brand span { display: block; font-size: 8px; letter-spacing: 1.2px; color: #6b7a89; font-weight: 700; margin-top: 3px; }
.inv-title { text-align: right; font-size: 9px; color: #6b7a89; line-height: 1.5; }
.inv-title b { display: block; font-size: 14px; color: #123239; letter-spacing: .5px; }
.inv-meta { display: flex; justify-content: space-between; gap: 16px; margin: 16px 0 14px; font-size: 8.5px; color: #4d5d6c; line-height: 1.55; }
.inv-meta b { color: #123239; }
.inv-table { width: 100%; border-collapse: collapse; font-size: 8px; }
.inv-table th { background: #eef4f6; color: #123239; font-size: 7.5px; letter-spacing: .5px; padding: 5px; border-bottom: 1px solid #cfdbe2; text-align: left; }
.inv-table td { padding: 5px; border-bottom: 1px solid #e8eef2; color: #33414f; }
.inv-table .r { text-align: right; }
.inv-table td:nth-child(3), .inv-table td:nth-child(4), .inv-table td:nth-child(5), .inv-table td:nth-child(6),
.inv-table th:nth-child(3), .inv-table th:nth-child(4), .inv-table th:nth-child(5), .inv-table th:nth-child(6) { white-space: nowrap; }
.inv-sum { margin-top: 12px; margin-left: auto; width: 220px; font-size: 8.5px; }
.inv-sum div { display: flex; justify-content: space-between; padding: 3px 0; gap: 12px; }
.inv-sum .total { border-top: 1.5px solid #123239; margin-top: 4px; padding-top: 6px; font-size: 11px; font-weight: 900; color: #123239; }
.inv-foot { margin-top: 18px; font-size: 7px; color: #7b8a99; line-height: 1.5; border-top: 1px solid #e1e8ed; padding-top: 7px; }

.doc-paper { font-size: 10px; line-height: 1.55; }
.paper-kicker { font-size: 8px; letter-spacing: 1.3px; color: #6b7a89; font-weight: 900; text-transform: uppercase; margin-bottom: 8px; }
.paper-title { font-size: 19px; line-height: 1.15; font-weight: 900; color: #123239; margin: 0 0 6px; }
.paper-sub { font-size: 10px; color: #6b7a89; margin-bottom: 16px; }
.paper-rule { height: 2px; background: #123239; margin: 12px 0 16px; }
.paper-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; margin-bottom: 16px; }
.paper-grid b { display: block; font-size: 8px; letter-spacing: .8px; color: #6b7a89; text-transform: uppercase; margin-bottom: 2px; }
.paper-p { margin: 0 0 9px; color: #33414f; }
.paper-sign { display: flex; justify-content: space-between; gap: 30px; margin-top: 36px; font-size: 8px; color: #6b7a89; }
.paper-sign div { border-top: 1px solid #9fb0b8; padding-top: 5px; width: 45%; text-align: center; }
.paper-stamp {
  margin-top: 22px; border: 1.5px dashed #b23b3b; color: #b23b3b;
  display: inline-block; padding: 6px 10px; font-size: 8px; font-weight: 900;
  letter-spacing: 1px; text-transform: uppercase; transform: rotate(-3deg);
}

.side-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  position: sticky; top: 96px; max-height: calc(100vh - 120px);
}
.panel-tabs { display: flex; border-bottom: 1px solid var(--line); padding: 0 14px; gap: 16px; flex: 0 0 43px; align-items: end; }
.panel-tab {
  font-size: 11.5px; font-weight: 700; color: #7b8a99; padding: 0 0 10px;
  background: transparent; border: 0; white-space: nowrap;
}
.panel-tab:hover { color: var(--teal); }
.panel-tab.active { color: var(--teal); box-shadow: inset 0 -2px 0 var(--teal); }
.panel-body { padding: 13px 15px 16px; overflow-y: auto; flex: 1; scrollbar-width: thin; }
.section-label { font-size: 9px; letter-spacing: 1px; text-transform: uppercase; color: #8b99a6; font-weight: 900; margin: 2px 0 8px; }
.kv { display: grid; grid-template-columns: 100px 1fr; gap: 7px 10px; font-size: 11.2px; margin-bottom: 12px; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 700; color: #2b3947; min-width: 0; overflow-wrap: anywhere; }
.kv .v.normal { font-weight: 400; }
.divider { height: 1px; background: var(--line-soft); margin: 11px 0; }
.timeline { position: relative; margin: 2px 0 0; }
.tl-item { display: flex; gap: 10px; position: relative; padding-bottom: 12px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot { width: 18px; height: 18px; border-radius: 50%; flex: 0 0 18px; display: grid; place-items: center; background: #eef3f5; color: #8b99a6; z-index: 1; border: 1px solid #d8e2e7; }
.tl-dot .ic { width: 10px; height: 10px; }
.tl-dot.done { background: var(--teal); border-color: var(--teal); color: #fff; }
.tl-dot.current { background: var(--gold); border-color: var(--gold); color: var(--navy); }
.tl-dot.returned { background: var(--red); border-color: var(--red); color: #fff; }
.tl-item:not(:last-child):before { content: ""; position: absolute; left: 8.5px; top: 18px; bottom: 0; width: 1px; background: #dbe4ea; }
.tl-body { font-size: 10.8px; line-height: 1.35; min-width: 0; }
.tl-body b { font-size: 11.2px; }
.tl-body .when { color: var(--muted); font-size: 9.8px; margin-top: 1px; }
.tl-body .who { color: #4d5d6c; }
.tl-body .late { color: var(--red); font-weight: 700; }

.comment-list { display: flex; flex-direction: column; gap: 10px; }
.comment-item { display: flex; gap: 8px; }
.comment-item .avatar { width: 26px; height: 26px; flex-basis: 26px; font-size: 9px; }
.comment-main { min-width: 0; }
.comment-head { font-size: 10.5px; color: #4d5d6c; margin-bottom: 2px; }
.comment-head b { color: var(--text); }
.comment-head span { color: #8b99a6; margin-left: 4px; }
.comment-text { font-size: 10.8px; color: #33414f; line-height: 1.4; }
.comment-form { display: flex; gap: 8px; margin-top: 12px; align-items: flex-start; }
.comment-form .avatar { width: 26px; height: 26px; flex-basis: 26px; font-size: 9px; }
.comment-form textarea {
  flex: 1; min-height: 38px; resize: vertical; border: 1px solid var(--line);
  border-radius: 7px; padding: 8px 9px; font-size: 11px; color: var(--text);
}
.comment-form textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(31,111,107,.18); }
.comment-form .btn { padding: 7px 9px; font-size: 10.5px; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(9,25,29,.56); z-index: 100;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: 12px; width: min(560px, 100%);
  max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 22px 60px rgba(9,25,29,.28); animation: modal-in .16s ease-out;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(8px) scale(.99); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 17px 19px 12px; border-bottom: 1px solid var(--line-soft); }
.modal-title { font-size: 17px; font-weight: 900; letter-spacing: -.2px; margin: 0; line-height: 1.2; }
.modal-sub { font-size: 11px; color: var(--muted); margin-top: 3px; }
.modal-close {
  margin-left: auto; width: 30px; height: 30px; border: 1px solid var(--line);
  background: #fff; border-radius: 7px; display: grid; place-items: center; color: #5d6c7b;
}
.modal-close:hover { background: #f6f9fa; }
.modal-body { padding: 16px 19px; overflow-y: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 19px 16px; border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 10.5px; font-weight: 700; color: #4d5d6c; }
.field input, .field textarea, .field select {
  border: 1px solid var(--line); border-radius: 7px; padding: 9px 10px;
  font-size: 12px; color: var(--text); background: #fff; width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px rgba(31,111,107,.18);
}
.field textarea { min-height: 82px; resize: vertical; }
.modal-note { font-size: 10.5px; color: var(--muted); background: #f6f9fa; border: 1px solid var(--line-soft); border-radius: 7px; padding: 8px 10px; margin: 10px 0 0; line-height: 1.45; }
.dropzone {
  border: 1px dashed #b9cdd4; border-radius: 8px; padding: 14px;
  text-align: center; color: var(--muted); font-size: 11px; background: #fbfcfd;
  cursor: pointer;
}
.dropzone:hover { border-color: var(--teal); background: #f7fbfa; }
.dropzone b { display: block; color: var(--text); font-size: 12px; margin-bottom: 2px; }
.dropzone.selected { border-style: solid; border-color: var(--teal); background: var(--teal-soft); color: var(--teal-dark); }
.help-steps { margin: 0; padding-left: 18px; font-size: 12px; color: #3c4b59; line-height: 1.6; }
.help-steps li { margin-bottom: 7px; }
.help-steps b { color: var(--text); }
.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 11px; color: #4d5d6c; margin-top: 10px; }
.shortcut-grid kbd { font-family: inherit; background: #f4f7f9; border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-weight: 700; }
.feedback-questions { font-size: 11.5px; color: #4d5d6c; line-height: 1.6; margin-bottom: 10px; }
.feedback-questions b { color: var(--text); }

/* ---------- Toast ---------- */
body.modal-open { overflow: hidden; }
.icon-only { padding-left: 9px; padding-right: 9px; }
.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif {
  display: flex; align-items: center; gap: 10px; width: 100%;
  text-align: left; background: #fff; border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; color: var(--text);
}
.notif:hover { background: #f7fbfa; border-color: #c6d8de; }
.notif .doc-ico { width: 28px; height: 32px; flex-basis: 28px; }
.notif-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notif-main b { font-size: 11.5px; line-height: 1.3; }
.notif-main span { font-size: 10.3px; color: var(--muted); }
.notif > .ic { color: #8b99a6; width: 14px; height: 14px; }
.dropzone span { display: block; font-size: 10.5px; margin-top: 2px; }

.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 120;
  background: #123239; color: #fff; border-radius: 9px;
  padding: 11px 13px; font-size: 12px; box-shadow: 0 12px 30px rgba(9,25,29,.25);
  display: flex; align-items: center; gap: 12px; max-width: min(420px, calc(100vw - 40px));
  transform: translateY(16px); opacity: 0; pointer-events: none; transition: .18s ease;
}
.toast.show { transform: none; opacity: 1; pointer-events: auto; }
.toast-btn {
  border: 1px solid #4f777d; background: transparent; color: var(--gold);
  border-radius: 6px; padding: 3px 7px; font-size: 10.5px; font-weight: 900; white-space: nowrap;
}
.toast-btn:hover { background: #1b4a52; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .doc-grid { grid-template-columns: minmax(0, 1fr) 380px; }
  .preview-page { padding: 28px 30px; }
  .doc-head .amount { margin-left: 0; }
}
@media (max-width: 980px) {
  .sidebar { width: 210px; flex-basis: 210px; }
  .content { padding: 20px 18px 40px; }
  .topbar { padding: 10px 18px; }
  .doc-grid { grid-template-columns: 1fr; }
  /* The invoice table may be wider than a phone; scroll it inside the preview, never the whole page. */
  .preview { max-height: none; overflow-x: auto; overflow-y: visible; }
  .side-panel { position: static; max-height: none; }
  .panel-body { max-height: none; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .doc-head .amount { margin-left: auto; }
}
@media (max-width: 760px) {
  .demo-strip { flex-wrap: wrap; gap: 6px 8px; padding: 7px 12px; position: static; }
  .demo-text { white-space: normal; flex: 1 1 180px; }
  .demo-spacer { display: none; }
  .app { display: block; min-height: 0; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 264px; height: 100vh;
    transform: translateX(-102%); transition: transform .18s ease, visibility .18s;
    visibility: hidden; /* keeps the closed drawer out of the Tab order */
    z-index: 90; box-shadow: 10px 0 30px rgba(9,25,29,.25);
  }
  body.nav-open .sidebar { transform: none; visibility: visible; }
  .nav-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(9,25,29,.45);
    z-index: 80; opacity: 0; pointer-events: none; transition: opacity .18s ease;
  }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  .menu-btn { display: grid; }
  .topbar { position: static; flex-wrap: wrap; gap: 9px; padding: 10px 14px; }
  .crumb { flex: 1; white-space: normal; font-size: 11px; }
  .search { order: 3; flex-basis: 100%; max-width: none; height: 36px; }
  .search kbd { display: none; }
  .top-actions { margin-left: 0; gap: 7px; }
  .top-actions .icon-btn { width: 32px; height: 32px; }
  .content { padding: 16px 13px 34px; }
  h1 { font-size: 22px; }
  .page-head { gap: 10px; }
  .head-actions { width: 100%; margin-left: 0; }
  .head-actions .btn { flex: 1; justify-content: center; }
  .toolbar { gap: 8px; }
  .tabs { width: 100%; display: grid; grid-template-columns: 1fr 1fr; }
  .tab { padding: 7px 6px; font-size: 10.8px; white-space: nowrap; text-align: center; }
  .filters { margin-left: 0; width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .filters .select { width: 100%; }
  .filters .select select { width: 100%; max-width: none; }
  .filters .select:last-child { grid-column: 1 / -1; }
  .table-wrap { background: transparent; border: 0; overflow: visible; }
  .table-wrap > table { min-width: 0; }
  .table-wrap thead { display: none; }
  .table-wrap tbody { display: block; }
  .table-wrap tbody tr { display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; margin-bottom: 8px; position: relative; }
  .table-wrap tbody td { display: none; border: 0; padding: 0; }
  .table-wrap tbody td:first-child { display: block; padding-right: 64px; }
  .table-wrap tbody td.row-act { display: block; position: absolute; right: 10px; top: 12px; padding: 0; }
  .table-wrap tbody td:first-child .doc-meta { white-space: normal; max-width: none; }
  .mobile-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 7px; }
  .mobile-meta .chip, .mobile-meta .type { font-size: 9.5px; padding: 3px 6px; }
  .mobile-meta .due { font-size: 10.5px; }
  .mobile-meta .num { font-size: 11px; }
  .mobile-owner { font-size: 10px; color: var(--muted); }
  .table-wrap .pagination { border-top: 0; background: transparent; padding: 8px 2px; }
  .stats { gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat .n { font-size: 18px; }
  .doc-head { padding: 12px; gap: 10px; }
  .doc-head-main { width: 100%; }
  .doc-head h1 { font-size: 17px; }
  .doc-head .amount { margin-left: 0; font-size: 19px; }
  .doc-actions { width: 100%; margin-left: 0; }
  .doc-actions .btn { flex: 1; justify-content: center; }
  .doc-actions .btn.icon-only { flex: 0 0 38px; }
  .preview { padding: 6px; }
  .preview-page { padding: 22px 12px; }
  .inv-top { gap: 10px; }
  .inv-brand { font-size: 12px; }
  .inv-title b { font-size: 11px; }
  .inv-meta { gap: 10px; }
  .inv-table { font-size: 7px; }
  .inv-table th, .inv-table td { padding: 4px 3px; }
  .inv-sum { width: 190px; }
  .paper-grid { grid-template-columns: 1fr; gap: 8px; }
  .paper-title { font-size: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .shortcut-grid { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 10px; align-items: flex-end; }
  .modal { max-height: 94vh; border-radius: 12px 12px 0 0; }
  .toast { right: 10px; bottom: 10px; left: 10px; max-width: none; }
  .summary { gap: 8px; }
  .sum-card { padding: 9px 11px; }
  .sum-card .n { font-size: 18px; }
}
@media (max-width: 480px) {
  .demo-btn { font-size: 10px; padding: 3px 6px; }
  .demo-pill { font-size: 8px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat .l { font-size: 9.5px; }
  .filters { grid-template-columns: 1fr; }
  .filters .select:last-child { grid-column: auto; }
  .pagination { gap: 6px; font-size: 9.5px; }
  .page-n { min-width: 32px; height: 32px; }
  .doc-head .meta-line { font-size: 10px; }
  .doc-actions .btn { font-size: 10.5px; padding: 8px 8px; }
  .doc-actions .btn .ic { width: 14px; height: 14px; }
  .preview-bar { font-size: 9px; }
  .preview-nav { font-size: 9px; }
}

/* ---------- Print ---------- */
@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; font-size: 10pt; }
  .demo-strip, .sidebar, .topbar, .doc-head, .doc-alert, .doc-actions, .side-panel, .preview-bar, .preview-nav, .toast, .modal-backdrop, .back { display: none !important; }
  .app, .main, .content, .page, .doc-grid, .preview { display: block !important; padding: 0 !important; margin: 0 !important; background: #fff !important; border: 0 !important; box-shadow: none !important; }
  .preview-page { box-shadow: none !important; width: 100% !important; max-width: none !important; padding: 0 !important; border-radius: 0 !important; }
  .doc-grid { height: auto !important; }
  .preview { overflow: visible !important; max-height: none !important; }
}
