:root {
  --bg: #f6f0e6;
  --paper: rgba(255, 249, 239, 0.9);
  --paper-strong: #fffaf2;
  --ink: #1c1711;
  --muted: #6f665a;
  --line: rgba(97, 82, 63, 0.16);
  --line-strong: rgba(97, 82, 63, 0.26);
  --brand: #a33d20;
  --brand-deep: #7e2f18;
  --accent: #0f6d63;
  --accent-soft: rgba(15, 109, 99, 0.12);
  --danger: #9b2323;
  --danger-soft: rgba(155, 35, 35, 0.12);
  --warn: #8a640f;
  --warn-soft: rgba(138, 100, 15, 0.14);
  --ok-soft: rgba(15, 109, 99, 0.18);
  --shadow: 0 24px 60px rgba(63, 37, 15, 0.12);
  --radius: 24px;
  --radius-sm: 18px;
  --mono: "IBM Plex Mono", "Consolas", monospace;
  --sans: "IBM Plex Sans Arabic", "Aptos", "Segoe UI", Tahoma, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(163, 61, 32, 0.16), transparent 26%),
    radial-gradient(circle at left 20%, rgba(15, 109, 99, 0.12), transparent 22%),
    linear-gradient(180deg, #fbf5ec 0%, var(--bg) 100%);
}

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

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
}

button {
  cursor: pointer;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus {
  border-color: rgba(163, 61, 32, 0.45);
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(163, 61, 32, 0.08);
}

input[readonly],
input:disabled,
button:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1520px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.landing-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: 32px 0 56px;
}

.landing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 28px;
  align-items: center;
}

.landing-copy,
.landing-notes,
.visual-canvas,
.visual-stats {
  display: grid;
  gap: 18px;
}

.landing-copy h1 {
  max-width: 11ch;
}

.landing-lede {
  max-width: 58ch;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.9;
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.landing-link {
  text-decoration: none;
}

.landing-note-card,
.visual-panel,
.visual-stats article {
  background: rgba(255, 250, 242, 0.84);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px 20px;
}

.landing-note-card strong,
.visual-panel strong,
.visual-stats strong {
  display: block;
}

.landing-note-card span,
.visual-panel p,
.visual-stats span {
  color: var(--muted);
}

.landing-visual {
  padding: 18px;
  min-height: 560px;
}

.visual-canvas {
  position: relative;
  min-height: 520px;
  padding: 26px;
  border-radius: 28px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(163, 61, 32, 0.18), transparent 24%),
    radial-gradient(circle at 80% 15%, rgba(15, 109, 99, 0.15), transparent 22%),
    linear-gradient(160deg, rgba(255, 252, 246, 0.98), rgba(246, 240, 230, 0.86));
}

.visual-orbit {
  position: absolute;
  border-radius: 999px;
  border: 1px dashed rgba(163, 61, 32, 0.2);
}

.orbit-a {
  inset: 52px 80px auto auto;
  width: 280px;
  height: 280px;
}

.orbit-b {
  inset: auto auto 38px 24px;
  width: 220px;
  height: 220px;
  border-color: rgba(15, 109, 99, 0.22);
}

.visual-panel {
  position: relative;
  z-index: 1;
  width: min(360px, 100%);
}

.visual-kicker {
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.74rem;
  font-weight: 700;
}

.visual-panel strong {
  font-size: 1.6rem;
}

.visual-stats {
  position: absolute;
  inset: auto 24px 24px 24px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  z-index: 1;
}

.login-stage {
  min-height: calc(100vh - 72px);
  display: grid;
  place-items: center;
}

