:root {
  --background: 210 25% 98%;
  --foreground: 216 100% 18%;
  --card: 0 0% 100%;
  --card-foreground: 216 100% 18%;
  --primary: 216 100% 18%;
  --primary-foreground: 0 0% 100%;
  --secondary: 187 100% 39%;
  --muted: 210 20% 96%;
  --muted-foreground: 215 16% 40%;
  --accent: 187 100% 39%;
  --accent-foreground: 0 0% 100%;
  --gold: 46 65% 52%;
  --destructive: 0 84% 60%;
  --border: 214 25% 90%;
  --input: 214 25% 90%;
  --ring: 187 100% 39%;
  --brand: #001f5c;
  --brand-soft: #00a8c5;
  --radius: 0.5rem;
}

html.dark {
  --background: 216 65% 8%;
  --foreground: 210 30% 96%;
  --card: 216 55% 12%;
  --card-foreground: 210 30% 96%;
  --primary: 187 100% 45%;
  --primary-foreground: 216 65% 8%;
  --secondary: 216 100% 18%;
  --muted: 216 40% 16%;
  --muted-foreground: 215 20% 65%;
  --accent: 187 100% 50%;
  --accent-foreground: 216 65% 8%;
  --gold: 46 55% 58%;
  --destructive: 0 62% 50%;
  --border: 216 35% 20%;
  --input: 216 35% 20%;
  --ring: 187 100% 45%;
  --brand: #00a8c5;
  --brand-soft: #4db8dc;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: #005c6f; }
html.dark a { color: #4db8dc; }

.shell {
  display: grid;
  grid-template-columns: 256px 1fr;
  min-height: 100vh;
}
.rail {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  border-right: 1px solid hsl(var(--border));
  padding: 0;
  display: flex;
  flex-direction: column;
}
.mark {
  display: flex;
  gap: 12px;
  align-items: center;
  height: 64px;
  padding: 0 16px;
  border-bottom: 1px solid hsl(var(--border));
}
.mark b {
  display: block;
  font-size: 16px;
  font-weight: 700;
  color: var(--brand);
}
.mark span {
  display: block;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
}
.logo {
  height: 40px;
  width: auto;
  object-fit: contain;
}
nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  flex: 1;
}
nav a {
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
}
nav a:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }
nav a.active {
  background: #001f5c;
  color: white;
}
html.dark nav a.active {
  background: hsl(var(--accent));
  color: #0a192f;
}
.rail footer {
  margin-top: auto;
  border-top: 1px solid hsl(var(--border));
  padding: 16px;
}
.who { margin: 0 12px; font-size: 14px; font-weight: 500; }
.who-mail { margin: 2px 12px 12px; color: hsl(var(--muted-foreground)); font-size: 12px; }
.rail-actions { display: flex; gap: 8px; }
.rail-actions button,
.theme-corner {
  background: transparent;
  color: hsl(var(--muted-foreground));
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 8px 10px;
}
.rail-actions button,
.theme-corner {
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  flex: 1;
}
.theme-corner {
  width: 36px;
  flex: 0 0 auto;
}
.rail-actions button:hover,
.theme-corner:hover {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}

.main { padding: 28px 32px 64px; max-width: 1180px; }
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  background: hsl(var(--background));
}
.theme-corner { position: absolute; top: 16px; right: 16px; }
.login-card, .card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 31, 92, 0.06);
}
html.dark .login-card,
html.dark .card { box-shadow: none; }
.login-card { width: min(420px, 100%); padding: 28px; }
.login-card .mark { height: auto; border: 0; padding: 0 0 8px; }
h1, h2, h3 { font-weight: 650; letter-spacing: -0.02em; margin: 0 0 8px; }
h1 { font-size: 32px; }
h2 { font-size: 28px; color: hsl(var(--foreground)); }
.lede { color: hsl(var(--muted-foreground)); margin: 0 0 22px; line-height: 1.5; }
.page-head { margin-bottom: 22px; }

