:root {
  --bg: #f3f6fa;
  --surface: #ffffff;
  --surface-strong: #ffffff;
  --surface-soft: #f8fafc;
  --border: #d9e2ec;
  --text: #1f2d3d;
  --muted: #64748b;
  --primary: #1f4e79;
  --primary-dark: #173b5d;
  --primary-soft: #e8f0f7;
  --success-soft: #e9f7ef;
  --warning-soft: #fdf0e3;
  --info-soft: #e8efff;
  --neutral-soft: #eef2f6;
  --danger-soft: rgba(185, 28, 28, 0.12);
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
  --shadow-soft: 0 2px 10px rgba(15, 23, 42, 0.04);
  --radius-xl: 16px;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  position: relative;
  isolation: isolate;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
}

body::before {
  content: none;
}

a {
  color: inherit;
}

.site-header {
  padding: 24px 24px 0;
}

.site-header__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  border-radius: 14px;
}

.brand {
  text-decoration: none;
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
}

.brand__eyebrow,
.eyebrow,
.section-kicker {
  color: var(--primary);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.brand__title {
  color: var(--text);
  font-family: inherit;
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
}

.brand__title span {
  color: var(--primary);
}

.site-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 24px 40px;
}

.page-shell {
  display: grid;
  gap: 22px;
}

.page-shell--detail {
  gap: 20px;
}

.page-shell--narrow {
  max-width: 760px;
}

.page-hero,
.panel,
.table-card,
.party-card,
.summary-card,
.totals-card,
.login-box,
.note-card,
.error-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}

.page-hero {
  padding: 24px 26px;
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.85fr);
  gap: 20px;
  align-items: start;
}

.page-hero::after {
  content: none;
}

