:root {
  --bg: #f5f7f6;
  --surface: #ffffff;
  --surface-2: #eef4f1;
  --ink: #17201c;
  --muted: #63726b;
  --line: #d8e2dc;
  --brand: #1f7a63;
  --brand-2: #155846;
  --amber: #b46b00;
  --amber-bg: #fff6e6;
  --red: #aa352f;
  --red-bg: #fff0ef;
  --blue: #2d5f9a;
  --blue-bg: #eef5ff;
  --shadow: 0 16px 36px rgba(22, 32, 28, 0.08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

body.auth-locked .app-shell {
  display: none;
}

body.auth-ready .login-screen {
  display: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(15, 26, 22, 0.92), rgba(21, 88, 70, 0.9)),
    #0f1a16;
}

.login-card {
  width: min(100%, 430px);
  background: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
  padding: 28px;
  display: grid;
  gap: 14px;
}

.login-logo {
  width: 82px;
  height: 82px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: #fff;
}

.login-card h1 {
  margin: -6px 0 0;
  font-size: 25px;
  letter-spacing: 0;
}

.login-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 14px;
}

.login-error {
  min-height: 20px;
  color: var(--red);
  font-weight: 800;
  margin: 0;
  font-size: 13px;
}

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

.side {
  background: #0f1a16;
  color: #f7fbf8;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #58c39c, #1f7a63);
  font-weight: 800;
  font-size: 22px;
}

.brand-logo {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
  padding: 4px;
  flex: 0 0 auto;
}

.brand-block h1 {
  font-size: 19px;
  margin: 0;
  letter-spacing: 0;
}

.brand-block p {
  margin: 2px 0 0;
  color: #a9bbb3;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 7px;
}

.nav-btn,
.icon-btn,
.ghost-btn,
.primary-btn {
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}

.nav-btn {
  justify-content: flex-start;
  padding: 11px 12px;
  color: #dce8e2;
  background: transparent;
}

.nav-btn:hover,
.nav-btn.is-active {
  background: rgba(255, 255, 255, 0.1);
}

.nav-btn svg,
.ghost-btn svg,
.primary-btn svg,
.icon-btn svg,
.notice svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.side-actions {
  margin-top: auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.icon-btn {
  min-width: 42px;
  height: 42px;
  background: rgba(255, 255, 255, 0.1);
  color: #f7fbf8;
  position: relative;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}

.icon-btn.danger:hover {
  background: rgba(170, 53, 47, 0.45);
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.main {
  padding: 22px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--brand);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.topbar h2 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.top-actions,
.button-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.primary-btn {
  background: var(--brand);
  color: #fff;
  min-height: 40px;
  padding: 10px 14px;
  font-weight: 800;
}

.primary-btn:hover {
  background: var(--brand-2);
}

.ghost-btn {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  min-height: 40px;
  padding: 10px 13px;
  font-weight: 700;
}

.ghost-btn:hover {
  border-color: #b8c7c0;
  background: #f9fbfa;
}

.ghost-btn.small {
  min-height: 34px;
  padding: 8px 10px;
  font-size: 13px;
}

.full-width {
  width: 100%;
}

.market-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.market-card {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  box-shadow: 0 8px 20px rgba(22, 32, 28, 0.04);
  text-align: left;
}

.market-card:hover {
  border-color: #a8bbb2;
  background: #fbfdfc;
}

.market-card.is-active {
  border-color: var(--brand);
  background: #edf8f3;
}

.market-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 900;
}

.market-title svg {
  width: 21px;
  height: 21px;
}

.market-detail {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.market-badge {
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--brand-2);
  padding: 7px 10px;
  font-weight: 900;
  font-size: 12px;
  white-space: nowrap;
}

.market-card.is-active .market-badge {
  background: var(--brand);
  color: #fff;
}

.notice {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--amber-bg);
  border: 1px solid #f1cc8b;
  color: #4c340c;
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.notice strong {
  display: block;
  margin-bottom: 2px;
}

.notice span {
  color: #71521d;
  font-size: 13px;
  line-height: 1.45;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 98px;
  box-shadow: 0 8px 20px rgba(22, 32, 28, 0.04);
}

.metric .label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric .value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 850;
  letter-spacing: 0;
  line-height: 1.1;
}

