:root {
  --bg: #14181f;
  --bg-deep: #0f1217;
  --panel: #1b212b;
  --panel-2: #222a36;
  --line: #6b4a23;
  --line-soft: #2e3644;
  --text: #ece7dc;
  --muted: #a6a9b0;
  --gold-a: #f0d27a;
  --gold-b: #b3852f;
  --wine-1: #4a0e1a;
  --wine-2: #6d1428;
  --wine-3: #8c1c35;
  --danger: #e05a4e;
  --ok: #6fcf8f;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.5 var(--font);
  color: var(--text);
  background:
    radial-gradient(900px 480px at 85% -10%, rgba(140, 28, 53, .28), transparent 70%),
    radial-gradient(700px 400px at -10% 0%, rgba(179, 133, 47, .14), transparent 70%),
    var(--bg);
  background-attachment: fixed;
}

a { color: var(--gold-a); text-underline-offset: 3px; }
a:hover { color: #fff3c9; }

:focus-visible {
  outline: 2px solid var(--gold-a);
  outline-offset: 2px;
}

.wordmark {
  font-weight: 800;
  letter-spacing: .04em;
  background: linear-gradient(135deg, var(--gold-a), var(--gold-b));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, var(--wine-1), #2d0a12);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 18px rgba(0, 0, 0, .35);
}

.topbar-inner {
  max-width: 72rem;
  margin: 0 auto;
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.topbar .wordmark { font-size: 1.35rem; margin-right: auto; }

.nav-toggle { position: absolute; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.nav-burger {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px;
  height: 44px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.nav-burger span {
  display: block;
  height: 2px;
  background: var(--gold-a);
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}

.nav-toggle:focus-visible + .nav-burger { outline: 2px solid var(--gold-a); outline-offset: 2px; }
.nav-toggle:checked + .nav-burger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle:checked + .nav-burger span:nth-child(2) { opacity: 0; }
.nav-toggle:checked + .nav-burger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.nav-menu {
  display: none;
  flex-basis: 100%;
  flex-direction: column;
  gap: .25rem;
  padding-top: .4rem;
}

.nav-toggle:checked ~ .nav-menu { display: flex; }

.nav-menu a {
  padding: .65rem .8rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  border: 1px solid transparent;
}

.nav-menu a:hover { background: rgba(240, 210, 122, .08); color: var(--gold-a); }
.nav-menu a[aria-current="page"] { color: var(--gold-a); border-color: var(--line); background: rgba(240, 210, 122, .1); }

.nav-user { margin: 0; }
.nav-user button { width: 100%; }

@media (min-width: 52rem) {
  .nav-burger { display: none; }
  .nav-menu { display: flex; flex: 1 1 auto; flex-basis: auto; flex-direction: row; align-items: center; padding: 0; gap: .15rem; }
  .nav-menu a { padding: .45rem .75rem; }
  .nav-user { margin-left: auto; }
  .nav-user button { width: auto; }
  .topbar .wordmark { margin-right: 0; }
}

.page {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

h1, h2 { line-height: 1.2; margin: 0 0 1rem; font-weight: 700; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; margin-top: 2rem; color: var(--gold-a); }

form:not(.inline):not(.nav-user) {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 1.1rem;
  margin: 0 0 1.25rem;
  max-width: 34rem;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
}

label {
  display: block;
  margin: 0 0 .9rem;
  color: var(--muted);
  font-size: .9rem;
}

input, select {
  display: block;
  width: 100%;
  margin-top: .3rem;
  padding: .65rem .75rem;
  font: inherit;
  color: var(--text);
  background: var(--bg-deep);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  min-height: 44px;
}

input:hover, select:hover { border-color: var(--line); }
input:focus-visible, select:focus-visible { border-color: var(--gold-a); outline: 2px solid var(--gold-a); outline-offset: 0; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: .5rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: #1a1306;
  background: linear-gradient(135deg, var(--gold-a), var(--gold-b));
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: box-shadow .2s, transform .1s, filter .2s;
}

button:hover { box-shadow: 0 0 14px rgba(240, 210, 122, .35); filter: brightness(1.06); }
button:active { transform: translateY(1px); }

form.inline button {
  min-height: 34px;
  padding: .2rem .7rem;
  font-size: .85rem;
}

button.btn-ghost {
  color: var(--gold-a);
  background: transparent;
  border-color: var(--line);
}

button.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, var(--wine-3), var(--wine-2));
  border-color: var(--wine-3);
}

button.btn-danger:hover { box-shadow: 0 0 14px rgba(224, 90, 78, .35); }

.flash {
  max-width: 34rem;
  margin: 0 0 1rem;
  padding: .75rem 1rem;
  border-radius: 8px;
  border: 1px solid;
}

.flash-ok { color: var(--ok); background: rgba(111, 207, 143, .08); border-color: rgba(111, 207, 143, .45); }
.flash-error { color: #ffb4ac; background: rgba(140, 28, 53, .35); border-color: var(--danger); }

.table-wrap {
  overflow-x: auto;
  margin: 0 0 1.25rem;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--panel);
  -webkit-overflow-scrolling: touch;
}

table { border-collapse: collapse; width: 100%; min-width: 34rem; }

th, td {
  padding: .6rem .8rem;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

thead th {
  color: var(--gold-a);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: rgba(107, 74, 35, .22);
  white-space: nowrap;
}

tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
tbody tr:hover { background: rgba(240, 210, 122, .04); }
tbody th { color: var(--muted); font-weight: 600; }

form.inline { display: inline-block; margin: .1rem .15rem .1rem 0; }

.pager { display: flex; gap: .75rem; margin: 0 0 1rem; }

.pager a {
  padding: .5rem 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
}

.pager a:hover { background: rgba(240, 210, 122, .1); }

.auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.auth .flash { max-width: 24rem; width: 100%; }

.auth-card {
  width: 100%;
  max-width: 24rem;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 2rem 1.5rem;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .4), 0 18px 48px rgba(0, 0, 0, .5), 0 0 40px rgba(140, 28, 53, .25);
  animation: rise .5s ease-out both;
}

.auth-card .wordmark { display: block; text-align: center; font-size: 2.2rem; }

.auth-card h1 {
  text-align: center;
  margin: .25rem 0 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
}

.auth-card form:not(.inline):not(.nav-user) { background: none; border: 0; box-shadow: none; padding: 0; margin: 0; max-width: none; }
.auth-card button { width: 100%; margin-top: .4rem; animation: pulse 2.8s ease-in-out infinite; }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(240, 210, 122, 0); }
  50% { box-shadow: 0 0 16px rgba(240, 210, 122, .3); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin: 0 0 1rem; }
.toolbar h1 { margin: 0 auto 0 0; }
.toolbar form.search:not(.inline):not(.nav-user) { display: flex; gap: .5rem; background: none; border: 0; box-shadow: none; padding: 0; margin: 0; max-width: none; flex: 1 1 16rem; justify-content: flex-end; }
.toolbar .search input { margin: 0; max-width: 20rem; }

.btn-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  color: #1a1306;
  text-decoration: none;
  background: linear-gradient(135deg, var(--gold-a), var(--gold-b));
  border: 1px solid var(--line);
  border-radius: 8px;
}

.btn-plus:hover { color: #1a1306; box-shadow: 0 0 14px rgba(240, 210, 122, .35); }

.row-actions { white-space: nowrap; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-height: 0;
  padding: 0;
  color: var(--gold-a);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.icon-btn:hover { background: rgba(240, 210, 122, .12); box-shadow: none; filter: none; }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn.icon-danger { color: #ff9a90; border-color: var(--wine-3); }
.icon-btn.icon-danger:hover { background: rgba(140, 28, 53, .45); }

.badge {
  display: inline-block;
  padding: .1rem .6rem;
  font-size: .8rem;
  color: var(--gold-a);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(240, 210, 122, .08);
}

.pager { align-items: center; flex-wrap: wrap; }
.pager-info { color: var(--muted); font-size: .9rem; margin-right: auto; order: 0; }

form.wide { max-width: 40rem; }
fieldset { border: 1px solid var(--line-soft); border-radius: 8px; margin: 0 0 1rem; padding: .6rem .9rem .2rem; }
legend { color: var(--gold-a); padding: 0 .4rem; font-size: .9rem; }
label.check { display: flex; align-items: center; gap: .6rem; color: var(--text); }
label.check input { width: 1.15rem; height: 1.15rem; min-height: 0; margin: 0; accent-color: var(--gold-b); }
.btn-link { margin-left: 1rem; }