.page-hero h2,
.login-box h2,
.error-box h2 {
  margin: 8px 0 10px;
  font-family: inherit;
  font-size: clamp(1.75rem, 2vw, 2.15rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.hero-copy,
.login-note,
.error-copy {
  max-width: 56ch;
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

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

.stat-card,
.summary-card {
  padding: 16px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  border: 1px solid var(--border);
}

.stat-card__label,
.summary-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.stat-card__value,
.summary-value {
  display: block;
  margin-top: 8px;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.summary-value--text {
  font-size: 1.1rem;
  line-height: 1.3;
}

.stat-card__meta,
.summary-meta,
.meta {
  color: var(--muted);
  font-size: 0.92rem;
}

.hero-actions,
.actions-top,
.search-form__actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-actions {
  justify-content: flex-end;
  align-self: center;
}

.detail-meta,
.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.panel,
.table-card,
.note-card {
  padding: 20px;
}

.table-card {
  overflow: hidden;
}

.search-form {
  display: grid;
  grid-template-columns: minmax(280px, 2.2fr) repeat(2, minmax(150px, 1fr)) auto auto;
  gap: 14px;
  align-items: end;
}

.field,
.toggle-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span,
.toggle-field span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.field input,
.search-form button,
.btn,
.btn-secondary,
.btn-google,
.action-link,
.pager-link,
.user-box__action {
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}

.field input {
  width: 100%;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

.field input:focus,
.search-form button:focus,
.btn:focus,
.btn-secondary:focus,
.btn-google:focus,
.action-link:focus,
.pager-link:focus,
.user-box__action:focus {
  outline: none;
  border-color: rgba(15, 118, 110, 0.4);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.toggle-field {
  flex-direction: row;
  align-items: center;
  align-self: stretch;
  justify-content: center;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.toggle-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.search-form button,
.btn,
.btn-google {
  border: none;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font: inherit;
  font-weight: 700;
  box-shadow: none;
}

.btn-secondary,
.action-link--secondary,
.pager-link,
.user-box__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  box-shadow: none;
}

.search-form button:hover,
.btn:hover,
.btn-google:hover,
.btn-secondary:hover,
.action-link:hover,
.pager-link:hover,
.user-box__action:hover {
  transform: translateY(-1px);
}

.btn-google {
  justify-self: start;
  background: #ffffff;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.tag,
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

.tag {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--text);
}

.status-pill--success {
  background: var(--success-soft);
  color: #166534;
}

.status-pill--warning {
  background: var(--warning-soft);
  color: #b45309;
}

.status-pill--info {
  background: var(--info-soft);
  color: #1d4ed8;
}

.status-pill--neutral {
  background: var(--neutral-soft);
  color: #475569;
}

.table-header,
.table-title-group,
.party-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.table-title-group {
  flex-direction: column;
}

.table-title-group h3,
.party-card h3 {
  margin: 0;
  font-family: inherit;
  font-size: 1.25rem;
  line-height: 1.2;
}

.table-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  margin-top: 16px;
}

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

th,
td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid #e6edf5;
  vertical-align: middle;
}

th {
  color: #667085;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

tbody tr:hover td {
  background: #fafcff;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.invoice-number {
  display: inline-block;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.action-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--primary-dark);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
  border: 1px solid var(--border);
}

.invoices {
  width: 100%;
  table-layout: fixed;
}

.invoices th,
.invoices td,
.invoices time,
.invoices .invoice-number,
.invoices .status-pill,
.invoices .action-link {
  white-space: nowrap;
}

.invoices .col-number {
  width: 112px;
}

.invoices .col-date {
  width: 112px;
}

.invoices .col-tax {
  width: 96px;
}

.invoices .col-total {
  width: 108px;
}

.invoices .col-status {
  width: 118px;
}

.invoices .col-type {
  width: 98px;
}

.invoices .col-actions {
  width: 148px;
}

.invoices .cell-client {
  overflow: hidden;
}

.client-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.invoices .actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
}

.lines {
  min-width: 1040px;
}

.lines .num,
.lines th.num {
  white-space: nowrap;
}

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

.pager {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
}

.pager .meta {
  text-align: center;
}

.pager-link:last-child {
  justify-self: end;
}

.pager-spacer {
  min-height: 1px;
}

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

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

.party-card {
  padding: 22px;
}

.party-card h3 {
  margin-top: 6px;
}

.detail-list,
.note-grid {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.detail-row {
  display: grid;
  gap: 4px;
}

.detail-row span,
.dir3-grid span {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.detail-row strong,
.dir3-grid strong {
  font-size: 0.98rem;
  font-weight: 600;
}

.detail-row--wide strong {
  line-height: 1.45;
}

.dir3-card {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(226, 232, 240, 0.9);
}

.dir3-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.invoice-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  align-items: start;
}

.line-description {
  display: grid;
  gap: 8px;
}

.line-description__text {
  white-space: pre-line;
  overflow-wrap: anywhere;
  line-height: 1.55;
  font-weight: 600;
}

.lines {
  width: 100%;
  table-layout: fixed;
}

.lines .col-line-description {
  width: auto;
}

.lines .col-line-qty {
  width: 84px;
}

.lines .col-line-unit,
.lines .col-line-base,
.lines .col-line-tax-amount {
  width: 126px;
}

.lines .col-line-tax-rate {
  width: 90px;
}

.period-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
}

.totals-card {
  padding: 24px;
  position: static;
  width: min(460px, 100%);
  margin-left: auto;
}

.totals-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid rgba(226, 232, 240, 0.86);
}

.totals-row span {
  color: var(--muted);
}

.totals-row strong {
  font-size: 1.05rem;
}

.totals-row--grand {
  margin-top: 4px;
}

.totals-row--grand span,
.totals-row--grand strong {
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
}

.totals-divider {
  height: 1px;
  margin: 18px 0;
  background: rgba(226, 232, 240, 0.9);
}

.warn {
  color: #b91c1c;
  font-weight: 700;
}

.login-shell {
  min-height: calc(100vh - 180px);
  display: grid;
  place-items: center;
  padding: 24px 16px 40px;
}

.login-box,
.error-box {
  padding: 34px;
}

.login-box {
  width: min(480px, 100%);
  text-align: left;
}

.login-box h2 {
  margin: 6px 0 10px;
  font-size: 1.8rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.login-box .eyebrow,
.error-box .eyebrow {
  justify-self: start;
}

.login-note {
  max-width: 44ch;
  margin-bottom: 20px;
}

.login-actions {
  display: flex;
  justify-content: flex-start;
}

.login-alert {
  margin: 0 0 18px;
  padding: 10px 12px;
  border: 1px solid #f3c7c7;
  border-radius: var(--radius-sm);
  background: #fff5f5;
  color: #b91c1c;
  font-weight: 600;
}

.error-box {
  border: 1px solid rgba(185, 28, 28, 0.18);
  background: #ffffff;
}

.error-box pre {
  margin: 20px 0 0;
  padding: 16px;
  overflow: auto;
  border-radius: var(--radius-md);
  background: rgba(15, 23, 42, 0.05);
  border: 1px solid rgba(15, 23, 42, 0.08);
  font-size: 0.82rem;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 16px;
  color: var(--text);
  font-size: 0.92rem;
}

.user-box img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
}

.user-box__action {
  padding: 10px 14px;
}

@media (max-width: 980px) {
  .page-hero,
  .invoice-layout,
  .parties,
  .summary-grid,
  .hero-grid {
    grid-template-columns: 1fr;
  }

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

  .field--search,
  .search-form__actions {
    grid-column: 1 / -1;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .totals-card {
    position: static;
  }
}

@media (max-width: 720px) {
  .site-header {
    padding: 18px 16px 0;
  }

  .site-header__inner,
  .user-box,
  .party-card__header,
  .pager {
    align-items: flex-start;
  }

  .site-header__inner,
  .pager,
  .search-form {
    grid-template-columns: 1fr;
  }

  .site-main {
    padding: 20px 16px 32px;
  }

  .site-header__inner,
  .page-hero,
  .panel,
  .table-card,
  .party-card,
  .summary-card,
  .totals-card,
  .login-box,
  .note-card,
  .error-box {
    border-radius: 14px;
  }

  .site-header__inner,
  .user-box {
    flex-direction: column;
    width: 100%;
  }

  .brand {
    width: 100%;
  }

  .user-box {
    padding-left: 0;
  }

  .search-form {
    gap: 12px;
  }

  .toggle-field,
  .search-form__actions {
    justify-content: flex-start;
  }

  .search-form__actions,
  .hero-actions,
  .actions {
    width: 100%;
  }

  .search-form button,
  .btn,
  .btn-secondary,
  .btn-google,
  .action-link,
  .pager-link {
    width: 100%;
  }

  .login-box {
    width: 100%;
  }

  .login-actions {
    width: 100%;
  }

  .pager {
    gap: 10px;
  }

  .pager .meta,
  .pager-link:last-child {
    justify-self: stretch;
    text-align: left;
  }
}