label { display: block; font-size: 13px; color: hsl(var(--muted-foreground)); margin: 12px 0 6px; }
input, select, textarea {
  width: 100%;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius);
  padding: 10px 12px;
  color: hsl(var(--foreground));
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 1px;
}
textarea { min-height: 88px; resize: vertical; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: end; }
.btn {
  border: 0;
  border-radius: 6px;
  padding: 10px 16px;
  background: #001f5c;
  color: white;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-ico { display: inline-flex; }
html.dark .btn {
  background: hsl(var(--accent));
  color: #0a192f;
}
.btn.secondary {
  background: transparent;
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
}
html.dark .btn.secondary {
  background: transparent;
  color: hsl(var(--foreground));
}
.btn.danger { background: hsl(var(--destructive)); color: white; }
html.dark .btn.danger { color: white; }
.btn.info { background: hsl(var(--accent)); color: #0a192f; }
.btn:disabled { opacity: 0.55; cursor: wait; }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.stat { padding: 18px; }
.stat strong { display: block; font-size: 28px; color: var(--brand); }
.stat span { color: hsl(var(--muted-foreground)); }
table {
  width: 100%;
  border-collapse: collapse;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  overflow: hidden;
}
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid hsl(var(--border)); vertical-align: top; }
th {
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted));
}
tr:last-child td { border-bottom: 0; }
.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
}
.pill.ready { background: #d7f5e4; color: #146c43; }
.pill.bad { background: #fde8e8; color: #b42318; }
.pill.wait { background: #e6f4fa; color: #005c6f; }
html.dark .pill.ready { background: rgba(16, 90, 55, 0.45); color: #b7ebc9; }
html.dark .pill.bad { background: rgba(127, 29, 29, 0.45); color: #fecaca; }
html.dark .pill.wait { background: rgba(0, 92, 111, 0.45); color: #b3e0f0; }
.wizard {
  display: flex;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
}
.wizard li {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 10px;
  background: hsl(var(--muted));
  color: hsl(var(--muted-foreground));
  font-weight: 600;
  font-size: 14px;
}
.wizard li b {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 13px;
}
.wizard li small { display: block; font-weight: 500; font-size: 12px; opacity: 0.8; }
.wizard li.current { background: #001f5c; color: white; }
.wizard li.current b { background: white; color: #001f5c; }
html.dark .wizard li.current { background: hsl(var(--accent)); color: #0a192f; }
html.dark .wizard li.current b { background: #0a192f; color: hsl(var(--accent)); }
.wizard li.done { background: #d7f5e4; color: #146c43; }
.wizard li.done b { background: #146c43; color: white; }
html.dark .wizard li.done { background: rgba(16, 90, 55, 0.45); color: #b7ebc9; }
html.dark .wizard li.done b { background: #146c43; color: white; }
.summary { display: flex; flex-wrap: wrap; gap: 18px 28px; }
.summary span { display: block; color: hsl(var(--muted-foreground)); font-size: 12px; margin-bottom: 2px; }
.actions-cell { white-space: nowrap; }
.actions-cell .btn { margin: 0 6px 0 0; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.table-wrap { overflow-x: auto; border: 1px solid hsl(var(--border)); border-radius: 12px; }
.table-wrap table { border: 0; border-radius: 0; }
.note { color: hsl(var(--muted-foreground)); font-size: 13px; }
.error {
  background: #fde8e8;
  color: #b42318;
  border-radius: 8px;
  padding: 10px 12px;
  margin: 10px 0;
}
html.dark .error { background: rgba(127, 29, 29, 0.35); color: #fecaca; }
.callout {
  border: 1px solid hsl(46 65% 52% / 0.45);
  background: hsl(46 65% 52% / 0.12);
  border-radius: 10px;
  padding: 14px 16px;
  margin: 12px 0 18px;
}
.list { display: flex; flex-direction: column; gap: 10px; }
.item-card { padding: 14px 16px; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.maker-main { flex: 1; min-width: 0; }
.maker-input { max-width: 360px; }
.maker-actions { margin-top: 0; }
code { font-size: 13px; }

.dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.dialog-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: hsl(216 100% 18% / 0.45);
  backdrop-filter: blur(4px);
}
html.dark .dialog-backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog-panel {
  position: relative;
  z-index: 1;
  width: min(28rem, 100%);
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0, 31, 92, 0.18);
}
.dialog-x {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: hsl(var(--muted-foreground));
}
.dialog-x:hover { background: hsl(var(--muted)); color: hsl(var(--foreground)); }
.dialog-body { padding: 28px 24px 8px; text-align: center; }
.dialog-badge {
  width: 48px;
  height: 48px;
  margin: 0 auto;
  border-radius: 999px;
  display: grid;
  place-items: center;
}
.dialog-badge.danger { background: rgba(239, 68, 68, 0.1); color: #dc2626; }
html.dark .dialog-badge.danger { color: #f87171; }
.dialog-badge.info { background: hsl(var(--accent) / 0.15); color: hsl(var(--accent)); }
.dialog-body h2 { margin-top: 16px; font-size: 18px; }
.dialog-body p { margin: 8px 0 0; color: hsl(var(--muted-foreground)); line-height: 1.6; }
.dialog-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  border-top: 1px solid hsl(var(--border));
  padding: 16px 24px;
}
.dialog-footer .btn { min-width: 7rem; justify-content: center; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { border-right: 0; border-bottom: 1px solid hsl(var(--border)); }
  nav { flex-direction: row; flex-wrap: wrap; }
  .main { padding: 20px 16px 48px; }
  .row { grid-template-columns: 1fr; }
}