.metric .detail {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.metric.warn {
  border-color: #ecc173;
  background: #fffaf0;
}

.metric.good {
  border-color: #9bd4bf;
  background: #f0fbf6;
}

.metric.bad {
  border-color: #eba6a1;
  background: #fff5f4;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-6 {
  grid-column: span 6;
}

.span-7 {
  grid-column: span 7;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: span 12;
}

.panel,
.invoice-paper {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-head h3 {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0;
}

.panel-head span {
  color: var(--muted);
  font-size: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.form-grid.single {
  grid-template-columns: 1fr;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.field input,
.field select,
.field textarea,
.cell-input,
.cell-select {
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 38px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}

.field textarea {
  min-height: 82px;
  resize: vertical;
}

.toggle-line {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 10px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  text-transform: none;
}

.toggle-line input {
  width: 18px;
  height: 18px;
}

.form-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
}

.span-form {
  grid-column: span 2;
}

.service-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: #26352f;
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #f7faf8;
  color: #52625b;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

td {
  font-size: 13px;
}

tr:last-child td {
  border-bottom: 0;
}

.cell-check {
  width: 18px;
  height: 18px;
}

.text-select {
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  font-weight: 850;
  text-align: left;
}

.text-select:hover {
  color: var(--brand);
}

.subline {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.audit-subline {
  display: block;
  margin-top: 4px;
  color: #6f7d76;
  font-size: 11px;
  line-height: 1.35;
}

.audit-panel {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  border: 1px solid #dfe8e3;
  border-radius: var(--radius);
  background: #f7faf8;
  padding: 10px;
  margin: 4px 0 12px;
}

.audit-panel div {
  min-width: 0;
}

.audit-panel span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.audit-panel strong {
  display: block;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.amount-cell {
  font-weight: 850;
  white-space: nowrap;
}

.row-action {
  border: 0;
  background: transparent;
  color: var(--red);
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 7px;
}

.row-action:hover {
  background: var(--red-bg);
}

.chart-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 190px 1fr 90px;
  gap: 12px;
  align-items: center;
}

.bar-label {
  font-weight: 800;
  font-size: 13px;
}

.bar-track {
  height: 12px;
  background: #e8eeeb;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--brand);
}

.bar-fill.amber {
  background: var(--amber);
}

.bar-fill.red {
  background: var(--red);
}

.bar-value {
  font-weight: 850;
  text-align: right;
  font-size: 13px;
}

.check-list {
  display: grid;
  gap: 10px;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.guide-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7faf8;
  padding: 14px;
}

.guide-card h4 {
  margin: 0 0 8px;
  font-size: 15px;
}

.guide-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.check-item {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.check-item:last-child {
  border-bottom: 0;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 5px;
  background: var(--brand);
}

.dot.warn {
  background: var(--amber);
}

.dot.bad {
  background: var(--red);
}

.check-title {
  font-weight: 850;
  font-size: 13px;
}

.check-detail {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quick-card {
  min-height: 82px;
  border: 1px solid var(--line);
  background: #fbfdfc;
  color: var(--ink);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  place-items: center;
  gap: 8px;
  font-weight: 850;
}

.quick-card:hover {
  border-color: var(--brand);
  background: #f0fbf6;
}

.quick-card svg {
  width: 22px;
  height: 22px;
  color: var(--brand);
}

.selected-row td {
  background: #f0fbf6;
}

.row-tools {
  display: flex;
  gap: 6px;
  align-items: center;
}

.mini-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.compact-wrap {
  margin-bottom: 12px;
}

.compact-table {
  min-width: 720px;
}

.service-line-table th:first-child,
.service-line-table td:first-child {
  min-width: 260px;
}

.line-description,
.service-template-details {
  min-height: 110px;
  margin-top: 8px;
  line-height: 1.4;
}

.service-name-input {
  margin-top: 8px;
}

.upload-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7faf8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  margin-bottom: 12px;
}

.upload-card strong,
.upload-card span {
  display: block;
}

.upload-card span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
}

.inline-file {
  position: relative;
  overflow: hidden;
}

.ghost-link {
  color: var(--brand-2);
  font-weight: 850;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 34px;
  padding: 8px 10px;
  display: inline-flex;
  align-items: center;
  background: #fff;
}

.service-picker {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfdfc;
  padding: 12px;
  margin-bottom: 12px;
}

.service-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.service-picker-head strong,
.service-picker-head span {
  display: block;
}

.service-picker-head span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  line-height: 1.35;
}

.service-picker-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 4px;
}

.service-check {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px;
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  align-items: start;
}

.service-check.already-added {
  border-color: #9bd4bf;
  background: #f0fbf6;
}

.service-check input {
  margin-top: 2px;
}

.service-check strong,
.service-check small {
  display: block;
}

.service-check strong {
  font-size: 13px;
}

.service-check small {
  color: var(--muted);
  line-height: 1.35;
  margin-top: 3px;
}

.ledger-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.ledger-summary div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7faf8;
  padding: 12px;
}

.ledger-summary span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.ledger-summary strong {
  font-size: 15px;
}

.ledger-summary small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.35;
}

