:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #697586;
  --line: #d9dee7;
  --accent: #1d4ed8;
  --accent-dark: #1e40af;
  --soft: #eff6ff;
  --danger: #dc2626;
}

* { box-sizing: border-box; }

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

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

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  min-height: 34px;
  padding: 0 12px;
}

button:hover { border-color: var(--accent); color: var(--accent-dark); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); }
.btn-icon { min-height: 24px; min-width: 24px; padding: 0; font-size: 18px; border-radius: 50%; flex-shrink: 0; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  flex-wrap: wrap;
}

.eyebrow { margin: 0 0 2px; color: var(--accent-dark); font-size: 12px; font-weight: 700; text-transform: uppercase; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; font-weight: 700; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions button:nth-child(2) { background: var(--accent); border-color: var(--accent); color: #fff; }

.workspace { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.status-bar { color: var(--muted); font-size: 13px; }

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

.order-list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
}

.order-row {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.1s;
}

.order-row:hover { background: var(--soft); }
.order-row.active { background: var(--soft); border-left: 3px solid var(--accent); }
.order-row:last-child { border-bottom: 0; }

.order-row-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 3px; }
.order-row-customer { font-size: 13px; }
.order-row-sub { font-size: 12px; color: var(--muted); }

.status-badge { font-size: 11px; font-weight: 700; text-transform: uppercase; }

.order-editor {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 160px);
  overflow-y: auto;
}

.editor-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.editor-header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
#editorStatus { font-size: 12px; color: var(--muted); }

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

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  min-height: 36px;
  padding: 6px 10px;
  text-transform: none;
  font-size: 14px;
}

textarea { resize: vertical; }

.field-group { display: flex; flex-direction: column; gap: 6px; }
.field-header { display: flex; align-items: center; justify-content: flex-start; gap: 8px; }
.field-label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; }

.customer-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 10px 12px;
  min-height: 52px;
  color: var(--muted);
}

.customer-card strong { display: block; color: var(--ink); }

.add-customer-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#newCustomerStatus { font-size: 12px; color: var(--muted); }

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.part-line {
  display: grid;
  grid-template-columns: 1fr 64px 92px 36px;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.pl-remove { padding: 0; min-width: 36px; font-size: 16px; }

#emptyOrders { text-align: center; color: var(--muted); padding: 32px 16px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .order-list { max-height: 300px; }
  .order-editor { max-height: none; }
  .grid.two { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; }
}
