:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #dde2e8;
  --text: #1d252d;
  --muted: #66727f;
  --accent: #1f7a5a;
  --danger: #b42318;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 32px auto;
}

.hidden { display: none !important; }

.publicHome {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.publicHome section {
  width: min(420px, 100%);
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.publicHome code {
  display: inline-block;
  margin-top: 16px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
}

.login {
  width: min(380px, 100%);
  margin: 12vh auto;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

h1, h2, p { margin: 0; }
h1 { font-size: 24px; }
h2 { font-size: 16px; margin-bottom: 12px; }
p { color: var(--muted); }

input, button, select {
  height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 0 12px;
  font: inherit;
}

input { background: #fff; min-width: 0; }
button {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}
button.secondary { background: #fff; color: var(--text); border-color: var(--line); }
button.danger { background: var(--danger); border-color: var(--danger); }

.login input, .login button { width: 100%; margin-top: 12px; }
#loginMsg { min-height: 22px; margin-top: 10px; color: var(--danger); }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.stats div, .toolbar, .filters, .tableWrap, .events {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stats div { padding: 16px; }
.stats span { display: block; font-size: 26px; font-weight: 700; }
.stats small { color: var(--muted); }

.toolbar {
  display: grid;
  grid-template-columns: 90px 120px 110px 1fr 1fr auto;
  gap: 10px;
  padding: 12px;
  margin-bottom: 16px;
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 140px auto auto;
  gap: 10px;
  padding: 12px;
  margin-bottom: 16px;
}

.tableWrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 1180px; }
th, td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
}
th { color: var(--muted); font-weight: 600; }
td code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.remark {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2f6;
  color: #43505c;
  font-size: 12px;
  white-space: nowrap;
}
.status.active { background: #e8f5ee; color: #176548; }
.status.unused { background: #eef2f6; color: #43505c; }
.status.frozen { background: #fff4dc; color: #8a5a00; }
.status.banned, .status.refunded { background: #fdecec; color: var(--danger); }
.status.expired { background: #f0edf8; color: #5b4694; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.actions button { height: 30px; padding: 0 10px; }

.events { margin-top: 16px; padding: 16px; }
.event {
  display: grid;
  grid-template-columns: 160px 120px 1fr 70px;
  gap: 12px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.event:first-of-type { border-top: 0; }

@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar, .filters { grid-template-columns: 1fr 1fr; }
  .toolbar button, .filters input { grid-column: 1 / -1; }
  header { align-items: flex-start; }
}
