:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1f2933;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #0f766e;
  --brand-soft: #ccfbf1;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --ok: #166534;
  --ok-soft: #dcfce7;
  --warn: #92400e;
  --warn-soft: #fef3c7;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 250px;
  flex: 0 0 250px;
  background: #111827;
  color: #d1d5db;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: block;
  color: #f9fafb;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.2px;
  padding: 0 10px 18px;
}
.brand:hover { text-decoration: none; }
.brand small { display: block; color: #9ca3af; font-size: 11px; font-weight: 500; margin-top: 2px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-group { margin-top: 14px; }
.nav-group-title {
  color: #6b7280;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0 10px 6px;
}
.nav-item {
  display: block;
  color: #d1d5db;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13px;
}
.nav-item:hover { color: #ffffff; background: #1f2937; text-decoration: none; }
.nav-item.active { color: #ffffff; background: var(--brand); font-weight: 600; }

.sidebar-footer {
  margin-top: auto;
  padding: 16px 10px 0;
  border-top: 1px solid #1f2937;
}
.sidebar-footer .user { color: #f9fafb; font-weight: 600; }
.sidebar-footer .muted { color: #6b7280; font-size: 11px; margin-top: 2px; }
.logout-form { margin-top: 12px; }
.logout-button {
  width: 100%;
  background: transparent;
  border: 1px solid #374151;
  color: #d1d5db;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 10px;
}
.logout-button:hover { background: var(--danger); border-color: var(--danger); color: #ffffff; }

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 0%, #e5f5f2 0%, var(--bg) 55%);
}
.login-card {
  width: min(400px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}
.login-brand {
  color: var(--brand);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.2px;
  margin-bottom: 22px;
}
.login-brand small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}
.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--muted);
}
.login-field input { width: 100%; }
.login-card button[type="submit"] { width: 100%; padding: 11px; margin-top: 4px; }
.login-footer { text-align: center; margin: 18px 0 0; }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 24px; flex: 1; }
h1 { font-size: 22px; margin: 0 0 18px; }
h2 { font-size: 16px; margin: 0; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-label { color: var(--muted); font-size: 12px; }
.card strong { font-size: 22px; }

.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 18px;
  overflow-x: auto;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.muted { color: var(--muted); font-size: 12px; }
.empty { color: var(--muted); padding: 12px 0; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: #fafafa; }
tbody tr:hover { background: #fafafa; }
td.price { font-variant-numeric: tabular-nums; font-weight: 600; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 18px;
}
.filters label, .form-row label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
input, select {
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  min-width: 150px;
}
input:focus, select:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }

button, .button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--brand);
  border: 0;
  border-radius: 7px;
  padding: 9px 14px;
  cursor: pointer;
}
button:hover, .button:hover { background: #115e59; text-decoration: none; }
.button-secondary { background: #6b7280; }
.button-secondary:hover { background: #4b5563; }
.button-danger { background: var(--danger); }
.button-danger:hover { background: #991b1b; }
button.button-danger { padding: 6px 10px; font-size: 12px; }

.form-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.form-section h2 { margin-bottom: 12px; }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}
.form-note { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.courier-grid { display: flex; flex-wrap: wrap; gap: 10px 20px; }
.courier-grid .checkbox { min-width: 130px; }
.checkbox { display: flex; flex-direction: row; align-items: center; gap: 6px; color: var(--text); font-size: 13px; }
.checkbox input { min-width: auto; }

.spinner { color: var(--muted); font-size: 13px; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

.status, .pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.status-success, .status-active, .status-paid { background: var(--ok-soft); color: var(--ok); }
.status-error, .status-failed, .status-canceled { background: var(--danger-soft); color: var(--danger); }
.status-pending { background: var(--warn-soft); color: var(--warn); }
.status-expired, .status-refunded { background: #e5e7eb; color: #374151; }
.pill { background: #eef2ff; color: #3730a3; }
.pill-warn { background: var(--warn-soft); color: var(--warn); }

.alert { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 18px; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

dialog.dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28);
}
dialog.dialog::backdrop { background: rgba(17, 24, 39, 0.55); }
.dialog-body { padding: 20px; }
.dialog-body h2 { margin-bottom: 14px; }

.breadcrumb { margin-bottom: 14px; color: var(--muted); }
.breadcrumb a { color: var(--brand); }
.breadcrumb .current { color: var(--text); font-weight: 600; }
.detail { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; margin: 14px 0; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; }

pre {
  background: #0b1020;
  color: #e5e7eb;
  padding: 14px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 12px;
  line-height: 1.45;
  max-height: 460px;
}

.pagination { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; }
.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    position: static;
    width: auto;
    flex: none;
    height: auto;
    padding: 16px;
  }
  .brand { padding-bottom: 10px; }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .nav-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 8px;
  }
  .nav-group-title { width: 100%; padding: 4px 10px; }
  .sidebar-footer { margin-top: 12px; padding-top: 12px; }
}

@media (max-width: 640px) {
  .container { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .detail { grid-template-columns: 1fr; }
  .detail dt { margin-top: 8px; }
}