.compact-summary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.company-preview {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7faf8;
  padding: 12px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.company-preview img {
  width: 58px;
  height: 58px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
  border: 1px solid var(--line);
}

.company-preview strong,
.company-preview span {
  display: block;
}

.company-preview span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 3px;
  line-height: 1.35;
}

.signature-upload-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #f7faf8;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 12px;
  align-items: center;
}

.signature-upload-card span,
.signature-upload-card strong,
.signature-upload-card small {
  display: block;
}

.signature-upload-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.signature-upload-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 4px;
}

.signature-preview {
  min-height: 86px;
  border: 1px dashed #b8c7c0;
  border-radius: 8px;
  background: #fff;
  display: grid;
  place-items: center;
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
}

.signature-preview img {
  max-width: 100%;
  max-height: 78px;
  object-fit: contain;
}

.ledger-select {
  min-width: 240px;
}

.invoice-paper {
  width: 210mm;
  min-height: 297mm;
  padding: 13mm;
  background: #fff;
  color: #111916;
  max-width: 100%;
  margin: 0 auto;
  overflow: hidden;
}

.invoice-preview-panel {
  overflow-x: auto;
}

.invoice-head {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 2px solid #17201c;
  padding-bottom: 18px;
  margin-bottom: 18px;
}

.invoice-logo {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.invoice-logo img {
  width: 82px;
  height: 82px;
  object-fit: contain;
  flex: 0 0 auto;
}

.invoice-head h3 {
  margin: 0;
  font-size: 20px;
}

.invoice-head p,
.invoice-meta p,
.invoice-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.invoice-meta {
  text-align: right;
  min-width: 240px;
}

.invoice-meta h2 {
  margin: 0 0 8px;
  font-size: 24px;
  letter-spacing: 0;
}

.bill-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 18px;
  margin-bottom: 18px;
}

.bill-grid h4,
.invoice-copy h4 {
  margin: 5px 0 7px;
}

.bill-grid p {
  margin: 3px 0;
  color: var(--muted);
  font-size: 12px;
}

.invoice-label {
  display: inline-flex;
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.invoice-items {
  min-width: 0;
  border: 1px solid var(--line);
  margin-bottom: 18px;
}

.invoice-items th,
.invoice-items td {
  vertical-align: top;
}

.invoice-items th:nth-child(1),
.invoice-items td:nth-child(1) {
  width: 44px;
}

.invoice-items th:nth-child(3),
.invoice-items th:nth-child(4),
.invoice-items th:nth-child(5),
.invoice-items td:nth-child(3),
.invoice-items td:nth-child(4),
.invoice-items td:nth-child(5) {
  text-align: right;
  white-space: nowrap;
}

.invoice-items p {
  margin: 5px 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.service-desc span {
  display: block;
  font-weight: 850;
  margin: 7px 0 4px;
}

.service-desc ul,
.invoice-copy ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.service-desc li,
.invoice-copy li {
  margin: 2px 0;
  line-height: 1.35;
}

.invoice-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
}

.invoice-copy {
  color: var(--muted);
  font-size: 12px;
}

.invoice-sums {
  display: grid;
  gap: 8px;
}

.invoice-sums div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.invoice-sums .grand {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  font-size: 18px;
  font-weight: 900;
}

.invoice-signature-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  margin-top: 72px;
}

