:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #1c1917;
  --muted: #78716c;
  --line: #e7e5e4;
  --brand: #166534;
  --brand-dark: #14532d;
  --brand-soft: #dcfce7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --amber: #fde68a;
  --radius: 16px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 28px; line-height: 1.2; letter-spacing: -0.02em; margin: 4px 0 0; }
h2 { font-size: 16px; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.strong { font-weight: 600; }
.warn { color: var(--danger); font-weight: 600; }

/* Shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 24px; padding: 24px 16px; background: #10241a; color: #d1fae5; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 18px; padding: 0 8px; }
.brand:hover { text-decoration: none; }
.brand img { width: 32px; height: 32px; }
.brand em { font-style: normal; font-weight: 500; color: #86efac; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: #bbf7d0; font-weight: 500; }
.sidebar nav a svg { width: 18px; height: 18px; }
.sidebar nav a:hover { background: rgb(255 255 255 / 0.06); text-decoration: none; }
.sidebar nav a.active { background: #1f3d2c; color: #fff; }
.logout { margin-top: auto; }
.logout button { width: 100%; background: transparent; border: 1px solid rgb(255 255 255 / 0.15); color: #bbf7d0; border-radius: 10px; padding: 9px; font: inherit; cursor: pointer; }
.logout button:hover { background: rgb(255 255 255 / 0.06); }
.content { padding: 32px clamp(16px, 4vw, 48px) 96px; max-width: 1200px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }

/* Cards & tiles */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: 0 1px 2px rgb(0 0 0 / 0.03); }
.card + .card { margin-top: 16px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.empty { color: var(--muted); text-align: center; padding: 32px 16px; }
.tiles .card + .card { margin-top: 0; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 16px; }
.tile-label { margin: 0; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.tile-value { margin: 6px 0 2px; font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }

/* Table */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; padding: 12px 16px; border-bottom: 1px solid var(--line); background: #fafaf9; }
.card:not(.flush) .table th { background: none; padding-left: 0; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.card:not(.flush) .table td { padding-left: 0; }
.table tr:last-child td { border-bottom: 0; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }
.actions form { margin: 0; }
.emoji { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; font-size: 22px; }
.swatch-rose { background: #ffe4e6; } .swatch-amber { background: #fef3c7; } .swatch-yellow { background: #fef9c3; }
.swatch-orange { background: #ffedd5; } .swatch-lime { background: #ecfccb; } .swatch-emerald { background: #d1fae5; }
.swatch-sky { background: #e0f2fe; } .swatch-violet { background: #ede9fe; } .swatch-red { background: #fee2e2; } .swatch-stone { background: #e7e5e4; }

/* Pills */
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; text-transform: capitalize; }
.pill-new { background: var(--amber); color: #78350f; }
.pill-paid { background: var(--brand-soft); color: var(--brand-dark); }
.pill-shipped { background: #dbeafe; color: #1e3a8a; }
.pill-cancelled { background: #f5f5f4; color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: 600 14px var(--font); cursor: pointer; }
.btn:hover { background: #fafaf9; text-decoration: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: #fecaca; }
.btn-small { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid #86efac; outline-offset: 2px; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.wide, .form-grid .wide { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 600; color: #44403c; }
input, select, textarea { font: inherit; padding: 10px 12px; border: 1px solid #d6d3d1; border-radius: 10px; background: #fff; color: var(--ink); width: 100%; }
textarea { resize: vertical; }
.field.check label { display: flex; align-items: center; gap: 8px; font-weight: 500; margin-top: 26px; }
.field.check input { width: 18px; height: 18px; accent-color: var(--brand); }
.has-error input, .has-error textarea { border-color: #fca5a5; background: #fff7f7; }
.error { margin: 0; color: var(--danger); font-size: 13px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; padding-top: 8px; border-top: 1px solid var(--line); }

/* Flash */
.flash { padding: 12px 16px; border-radius: 12px; margin-bottom: 20px; font-weight: 500; }
.flash-success { background: var(--brand-soft); color: var(--brand-dark); }
.flash-error { background: var(--danger-soft); color: var(--danger); }

/* Orders */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.filters a { padding: 6px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: #44403c; font-size: 13px; font-weight: 600; text-transform: capitalize; }
.filters a.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.filters a:hover { text-decoration: none; }
.order-list { display: grid; gap: 16px; }
.order-list .card + .card { margin-top: 0; }
.order-head { display: flex; justify-content: space-between; align-items: flex-start; }
.order-head p { margin: 0; }
.order-body { display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; margin: 16px 0; }
.items { list-style: none; margin: 0; padding: 0; }
.items li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.items li.total { border: 0; font-weight: 700; }
.customer p { margin: 0 0 4px; font-size: 14px; }
.note { font-style: italic; color: #57534e; }
.order-actions { display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.order-actions select { width: auto; padding: 6px 10px; }

/* Login */
.bare { min-height: 100vh; display: grid; place-items: center; background: radial-gradient(ellipse at top, #dcfce7, var(--bg) 60%); }
.login { width: 100%; padding: 24px 16px; }
.login-card { max-width: 380px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; padding: 32px; }
.brand.big { color: var(--ink); padding: 0; font-size: 20px; }
.brand.big em { color: var(--brand); }
.login-card .btn { margin-top: 8px; }

/* Deployment badge (Scenario I) */
/* Bottom-right here so it never covers the sidebar's Sign out button. */
.deploy-badge { position: fixed; right: 16px; bottom: 16px; z-index: 50; font: 11px/1.5 var(--mono); color: #d4d4d8; max-width: calc(100vw - 32px); }
.deploy-badge summary { list-style: none; display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 10px; border-radius: 999px; background: rgb(24 24 27 / 0.92); border: 1px solid rgb(255 255 255 / 0.1); cursor: pointer; box-shadow: 0 8px 20px rgb(0 0 0 / 0.2); }
.deploy-badge summary::-webkit-details-marker { display: none; }
.deploy-badge strong { color: #fff; }
.deploy-badge .muted { color: #71717a; }
.deploy-badge .url { color: #a1a1aa; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deploy-badge dl { position: absolute; bottom: calc(100% + 8px); right: 0; width: 300px; max-width: calc(100vw - 32px); margin: 0; padding: 12px; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; background: rgb(24 24 27 / 0.96); border: 1px solid rgb(255 255 255 / 0.1); border-radius: 12px; }
.deploy-badge dt { color: #71717a; }
.deploy-badge dd { margin: 0; word-break: break-all; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot-up { background: #10b981; } .dot-degraded, .dot-down { background: #ef4444; }

/* Mobile */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px 16px; }
  .sidebar nav { flex-direction: row; order: 3; width: 100%; overflow-x: auto; }
  .sidebar nav a { padding: 8px 10px; white-space: nowrap; }
  .logout { margin: 0 0 0 auto; }
  .logout button { padding: 6px 12px; }
  .tiles, .form-grid, .order-body { grid-template-columns: 1fr; }
  .field.check label { margin-top: 0; }
  .table th:nth-child(5), .table td:nth-child(5) { display: none; }
  .deploy-badge .url { display: none; }
}
