:root {
  --bg: #10110f;
  --bg-2: #171814;
  --panel: #1d1f19;
  --line: #2d2f28;
  --text: #f4f0e6;
  --muted: #9c9789;
  --gold: #d4b06a;
  --gold-2: #f0d7a0;
  --green: #7dba7a;
  --red: #d36b5e;
  --blue: #8aa6c1;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
  --radius: 16px;
  --font: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(212, 176, 106, 0.08), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--gold-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px;
  background: #12130f;
  border-right: 1px solid var(--line);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand { display: flex; flex-direction: column; gap: 4px; }
.brand-mark {
  font-family: var(--font);
  font-size: 22px;
  letter-spacing: 0.02em;
}
.brand-mark span { color: var(--gold); }
.brand small { color: var(--muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; gap: 6px; }
.nav a {
  color: var(--text);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 10px;
  color: #d9d3c5;
}
.nav a:hover, .nav a.active { background: #24261f; color: var(--gold-2); }
.sidebar-foot { margin-top: auto; color: var(--muted); font-size: 12px; }

.main { flex: 1; padding: 32px 40px 56px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 28px; }
.topbar h1 { margin: 0; font-family: var(--font); font-size: 34px; font-weight: 500; }
.topbar p { margin: 6px 0 0; color: var(--muted); }

.badge, .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-test { background: #3a2f16; color: var(--gold-2); border: 1px solid #6a5424; }
.badge-live { background: #1d3320; color: #b6e0b3; border: 1px solid #35633a; }
.status { font-size: 12px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; padding: 5px 9px; border-radius: 999px; }
.status-pending, .status-processing { background: #2f2a1a; color: #e6cb86; }
.status-paid, .status-succeeded { background: #1c3324; color: #b7e0b4; }
.status-failed, .status-expired, .status-cancelled, .status-canceled { background: #3a221f; color: #f0b0a8; }
.status-refunded, .status-partially_refunded { background: #1e2c38; color: #b9d0e6; }
.status-disputed { background: #3a2618; color: #f0c39a; }

.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card {
  background: linear-gradient(180deg, #21231c, #1a1c16);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
}
.stat-label { color: var(--muted); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.stat-value { font-family: var(--font); font-size: 30px; margin-top: 8px; }
.stat-note { color: var(--muted); font-size: 13px; margin-top: 6px; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 12px; letter-spacing: 0.07em; text-transform: uppercase; font-weight: 600; }
tr:hover td { background: rgba(255,255,255,0.015); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }

.btn, button.btn {
  appearance: none;
  border: 0;
  background: var(--gold);
  color: #20190d;
  font-weight: 650;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-family: var(--sans);
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.05); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-danger { background: #8d3d35; color: #fff; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

label { display: block; font-size: 13px; color: #d8d2c4; margin-bottom: 6px; }
input, select, textarea {
  width: 100%;
  background: #12140f;
  border: 1px solid #35372e;
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid rgba(212, 176, 106, 0.35);
  border-color: var(--gold);
}
.field { margin-bottom: 16px; }
.help { color: var(--muted); font-size: 12px; margin-top: 6px; }
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 18px; }
.flash-ok { background: #1c3324; color: #c8ebc5; }
.flash-err { background: #3a221f; color: #f3c4be; }
.flash-warn { background: #3a2f16; color: #f0d7a0; }

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card { width: min(440px, 100%); }

.line-row { display: grid; grid-template-columns: 2fr 90px 120px 40px; gap: 8px; margin-bottom: 8px; }
.detail-grid { display: grid; grid-template-columns: 1.3fr 0.7fr; gap: 16px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.copy {
  border: 1px dashed #4a4638;
  background: #141610;
  padding: 12px;
  border-radius: 10px;
  word-break: break-all;
}

.customer {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 16px;
}
.customer-card { width: min(560px, 100%); text-align: center; }
.customer-card h1 { font-family: var(--font); font-weight: 500; font-size: 36px; margin: 8px 0 10px; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 22px;
}
.filters .field { margin-bottom: 0; }
.filters input,
.filters select { width: 170px; }
.filters .btn { height: 42px; }
input[type="date"] {
  color-scheme: dark;
  color: var(--text);
}
input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 1;
  cursor: pointer;
  width: 16px;
  height: 16px;
  filter: none;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23f4f0e6' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='2' y='3.5' width='12' height='11' rx='1.5'/%3E%3Cpath d='M2 7.5h12M5.5 1.5v3M10.5 1.5v3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px 16px;
}
.filter-error {
  display: none;
  width: 100%;
  margin: -12px 0 18px;
  color: #f3c4be;
  font-size: 13px;
}
.filter-error.show { display: block; }
.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0;
}
.inline-form input { width: 160px; }

.empty { color: var(--muted); padding: 28px 8px; text-align: center; }

@media (max-width: 980px) {
  .app-shell { display: block; }
  .sidebar { width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .grid-4, .grid-2, .detail-grid, .line-row { grid-template-columns: 1fr; }
  .main { padding: 22px 16px 40px; }
  .kv { grid-template-columns: 1fr; }
}