.login-panel,
.card,
.metric-card,
.dialog-shell,
.results-table,
.search-filters {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.login-panel {
  width: min(580px, 100%);
  padding: 32px;
  display: grid;
  gap: 22px;
}

.boot-panel {
  justify-items: center;
  text-align: center;
}

.boot-mark {
  width: 72px;
  height: 72px;
  border-radius: 999px;
  border: 3px solid rgba(163, 61, 32, 0.16);
  border-top-color: var(--brand);
  animation: boot-spin 1s linear infinite;
}

.brand-block,
.section-head,
.dialog-head {
  display: grid;
  gap: 8px;
}

.eyebrow {
  margin: 0;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.74rem;
  font-weight: 700;
}

@keyframes boot-spin {
  to {
    transform: rotate(360deg);
  }
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.6rem);
  max-width: 12ch;
}

h2 {
  font-size: 1.4rem;
}

h3 {
  font-size: 1.04rem;
}

.lede,
.muted-note,
.section-head p,
.dialog-head p,
.compact,
label span,
.timeline-item span,
.mini-row span,
.mini-row small,
.result-row span,
.result-row small,
.list-row span,
.list-row small {
  color: var(--muted);
}

.login-form,
.editor-grid,
.dialog-grid,
.dialog-form,
.search-filters {
  display: grid;
  gap: 14px;
}

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

.workspace {
  display: grid;
  gap: 22px;
}

.topbar,
.toolbar,
.lookup-row,
.pill-stack,
.topbar-actions,
.mini-actions,
.results-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar {
  justify-content: space-between;
  padding: 24px;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.toolbar {
  flex-wrap: wrap;
}

.inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
  white-space: nowrap;
}

.inline-toggle span {
  color: inherit;
}

.card {
  padding: 22px;
}

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

.metric-card {
  padding: 20px;
  display: grid;
  gap: 10px;
}

.metric-card span {
  color: var(--muted);
  font-size: 0.9rem;
}

.metric-card strong {
  font-size: clamp(1.6rem, 2vw, 2.2rem);
}

.metric-card.accent {
  background: linear-gradient(135deg, rgba(15, 109, 99, 0.95), rgba(11, 88, 78, 0.95));
  color: #f8fffc;
}

.metric-card.accent span {
  color: rgba(248, 255, 252, 0.8);
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 0.92fr);
  gap: 22px;
}

.sidebar {
  display: grid;
  gap: 18px;
}

.side-card {
  min-height: 180px;
}

.invoice-toolbar {
  margin-block: 18px 16px;
}

.compact-head {
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 7px;
}

label span {
  font-size: 0.88rem;
  font-weight: 700;
}

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

.wide {
  width: 100%;
}

button {
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  font-weight: 700;
  transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  color: #fff7f2;
  box-shadow: 0 12px 28px rgba(163, 61, 32, 0.24);
}

.secondary {
  background: #e9ddcb;
  color: var(--ink);
}

.danger {
  background: #f4d9d9;
  color: var(--danger);
}

.ghost {
  background: transparent;
  color: var(--brand);
  border: 1px solid rgba(163, 61, 32, 0.16);
}

.mini {
  padding: 9px 12px;
  font-size: 0.86rem;
}

.pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  border: 1px solid transparent;
}

.pill {
  background: rgba(255, 255, 255, 0.8);
  border-color: var(--line);
}

.pill.ok,
.status-badge.cleared,
.status-badge.reported {
  background: var(--ok-soft);
  color: var(--accent);
}

.pill.warn,
.status-badge.issuing {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill.muted,
.status-badge.draft {
  background: rgba(111, 102, 90, 0.12);
  color: var(--muted);
}

.status-badge.failed {
  background: var(--danger-soft);
  color: var(--danger);
}

.details-box {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.45);
}

.details-box summary {
  cursor: pointer;
  font-weight: 700;
}

.nested-grid {
  margin-top: 14px;
}

.line-items {
  display: grid;
  gap: 12px;
}

.line-item {
  display: grid;
  grid-template-columns: 2.2fr 0.9fr 0.95fr 0.75fr 0.8fr auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  border-radius: 20px;
  border: 1px solid rgba(97, 82, 63, 0.12);
  background: rgba(255, 255, 255, 0.54);
}

