:root {
  color-scheme: light;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  --ink: #14263d;
  --muted: #52657e;
  --background: #f3f6fa;
  --line: #d9e3ef;
  --navy: #101f36;
  --blue: #2056bd;
  --blue-dark: #173e8c;
  --green: #17644e;
  --amber: #815109;
  --red: #a92338;
  --radius: 12px;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--background); }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.025em; }
h1 { font-size: clamp(1.8rem, 2.9vw, 2.5rem); }
h2 { font-size: 1.14rem; }
h3 { font-size: 1rem; }
p { margin: .45rem 0 .9rem; }
a { color: #164aa4; text-underline-offset: .18em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid #3e79ed; outline-offset: 3px; }
[hidden] { display: none !important; }

.shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 230px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: auto;
  padding: 23px 16px;
  background: linear-gradient(166deg, #102743, var(--navy) 62%);
  color: #edf4ff;
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  place-items: center;
  border: 1px solid #8dd7ff52;
  border-radius: 10px;
  background: #153853;
  color: #f4faff;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -.045em;
}
.sidebar .brand { margin: 0 5px 22px; }
.brand strong, .brand small { display: block; }
.brand strong { margin-bottom: 1px; font-size: .99rem; }
.brand small { color: #b4c9e3; font-size: .74rem; }
.nav { display: flex; flex-direction: column; gap: 5px; }
.nav a {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #d9e6f7;
  font-size: .89rem;
  font-weight: 650;
  text-decoration: none;
}
.nav a:hover { color: white; background: #ffffff13; }
.nav a[aria-current="page"] { border-color: #9ccfff33; background: #2b5594; color: #fff; }

.workspace, .content { min-width: 0; }
.topbar {
  display: flex;
  flex-wrap: wrap;
  min-height: 66px;
  justify-content: space-between;
  align-items: center;
  gap: 10px 16px;
  padding: 10px clamp(16px, 3.5vw, 40px);
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.breadcrumbs { color: #314b70; font-size: .88rem; font-weight: 750; }
.content { max-width: 1540px; margin: 0 auto; padding: 26px clamp(16px, 3.5vw, 40px) 46px; }
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px 22px;
  margin: 0 0 22px;
}
.page-head p { margin: 7px 0 0; }
.muted { color: var(--muted); }
.empty { padding: 18px 0; }

.panel {
  min-width: 0;
  margin: 0 0 15px;
  padding: clamp(15px, 2.2vw, 23px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 2px 6px #14376606;
}
.panel h2 + :is(p,form,dl,ul,details,pre,.button-row,.table-scroll) { margin-top: 12px; }
.panel > :last-child { margin-bottom: 0; }
.grid, .split, .form-grid { display: grid; gap: 13px; }
.grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.split { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid > *, .split > *, .form-grid > * { min-width: 0; }

button, input, select, textarea { font: inherit; color: inherit; }
input:not([type="checkbox"], [type="radio"], [type="hidden"]), select, textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #bfcfe2;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 100px; resize: vertical; }
input[type="file"] { padding: 6px; }
input:is([type="radio"], [type="checkbox"]) { accent-color: var(--blue); width: 17px; height: 17px; margin: 0; }
.field { display: grid; min-width: 0; align-content: start; gap: 5px; }
.field span { font-size: .86rem; font-weight: 660; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 30px; font-size: .91rem; }
.check input { flex: 0 0 auto; }
.actions, .toolbar, .button-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
  min-width: 0;
}
.toolbar { align-items: flex-end; margin-bottom: 14px; }
.toolbar > .field { flex: 1 1 145px; }
.button-row { margin-top: 14px; }
.topbar .actions form { margin: 0; }

.btn {
  display: inline-flex;
  min-height: 41px;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border: 1px solid #c5d2e5;
  border-radius: 8px;
  background: #fff;
  color: #203857;
  font-size: .88rem;
  font-weight: 690;
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn:not(:disabled):hover { border-color: #a8c0e0; background: #edf4ff; }
.btn.primary { border-color: var(--blue); background: var(--blue); color: #fff; }
.btn.primary:not(:disabled):hover { border-color: var(--blue-dark); background: var(--blue-dark); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.table-scroll { overflow-x: auto; max-width: 100%; }
table { width: 100%; min-width: 520px; border-collapse: collapse; text-align: left; font-size: .9rem; }
td, th { padding: 10px 11px; border-bottom: 1px solid #e4ebf4; vertical-align: top; }
th { background: #eef3f9; color: #354b68; font-size: .81rem; font-weight: 720; }
tbody tr:hover { background: #f8fbff; }
td a { font-weight: 670; }
td p { margin: 0; }
.mail-origin { font-weight: 650; }

.flash {
  margin: 0 0 16px;
  padding: 10px 13px;
  border: 1px solid #a5d8c5;
  border-radius: 8px;
  color: var(--green);
  background: #e9f8f1;
}
.flash.error, .flash.danger { border-color: #ebbec6; color: var(--red); background: #fdeff2; }
.flash.warning { border-color: #e5ce9e; color: var(--amber); background: #fff6e3; }
.badge, .status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  color: #314b70;
  background: #e9eff7;
  font-size: .79rem;
  font-weight: 710;
}
.status.valid, .status.success, .status.sent { color: var(--green); background: #e6f6ed; }
.status.warning, .status.warnings, .status.pending { color: var(--amber); background: #fff2db; }
.status.invalid, .status.error, .status.failed { color: var(--red); background: #fcecf0; }

.facts {
  display: grid;
  grid-template-columns: minmax(100px, .7fr) minmax(0, 1fr);
  gap: 8px 12px;
  margin: 12px 0;
}
.facts dt { font-size: .86rem; font-weight: 690; color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
fieldset { min-width: 0; margin: 0 0 13px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
legend { padding: 0 6px; font-weight: 700; }
.permission-set .form-grid { margin-top: 10px; }
pre {
  max-width: 100%;
  max-height: 440px;
  overflow: auto;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f5f8fc;
  font-size: .82rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
summary { cursor: pointer; font-weight: 700; }

.invoice-editor { min-width: 0; }
.line-editor {
  display: grid;
  grid-template-columns: minmax(150px, 2.3fr) repeat(4, minmax(72px, .8fr)) auto;
  gap: 9px;
  align-items: end;
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faff;
}
.customer-search { position: relative; }
.suggestions {
  display: grid;
  margin: 5px 0 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f3f7fd;
}
.suggestions button { padding: 7px; text-align: left; }
.inline-customer { margin-top: 12px; }

.sign-in {
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  place-items: center;
  padding: 22px 16px;
  background: radial-gradient(ellipse at 70% 0%, #204b7a, #0a1c33 72%);
}
.auth-card {
  width: min(100%, 445px);
  padding: clamp(19px, 4.4vw, 33px);
  border: 1px solid #d7e2f1;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 12px 32px #020d1f42;
}
.auth-card .brand { margin-bottom: 23px; }
.auth-card .brand small { color: var(--muted); }
.auth-card .page-head { margin-bottom: 16px; }
.auth-card h1 { font-size: 1.7rem; }
.auth-card .form-grid { grid-template-columns: 1fr; }
.auth-card .field + .field { margin-top: 10px; }
.auth-card .form-grid .field + .field { margin-top: 0; }

@media (max-width: 1100px) {
  .line-editor { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .line-editor > .field:first-child { grid-column: span 2; }
}
@media (max-width: 830px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; padding: 11px 14px 9px; }
  .sidebar .brand { margin: 0 0 9px; }
  .sidebar .brand-mark { width: 34px; height: 34px; flex-basis: 34px; }
  .nav { flex-direction: row; overflow-x: auto; padding: 4px; margin: -4px; }
  .nav a { flex: 0 0 auto; padding: 8px 10px; white-space: nowrap; }
  .topbar { min-height: 52px; }
  .content { padding-top: 20px; }
}
@media (max-width: 610px) {
  .split, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .topbar .actions { flex-wrap: wrap; }
  .topbar .actions > .muted { max-width: min(100%, 170px); overflow-wrap: anywhere; }
  .line-editor { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .line-editor > .field:first-child { grid-column: 1 / -1; }
  .facts { grid-template-columns: minmax(72px, .8fr) minmax(0, 1fr); }
}
@media print {
  body, .panel { background: #fff; }
  .shell { display: block; }
  .sidebar, .topbar, .page-head .actions, .button-row, .toolbar, .flash { display: none !important; }
  .content { padding: 0; }
  .panel { box-shadow: none; }
}
