:root {
  color-scheme: light;
  --primary: #92000a;
  --primary-dark: #6f0008;
  --secondary: #4A5568;
  --neutral-light: #F7FAFC;
  --accent: #E2E8F0;
  --bg: var(--neutral-light);
  --surface: #ffffff;
  --ink: #18212f;
  --muted: var(--secondary);
  --line: var(--accent);
  --green: #247a4d;
  --amber: #9a6400;
  --red: var(--primary);
  --soft-red: #fff0ed;
  --soft-green: #edf8f2;
  --soft-amber: #fff6df;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

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

button {
  border: 0;
  cursor: pointer;
  min-height: 38px;
}

.app-header {
  align-items: center;
  background: var(--primary);
  color: #fff;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(18px, 4vw, 44px);
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.05;
  margin-bottom: 0;
}

.cloud-status {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  margin: 10px 0 0;
}

.cloud-status.offline {
  color: #fff0ed;
}

h2 {
  font-size: 22px;
  margin-bottom: 6px;
}

.header-actions,
.panel-title,
.tabs,
.entry-form {
  display: flex;
  gap: 10px;
}

.app-shell {
  padding: 24px clamp(14px, 3vw, 44px) 42px;
}

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

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-bottom: 10px;
}

.metric strong {
  display: block;
  font-size: 32px;
}

.metric.alert strong {
  color: var(--red);
}

.workspace {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.tabs {
  background: var(--neutral-light);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  padding: 8px;
}

.tab {
  background: transparent;
  border-radius: 6px;
  color: var(--secondary);
  font-weight: 700;
  padding: 8px 14px;
  white-space: nowrap;
}

.tab.active {
  background: var(--surface);
  color: var(--primary);
}

.panel {
  display: none;
  padding: 20px;
}

.panel.active {
  display: block;
}

.panel-title {
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-title p,
.import-box p {
  color: var(--muted);
  margin-bottom: 0;
}

.primary-btn,
.ghost-btn,
.danger-btn,
.icon-btn {
  border-radius: 6px;
  font-weight: 700;
  padding: 8px 13px;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
}

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

.ghost-btn {
  background: var(--accent);
  color: var(--primary);
}

.danger-btn {
  background: var(--secondary);
  color: #ffffff;
}

.icon-btn {
  background: transparent;
  color: var(--red);
  min-width: 34px;
  padding: 6px 8px;
}

.entry-form {
  align-items: end;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 16px;
}

.entry-form label {
  color: var(--muted);
  display: grid;
  flex: 1 1 230px;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
}

.customer-form label {
  flex-basis: 180px;
}

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

textarea {
  margin: 10px 0;
  min-height: 112px;
  resize: vertical;
}

.import-box {
  background: var(--neutral-light);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 14px;
  padding: 12px;
}

.import-box summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.file-import {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}

.file-import input {
  flex: 1 1 320px;
}

.import-status {
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  margin-top: 8px;
}

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

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

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

th {
  background: var(--neutral-light);
  color: var(--secondary);
  font-size: 12px;
  position: sticky;
  text-transform: uppercase;
  top: 0;
}

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

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

.status {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 9px;
  white-space: nowrap;
}

.status.ok {
  background: var(--soft-green);
  color: var(--green);
}

.status.review {
  background: var(--soft-amber);
  color: var(--amber);
}

.status.over {
  background: var(--soft-red);
  color: var(--red);
}

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

@media (max-width: 760px) {
  .app-header,
  .panel-title {
    align-items: stretch;
    flex-direction: column;
  }

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

@media (max-width: 520px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }
}