.digital-signature {
  text-align: center;
  min-height: 92px;
  display: grid;
  align-content: end;
  justify-items: center;
  gap: 4px;
}

.digital-signature img {
  max-width: 210px;
  max-height: 68px;
  object-fit: contain;
}

.digital-signature strong,
.digital-signature span {
  display: block;
}

.digital-signature strong {
  font-weight: 850;
}

.digital-signature span {
  color: var(--muted);
  font-size: 12px;
}

.signature-placeholder {
  width: 210px;
  min-height: 48px;
  border: 1px dashed #9aa9a2;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  padding: 8px;
  margin-bottom: 4px;
}

.invoice-total {
  display: grid;
  gap: 8px;
  max-width: 360px;
  margin-left: auto;
  margin-top: 16px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.total-row.grand {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  font-weight: 900;
  font-size: 18px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 12px;
  background: var(--surface-2);
}

.status-pill.paid {
  background: #dff6ea;
  color: #155846;
}

.status-pill.active {
  background: #dff6ea;
  color: #155846;
}

.status-pill.invoiced,
.status-pill.unpaid,
.status-pill.overdue,
.status-pill.partial {
  background: var(--amber-bg);
  color: #714900;
}

.status-pill.paid {
  background: #dff6ea;
  color: #155846;
}

.status-pill.cancelled {
  background: var(--red-bg);
  color: var(--red);
}

.status-pill.disabled {
  background: #edf0ef;
  color: #63726b;
}

.status-pill.pending {
  background: #f0f2f1;
  color: #5b6863;
}

.empty {
  color: var(--muted);
  padding: 22px;
  text-align: center;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .nav-btn {
    justify-content: center;
  }

  .metrics-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8,
  .span-12 {
    grid-column: span 12;
  }
}

@media (max-width: 720px) {
  .main {
    padding: 14px;
  }

  .topbar,
  .invoice-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar h2 {
    font-size: 22px;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics-grid,
  .form-grid,
  .market-switch,
  .mini-form,
  .ledger-summary,
  .audit-panel,
  .quick-grid,
  .guide-grid,
  .signature-upload-card,
  .bill-grid,
  .invoice-bottom,
  .invoice-signature-row,
  .service-picker-grid {
    grid-template-columns: 1fr;
  }

  .service-picker-head,
  .company-preview {
    flex-direction: column;
  }

  .bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .bar-value {
    text-align: left;
  }

  .invoice-meta {
    text-align: left;
  }
}

@page {
  size: A4 portrait;
  margin: 10mm;
}

@media print {
  html,
  body {
    width: 210mm;
    min-height: 297mm;
  }

  body {
    background: #fff;
    color: #111916;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .side,
  .login-screen,
  .topbar,
  .notice,
  .market-switch,
  .top-actions,
  .notice,
  .ledger-panel .panel-head .top-actions {
    display: none !important;
  }

  body.print-ledger .view:not(#ledger),
  body.print-invoice .view:not(#invoices),
  body.print-invoice #invoices > .content-grid > .panel:not(.invoice-preview-panel),
  body.print-invoice .invoice-preview-panel .panel-head {
    display: none !important;
  }

  .app-shell,
  .content-grid {
    display: block;
  }

  .main {
    padding: 0;
  }

  body.print-ledger #ledger,
  body.print-invoice #invoices {
    display: block !important;
  }

  .panel {
    border: 0;
    box-shadow: none;
    border-radius: 0;
    padding: 0;
    margin: 0;
  }

  body.print-invoice .invoice-preview-panel {
    overflow: visible;
  }

  .invoice-paper {
    border: 0;
    box-shadow: none;
    width: 100%;
    min-height: calc(297mm - 20mm);
    padding: 0;
    max-width: none;
    margin: 0;
    overflow: visible;
  }

  .invoice-head,
  .bill-grid,
  .invoice-bottom,
  .invoice-signature-row {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .invoice-items {
    page-break-inside: auto;
  }

  .invoice-items thead {
    display: table-header-group;
  }

  .invoice-items tr,
  .service-desc,
  .invoice-copy li {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .invoice-signature-row {
    margin-top: 24mm;
  }

  .invoice-copy,
  .invoice-head p,
  .invoice-meta p,
  .bill-grid p {
    color: #3f4d47;
  }
}
