:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text-1: #0f172a;
  --text-2: #334155;
  --text-3: #64748b;
  --primary: #0f172a;
  --action: #2563eb;
  --action-hover: #1d4ed8;
  --success: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.08), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  font-size: 15px;
  line-height: 1.5;
  -webkit-tap-highlight-color: rgba(15, 23, 42, 0.06);
}

.app-header {
  background: var(--primary);
  color: white;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.app-header .brand-icon {
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 12px;
}
.app-header .brand-name { font-weight: 600; font-size: 14px; }
.app-header .brand-sub { font-size: 12px; opacity: 0.7; }
.app-header .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.app-header .user-name { opacity: 0.85; }
.app-header .header-link {
  color: white;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
}
.app-header .header-link:hover { background: rgba(255, 255, 255, 0.15); }

/* "+ New Order" gets the green-CTA treatment so it stands apart from the
   plain nav links — solid fill, white text, bigger weight. Reads as a
   primary action button instead of one item in a row of links. */
.app-header .header-link.header-cta {
  background: var(--success);
  color: white;
  border-color: var(--success);
  font-weight: 800;
  padding: 7px 14px;
}
.app-header .header-link.header-cta:hover {
  background: #047857;
  border-color: #047857;
}

/* Mobile hamburger menu button. Hidden on desktop; on phone it's the
   only nav affordance unless tapped, then a vertical menu drops down. */
.app-header .header-menu-btn {
  display: none;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: white;
  width: 44px; height: 44px;
  border-radius: 8px;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.app-header .header-menu-btn:active { transform: scale(0.95); }

.app-main {
  padding: 20px;
  max-width: 1100px;
  margin: 0 auto;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.card-body { padding: 20px; }
.card-title { font-size: 16px; font-weight: 600; margin: 0; }
.card-subtitle { font-size: 13px; color: var(--text-3); margin: 2px 0 0; }

button, .btn {
  font: inherit;
  padding: 10px 18px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background: white;
  color: var(--text-1);
  cursor: pointer;
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
  -webkit-appearance: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
button:hover, .btn:hover { background: var(--surface-2); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled, .btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary, .btn-action {
  background: var(--action);
  color: white;
  border-color: var(--action);
  font-weight: 600;
}
.btn-primary:hover, .btn-action:hover { background: var(--action-hover); border-color: var(--action-hover); }
.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-link {
  background: transparent;
  border: 0;
  padding: 4px 8px;
  color: var(--action);
  font-weight: 500;
}
.btn-link:hover { background: var(--surface-2); }
.btn-link.danger { color: var(--danger); }

.field { margin-bottom: 14px; }
.field > label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font: inherit;
  background: white;
  color: var(--text-1);
  -webkit-appearance: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--action);
  outline-offset: -1px;
  border-color: var(--action);
}
.field textarea { resize: vertical; min-height: 60px; }

.row { display: flex; gap: 14px; }
.row .field { flex: 1; min-width: 0; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-progress { background: #eff6ff; color: #1e40af; }
.badge-completed { background: #ecfdf5; color: #047857; }
.badge-admin { background: #fef3c7; color: #92400e; }
.badge-worker { background: #f1f5f9; color: #475569; }

.muted { color: var(--text-3); }
.error-msg { color: var(--danger); font-size: 13px; margin-top: 8px; }
.success-msg { color: var(--success); font-size: 13px; margin-top: 8px; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.data-table th, table.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.data-table th {
  font-weight: 600;
  color: var(--text-2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--surface-2);
}
table.data-table tbody tr:hover { background: var(--surface-2); cursor: pointer; }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .app-header { padding: 10px 14px; position: relative; }
  .app-header .brand-name { font-size: 14px; }
  .app-header .brand-sub { display: none; }
  .app-header .user-name { display: none; }
  /* Hamburger replaces the inline nav row on phone */
  .app-header .header-menu-btn { display: block; }
  .app-header .user-info {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 8px;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    background: var(--primary);
    padding: 12px;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
    z-index: 60;
    min-width: 200px;
    max-width: calc(100vw - 32px);
  }
  .app-header.menu-open .user-info { display: flex; }
  .app-header .user-info .header-link {
    text-align: left;
    padding: 12px 14px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    width: 100%;
  }
  .app-main { padding: 12px; }
  .card-header { padding: 12px 14px; }
  .card-body { padding: 14px; }
  .row { flex-direction: column; gap: 0; }
  button, .btn { min-height: 44px; font-size: 16px; }
  .field input, .field select, .field textarea { font-size: 16px; padding: 12px 14px; }
  table.data-table { font-size: 13px; }
  table.data-table th, table.data-table td { padding: 8px 6px; }
}

/* Hide the app header (and any other chrome) when printing — labels.html in
   particular was bleeding "Records Labels Users Sign out" onto the first
   thermal label because the renderHeader-injected element wasn't tagged
   .no-print. Apply globally so every page is print-clean. */
@media print {
  .app-header,
  .app-header * { display: none !important; }
}
