:root {
  color-scheme: light;
  --ink: #1e222a;
  --muted: #626b7a;
  --line: #dde2ea;
  --panel: #ffffff;
  --page: #f5f6f8;
  --brand: #b51624;
  --brand-dark: #8d101b;
  --charcoal: #1f2024;
  --ok: #167449;
  --warn: #a35e00;
  --danger: #b63434;
  --shadow: 0 16px 40px rgba(28, 31, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #fafafa 0, var(--page) 360px);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

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

button,
select,
label.file-btn {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--charcoal);
  color: #fff;
  padding: 22px 18px;
  border-right: 1px solid #2f3238;
}

.brand {
  display: grid;
  gap: 12px;
  margin-bottom: 28px;
  border: 1px solid #353940;
  border-radius: 8px;
  background: #ffffff;
  padding: 13px;
  color: var(--ink);
}

.brand-logo {
  width: 100%;
  max-height: 70px;
  object-fit: contain;
}

.brand h1,
.topbar h2,
.panel h3 {
  margin: 0;
}

.brand h1 {
  font-size: 17px;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab {
  min-height: 46px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #d4d9e4;
  text-align: left;
  padding: 0 14px;
  font-weight: 700;
}

.nav-tab:hover,
.nav-tab.active {
  background: #34363d;
  color: #fff;
  box-shadow: inset 4px 0 0 var(--brand);
}

.workspace {
  min-width: 0;
  padding: 28px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

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

.primary-btn,
.ghost-btn,
.file-btn {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
}

.primary-btn {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 10px 24px rgba(181, 22, 36, 0.18);
}

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

.ghost-btn {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
}

.file-btn {
  display: inline-grid;
  place-items: center;
  background: #eef3f6;
  color: var(--brand-dark);
  border-color: #c9d9df;
}

.file-btn input {
  display: none;
}

.logo-preview {
  display: flex;
  align-items: center;
  min-height: 64px;
  color: var(--muted);
  font-size: 13px;
}

.logo-preview img {
  max-width: 160px;
  max-height: 72px;
  object-fit: contain;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 20px;
  box-shadow: var(--shadow);
}

.hero-logo {
  display: block;
  width: min(420px, 100%);
  max-height: 98px;
  object-fit: contain;
  object-position: left center;
  margin-bottom: 10px;
}

.dashboard-hero p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  min-height: 116px;
  padding: 18px;
  display: grid;
  align-content: space-between;
  border-top: 4px solid var(--brand);
}

.metric span,
.subtle {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 34px;
  color: var(--ink);
}

.split {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 18px;
}

.settings-grid {
  margin-top: 18px;
}

.split.wide {
  grid-template-columns: minmax(310px, 0.8fr) minmax(360px, 1.2fr);
}

.panel {
  min-width: 0;
  padding: 18px;
}

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

.form-grid {
  display: grid;
  gap: 10px;
}

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

.compact-form textarea,
.form-grid .form-actions,
.compact-form .form-actions {
  grid-column: 1 / -1;
}

.inline-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.inline-result {
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.inline-create {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.inline-create[hidden] {
  display: none;
}

.parts-builder {
  display: grid;
  gap: 10px;
}

.selected-parts-list {
  display: grid;
  gap: 8px;
}

.part-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 70px 90px 90px auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 8px;
}

.part-line input {
  padding: 8px;
}

.money-input {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.money-input span {
  padding-left: 9px;
  color: var(--muted);
  font-weight: 800;
}

.money-input input {
  border: 0;
  border-radius: 0;
  min-width: 0;
}

.part-line button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.photo-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.photo-thumb {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 8px;
}

.photo-thumb img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 6px;
}

.photo-thumb button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: #c04450;
  box-shadow: 0 0 0 3px rgba(181, 22, 36, 0.12);
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.checkbox-row input {
  width: 18px;
  height: 18px;
}

.stack,
.table-list {
  display: grid;
  gap: 10px;
}

.empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.record {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

.record:hover {
  border-color: #c8ced8;
  box-shadow: 0 10px 24px rgba(28, 31, 38, 0.07);
}

.record-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.record-title {
  font-weight: 800;
}

.record-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  background: #e9eef5;
  color: #384356;
}

.pill.complete,
.pill.paid {
  background: #dff3ea;
  color: var(--ok);
}

.pill.waiting {
  background: #fff2d9;
  color: var(--warn);
}

.pill.unpaid {
  background: #fde8e8;
  color: var(--danger);
}

.record-actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.record-actions button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fb;
  color: var(--ink);
}

.record-top > button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fb;
  white-space: nowrap;
}

.settings-list {
  margin-top: 14px;
}

.copy {
  color: var(--muted);
  line-height: 1.5;
}

.storage-health {
  display: grid;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  min-width: 220px;
  max-width: min(420px, calc(100vw - 36px));
  border-radius: 8px;
  background: #111827;
  color: #fff;
  padding: 13px 15px;
  box-shadow: var(--shadow);
  transform: translateY(120px);
  opacity: 0;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.invoice-document {
  display: none;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 14px;
  }

  .brand {
    grid-template-columns: 160px 1fr;
    align-items: center;
    margin-bottom: 12px;
  }

  .nav-tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    overflow-x: auto;
  }

  .nav-tab {
    text-align: center;
    white-space: nowrap;
  }

  .metric-grid,
  .dashboard-hero,
  .split,
  .split.wide,
  .compact-form,
  .inline-field,
  .part-line {
    grid-template-columns: 1fr;
  }

  .hero-actions {
    justify-content: stretch;
  }

  .hero-actions button {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .workspace {
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .brand-logo {
    max-height: 54px;
    object-position: left center;
  }

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

  .metric strong {
    font-size: 28px;
  }
}