.line-total {
  min-height: 47px;
  border-radius: 16px;
  padding: 10px 12px;
  background: rgba(15, 109, 99, 0.08);
  border: 1px solid rgba(15, 109, 99, 0.16);
  display: grid;
  gap: 4px;
}

.line-total span {
  color: var(--muted);
  font-size: 0.8rem;
}

.line-total strong {
  font-family: var(--mono);
}

.line-remove {
  min-height: 47px;
}

.totals-card {
  margin-top: 18px;
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(255, 249, 239, 0.95), rgba(245, 236, 220, 0.9));
  border: 1px solid var(--line);
}

.totals-card > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.totals-card strong {
  font-family: var(--mono);
}

.grand-total {
  border-top: 1px dashed var(--line-strong);
  padding-top: 10px;
}

.grand-total strong {
  color: var(--brand);
  font-size: 1.18rem;
}

.message-box {
  min-height: 54px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  display: flex;
  align-items: center;
  white-space: pre-wrap;
}

.message-box.light {
  background: rgba(255, 255, 255, 0.5);
}

.message-box.info {
  background: rgba(111, 102, 90, 0.08);
}

.message-box.success {
  background: var(--accent-soft);
  border-color: rgba(15, 109, 99, 0.18);
  color: var(--accent);
}

.message-box.error {
  background: var(--danger-soft);
  border-color: rgba(155, 35, 35, 0.18);
  color: var(--danger);
}

.timeline,
.mini-table,
.list-panel,
.results-table {
  display: grid;
  gap: 12px;
}

.timeline-item,
.mini-row,
.list-row,
.result-row {
  width: 100%;
  text-align: right;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(97, 82, 63, 0.12);
  background: rgba(255, 255, 255, 0.58);
}

.timeline-item {
  display: grid;
  gap: 5px;
}

.timeline-item p {
  margin: 0;
  white-space: pre-wrap;
  color: var(--ink);
}

.mini-row,
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.mini-row.locked {
  border-inline-start: 5px solid var(--accent);
}

.mini-row.draft {
  border-inline-start: 5px solid var(--brand);
}

.list-row {
  display: grid;
  gap: 4px;
  background: rgba(255, 255, 255, 0.72);
}

.list-row:hover {
  border-color: rgba(163, 61, 32, 0.24);
}

.empty-state {
  padding: 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  border: 1px dashed var(--line-strong);
}

.app-dialog {
  width: min(1120px, calc(100% - 32px));
  max-width: none;
  border: none;
  padding: 0;
  background: transparent;
}

.app-dialog::backdrop {
  background: rgba(32, 19, 9, 0.38);
  backdrop-filter: blur(5px);
}

.dialog-shell {
  padding: 22px;
  display: grid;
  gap: 18px;
}

.wide-shell {
  width: min(1240px, 100%);
}

.dialog-head {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.dialog-grid {
  grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1.1fr);
}

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

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

.search-filters {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 16px;
}

.search-filters .span-2 {
  grid-column: span 2;
}

.results-table {
  padding: 16px;
}

.results-header {
  justify-content: space-between;
}

@media (max-width: 1200px) {
  .landing-hero {
    grid-template-columns: 1fr;
  }

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

  .workspace-grid {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 860px) {
  .landing-shell,
  .app-shell {
    width: min(100%, calc(100% - 20px));
    margin: 10px auto 28px;
  }

  .landing-actions,
  .login-form,
  .editor-grid,
  .dialog-grid,
  .dialog-form,
  .search-filters,
  .dashboard-grid,
  .sidebar {
    grid-template-columns: 1fr;
  }

  .span-2,
  .search-filters .span-2 {
    grid-column: auto;
  }

  .topbar,
  .mini-row,
  .result-row {
    flex-direction: column;
    align-items: stretch;
  }

  .line-item {
    grid-template-columns: 1fr;
  }

  .line-total,
  .line-remove {
    min-height: auto;
  }

  .visual-stats {
    position: static;
    grid-template-columns: 1fr;
  }
}
