:root {
  --ink: #0a0c14;
  --ink-2: #131622;
  --muted: #6e7180;
  --muted-light: #a3a6b3;
  --paper: #f5f4ef;
  --paper-2: #ecebe2;
  --card: #ffffff;
  --line: #e1ddd0;
  --blue: #3457ff;
  --violet: #7a3dff;
  --pink: #ff52aa;
  --green: #21c98a;
  --yellow: #f5b800;
  --red: #ff3b30;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow: 0 8px 32px rgba(10, 12, 20, 0.08);
  --shadow-lg: 0 22px 70px rgba(10, 12, 20, 0.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
  background: var(--paper);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: "IBM Plex Mono", monospace; }

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font: inherit; cursor: pointer; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font-weight: 500;
  font-size: 14px;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--paper-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
.btn-primary:hover { background: var(--ink-2); }

.btn-green { background: var(--green); color: white; border-color: var(--green); }
.btn-green:hover { filter: brightness(0.95); }

.btn-danger { background: var(--red); color: white; border-color: var(--red); }
.btn-danger:hover { filter: brightness(0.95); }

.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--paper-2); }

/* Layout */
.admin-shell { min-height: 100vh; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 24px; }
.brand {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.brand-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--blue);
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}
.topbar-nav { display: flex; gap: 4px; }
.topbar-nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
}
.topbar-nav a.active, .topbar-nav a:hover {
  color: var(--ink);
  background: var(--paper-2);
  text-decoration: none;
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px;
}

/* KPI cards */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 20px;
}
.kpi-label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.kpi-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

/* Filter bar */
.filterbar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filterbar input[type=search] {
  flex: 1;
  min-width: 200px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  font: inherit;
  outline: none;
}
.filterbar input[type=search]:focus { border-color: var(--blue); }
.filter-chip {
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
}
.filter-chip.active { background: var(--ink); color: white; border-color: var(--ink); }

/* Orders table */
.orders-table {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; text-align: left; vertical-align: middle; }
th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}
tbody tr { border-bottom: 1px solid var(--line); cursor: pointer; transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--paper); }

td.order-no { font-family: "IBM Plex Mono", monospace; font-weight: 600; }
td.amount { font-weight: 600; text-align: right; }

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.paid { background: #e6f7ee; color: #18a36b; }
.badge.unpaid { background: #fff4d6; color: #b07a00; }
.badge.refunded { background: #fde7e6; color: #c0392b; }

.badge.open { background: #fff4d6; color: #b07a00; }
.badge.shipped { background: #dee8ff; color: #2643d4; }
.badge.delivered { background: #e6f7ee; color: #18a36b; }
.badge.overdue { background: #fde7e6; color: #c0392b; }

.badge-domain {
  background: var(--paper-2);
  color: var(--muted);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty h3 { color: var(--ink); margin-bottom: 8px; font-size: 18px; }

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(140deg, var(--paper) 0%, var(--paper-2) 100%);
}
.login-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-card h1 {
  font-size: 22px;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}
.login-card p {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 24px;
}
.login-card label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}
.login-card input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  outline: none;
  margin-bottom: 16px;
}
.login-card input:focus { border-color: var(--blue); }
.login-card button { width: 100%; padding: 12px; }
.login-error {
  background: #fde7e6;
  color: #c0392b;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* Detail page */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
}
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}
.detail-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 16px;
}
.detail-card h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 12px;
  font-weight: 600;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.detail-row:last-child { border-bottom: none; }
.detail-row .key { color: var(--muted); font-size: 14px; }
.detail-row .val { font-weight: 500; font-size: 14px; text-align: right; }
.address-block {
  background: var(--paper);
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.6;
}
.line-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  gap: 16px;
}
.line-item:last-child { border-bottom: none; }
.line-item-name { font-weight: 500; margin-bottom: 4px; }
.line-item-desc { color: var(--muted); font-size: 13px; }
.line-item-price { white-space: nowrap; font-weight: 500; }

.totals {
  background: var(--paper);
  padding: 16px 18px;
  border-radius: 10px;
  margin-top: 16px;
}
.totals-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 14px;
}
.totals-row.grand {
  font-weight: 700;
  font-size: 16px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
  padding-top: 12px;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.actions .btn { width: 100%; padding: 12px; }

textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  outline: none;
  resize: vertical;
  min-height: 80px;
  background: var(--card);
}
textarea:focus { border-color: var(--blue); }

input[type=text], input[type=url], input[type=password] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  outline: none;
  background: var(--card);
}
input[type=text]:focus, input[type=url]:focus { border-color: var(--blue); }

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 20, 0.5);
  display: grid;
  place-items: center;
  z-index: 100;
}
.modal {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 28px;
  width: 100%;
  max-width: 440px;
  margin: 16px;
}
.modal h2 { font-size: 18px; margin-bottom: 16px; letter-spacing: -0.02em; }
.modal label { display: block; font-size: 13px; font-weight: 500; margin: 12px 0 6px; }
.modal-actions { display: flex; gap: 8px; margin-top: 20px; justify-content: flex-end; }

/* Loading */
.loading { color: var(--muted); padding: 40px; text-align: center; }
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink);
  color: white;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }

.ship-by {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.ship-by.overdue { color: var(--red); font-weight: 600; }
.ship-by.soon { color: var(--yellow); font-weight: 600; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 16px;
}
.back-link:hover { color: var(--ink); text-decoration: none; }
