:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #1d2624;
  --muted: #68736f;
  --line: #dce3df;
  --accent: #1f6f68;
  --accent-dark: #174f4a;
  --amber: #b46916;
  --danger: #ad343e;
  --blue: #315f9d;
  --shadow: 0 14px 32px rgba(19, 34, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  background: #163532;
  color: #f5fbf8;
  padding: 24px 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 48px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #bed3ce;
  margin-top: 2px;
}

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

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 6px;
  padding: 12px 14px;
  text-align: left;
  color: #dbe8e4;
  background: transparent;
}

.nav-item.is-active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

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

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

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.86rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 1.85rem;
}

h2 {
  margin-bottom: 0;
  font-size: 1.08rem;
}

h3 {
  font-size: 0.95rem;
}

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

.primary-button,
.secondary-button {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 40px;
  padding: 9px 14px;
  font-weight: 700;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

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

.link-button {
  border: 0;
  padding: 0;
  color: var(--accent);
  background: transparent;
  font-weight: 800;
  text-align: left;
}

.full {
  width: 100%;
}

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

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

.metric {
  padding: 16px;
}

.metric span,
label,
.ai-suggestion span,
.status-pill {
  color: var(--muted);
  font-size: 0.86rem;
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 1.35rem;
}

.view {
  display: none;
}

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

.capture-layout,
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
}

.panel {
  padding: 18px;
}

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

.status-pill {
  border-radius: 999px;
  padding: 5px 10px;
  background: #edf4f2;
  color: var(--accent);
  white-space: nowrap;
}

.status-pill.warning {
  background: #fff4df;
  color: var(--amber);
}

.form-panel {
  display: grid;
  gap: 14px;
}

.ocr-tools {
  display: grid;
  gap: 10px;
}

.upload-box {
  display: grid;
  place-items: center;
  min-height: 116px;
  border: 1px dashed #8ca7a0;
  border-radius: 8px;
  background: #f8fbfa;
  color: var(--ink);
  text-align: center;
}

.upload-box input {
  display: none;
}

.upload-box span,
.upload-box small {
  display: block;
}

.camera-tools {
  display: grid;
  gap: 10px;
}

.camera-frame {
  display: none;
  place-items: center;
  min-height: 220px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111917;
  color: #dbe8e4;
}

.camera-frame.is-active {
  display: grid;
}

.camera-frame video {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
}

.camera-frame.has-video span {
  display: none;
}

.secondary-button:disabled,
.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.preview-frame {
  display: grid;
  place-items: center;
  min-height: 180px;
  max-height: 320px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f2f4f1;
  color: var(--muted);
}

.preview-frame img {
  display: none;
  width: 100%;
  height: 100%;
  max-height: 320px;
  object-fit: contain;
}

.preview-frame.has-image span {
  display: none;
}

.preview-frame.has-image img {
  display: block;
}

.upload-status {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fbfcfb;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.upload-status.is-ok {
  border-color: #9fc9be;
  background: #edf8f5;
  color: var(--accent);
}

.upload-status.is-error {
  border-color: #e7a6ab;
  background: #fff3f4;
  color: var(--danger);
}

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

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

.ai-suggestion,
.check-item,
.approval-item,
.master-list li {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.ai-suggestion {
  display: grid;
  gap: 4px;
  padding: 12px;
}

.check-list,
.approval-list,
.master-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.check-item,
.approval-item,
.master-list li {
  padding: 12px;
}

.check-item.is-warning {
  border-color: #e5bb72;
  background: #fff8ec;
}

.check-item.is-error {
  border-color: #e7a6ab;
  background: #fff3f4;
}

.audit-box {
  margin-top: 22px;
}

.audit-box ul {
  display: grid;
  gap: 8px;
  padding-left: 18px;
  color: var(--muted);
}

.table-heading {
  align-items: flex-end;
}

.table-wrap {
  overflow-x: auto;
}

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

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

th {
  color: var(--muted);
  font-size: 0.82rem;
}

td {
  font-size: 0.92rem;
}

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

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

.master-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.pill-draft {
  color: var(--muted);
}

.pill-submitted {
  color: var(--blue);
}

.pill-approved,
.pill-checked {
  color: var(--accent);
}

.pill-review {
  color: var(--amber);
  font-weight: 700;
}

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

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

  .brand {
    margin-bottom: 12px;
  }

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

  .nav-item {
    text-align: center;
    padding: 10px 6px;
  }

  .main {
    padding: 18px;
  }

  .summary-grid,
  .capture-layout,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .topbar,
  .panel-heading,
  .table-heading,
  .top-actions,
  .button-row,
  .filter-row {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-grid,
  .form-grid,
  .inline-form,
  .master-columns {
    grid-template-columns: 1fr;
  }

  .nav {
    overflow-x: auto;
    grid-template-columns: repeat(4, minmax(92px, 1fr));
  }
}
