:root {
  --ink: #071013;
  --graphite: #1d272b;
  --muted: #607076;
  --line: #e3e9e7;
  --paper: #f5f8f3;
  --white: #ffffff;
  --mint: #18a76b;
  --blue: #2f5fdd;
  --amber: #e88b3a;
  --red: #b42318;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); color: var(--ink); }
a { color: inherit; }
[hidden] { display: none !important; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.side {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  background: var(--white);
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
  text-decoration: none;
  color: inherit;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: linear-gradient(135deg, #2f5fdd, #18a76b);
  color: white;
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}
.brand strong { display: block; font-size: 0.96rem; font-weight: 800; letter-spacing: 0.02em; }
.brand small { display: block; color: var(--muted); font-size: 0.76rem; }
.brand-big .brand-mark { width: 46px; height: 46px; font-size: 0.88rem; }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--graphite);
  transition: background 180ms, color 180ms;
}
.side-nav a:hover { background: var(--paper); }
.side-nav a.active { background: color-mix(in srgb, var(--blue) 12%, transparent); color: var(--blue); }

.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }

.btn-ghost {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}
.btn-ghost:hover { background: var(--paper); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  min-height: 64px;
  padding: 12px 28px;
  background: rgba(255,255,255,0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.topbar h1 { margin: 0; font-size: 1.1rem; font-weight: 800; }
.content { padding: 24px 28px 60px; max-width: 1200px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  padding: 18px;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(7,16,19,0.04);
}
.kpi-label { margin: 0; color: var(--muted); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-value { margin: 6px 0 4px; font-size: 1.6rem; font-weight: 900; }
.kpi-foot { margin: 0; color: var(--muted); font-size: 0.82rem; }

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.card-header h2 { margin: 0; font-size: 1rem; font-weight: 800; }
.card-header h3 { margin: 0; font-size: 0.95rem; font-weight: 800; }

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.grid-2-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: relative; height: auto; flex-direction: row; flex-wrap: wrap; }
  .brand { border: 0; margin: 0; padding: 0 12px 0 0; }
  .side-nav { flex-direction: row; flex: 1 1 auto; flex-wrap: wrap; }
  .side-foot { padding: 0; border: 0; margin-left: auto; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-2-form { grid-template-columns: 1fr; }
}

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 8px; text-align: left; font-size: 0.88rem; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 800; text-transform: uppercase; font-size: 0.72rem; letter-spacing: 0.04em; }
.table tbody tr:hover { background: var(--paper); }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pill-ok, .pill-succeeded { background: rgba(24,167,107,0.14); color: #0c6d48; }
.pill-pending, .pill-processing { background: rgba(232,139,58,0.14); color: #8a4f1a; }
.pill-fail, .pill-failed, .pill-canceled { background: rgba(180,35,24,0.12); color: #b42318; }
.pill-off, .pill-refunded { background: var(--paper); color: var(--muted); }

.alert { padding: 12px 14px; border-radius: 10px; margin-bottom: 16px; font-size: 0.92rem; }
.alert-ok { background: rgba(24,167,107,0.12); color: #0c6d48; border: 1px solid rgba(24,167,107,0.3); }
.alert-error { background: rgba(180,35,24,0.1); color: #b42318; border: 1px solid rgba(180,35,24,0.3); }

.lbl { display: block; margin-bottom: 12px; font-size: 0.84rem; font-weight: 700; color: var(--graphite); }
.lbl input, .lbl select, .lbl textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  background: #fbfdfb;
  color: var(--ink);
  outline: none;
}
.lbl input:focus, .lbl select:focus, .lbl textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,95,221,0.15); }
.check { display: flex; gap: 8px; align-items: center; margin: 6px 0 14px; font-weight: 700; }

.btn-primary {
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 800;
  cursor: pointer;
  transition: background 180ms;
}
.btn-primary:hover { background: #122227; }

.btn-small {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.btn-small.danger { color: var(--red); border-color: rgba(180,35,24,0.3); }
.btn-small.danger:hover { background: rgba(180,35,24,0.06); }

.empty { color: var(--muted); padding: 18px; text-align: center; font-size: 0.92rem; }

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.filters input, .filters select {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  font: inherit;
}

.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }

.help { background: linear-gradient(180deg, var(--paper), var(--white)); border-color: rgba(47,95,221,0.18); }
.code-box {
  background: #0a121a;
  color: #d8e1ee;
  padding: 12px 14px;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 0.82rem;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.link { color: var(--blue); font-weight: 700; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* LOGIN */
.login-body { background: linear-gradient(135deg, #071013, #1d272b); display: grid; place-items: center; min-height: 100vh; }
.login-card {
  width: min(380px, calc(100% - 24px));
  padding: 32px;
  background: var(--white);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.45);
}
.login-sub { color: var(--muted); margin: 12px 0 18px; font-size: 0.9rem; }
.login-form label { display: block; font-weight: 700; margin-bottom: 4px; }
.login-form input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; margin-bottom: 12px; }
.login-form button { width: 100%; }

.toast-container { position: fixed; top: 80px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 14px; background: var(--ink); color: white; border-radius: 10px; font-weight: 700; font-size: 0.88rem; opacity: 0; transform: translateX(20px); transition: 220ms; }
.toast.show { opacity: 1; transform: translateX(0); }
.toast-ok { background: linear-gradient(135deg, #18a76b, #0c6d48); }
.toast-error { background: linear-gradient(135deg, #b42318, #7a2418); }
