:root {
  --primary: #1a3a2a;
  --primary-dark: #0f281c;
  --primary-light: #e8f0ea;
  --gold: #d4a843;
  --gold-hover: #c49a33;
  --gold-light: #f5edd6;
  --bg: #f4f1ea;
  --card: #ffffff;
  --border: #e3ddd3;
  --text: #1e1e1e;
  --text-muted: #7a7a7a;
  --danger: #b91c1c;
  --wave1: #1565c0;
  --wave2: #b8860b;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Header */
header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  color: #fff;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}
.logo-text h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.logo-text .sub {
  font-size: 11px;
  opacity: 0.7;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

/* SVG logo emblem */
.logo-emblem {
  flex-shrink: 0;
}
.logo-emblem svg {
  display: block;
}

/* Navigation */
nav {
  display: flex;
  gap: 2px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  overflow-x: auto;
}
nav button {
  border: none;
  background: none;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}
nav button:hover { color: var(--primary); }
nav button.active {
  color: var(--primary);
  border-bottom-color: var(--gold);
}

/* Main content */
main { padding: 28px 24px; max-width: 1120px; margin: 0 auto; }
section.tab { display: none; }
section.tab.active { display: block; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.card h2 {
  margin: 0 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
}
.card p.hint {
  color: var(--text-muted);
  font-size: 12px;
  margin: 0 0 14px;
  line-height: 1.5;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.card-header h2 { margin: 0; }

/* Form layout */
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 140px; }
.field label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Inputs */
input, select, textarea {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 2px var(--gold-light);
}
textarea { min-height: 160px; font-family: monospace; font-size: 11px; width: 100%; }

/* Buttons */
button.btn {
  padding: 9px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
button.btn:hover { background: var(--primary-dark); }
button.btn:disabled { background: #bbb; cursor: not-allowed; }
button.btn.secondary {
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--border);
}
button.btn.secondary:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}
button.btn.danger {
  background: #fff;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 5px 10px;
  font-size: 12px;
}
button.btn.danger:hover { background: #fdecea; }
button.btn-icon {
  background: none;
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 6px;
  width: 26px;
  height: 26px;
  line-height: 1;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s, color 0.15s;
}
button.btn-icon:hover { background: var(--danger); color: #fff; }
button.btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
th {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 700;
}
tr:hover td { background: #f8f6f2; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.badge.wave1 { background: #e3f2fd; color: var(--wave1); }
.badge.wave2 { background: var(--gold-light); color: var(--wave2); }
.badge.used { background: #eee; color: #999; }
.badge.free { background: var(--primary-light); color: var(--primary); }

/* Toast */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  color: #fff;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.25s;
  pointer-events: none;
  max-width: 340px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  z-index: 1000;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.ok { background: var(--primary); }
#toast.err { background: var(--danger); }

/* Misc */
.empty { color: var(--text-muted); font-size: 13px; padding: 20px 0; text-align: center; }
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.link-box {
  font-family: monospace;
  font-size: 12px;
  background: #f4f1ea;
  padding: 10px 12px;
  border-radius: 6px;
  word-break: break-all;
}
.table-scroll { overflow-x: auto; }
button.btn-refresh {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
button.btn-refresh:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}
.plan-note { color: var(--text-muted); font-style: italic; }

/* Login overlay */
#loginOverlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
#loginBox {
  background: #fff;
  border-radius: 16px;
  padding: 48px 40px;
  text-align: center;
  box-shadow: 0 12px 48px rgba(0,0,0,0.25);
  max-width: 400px;
  width: 90%;
}
#loginBox .login-logo { margin-bottom: 20px; }
#loginBox h1 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
}
#loginBox p {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 24px;
  line-height: 1.6;
}
#loginBox .btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
#loginBox .btn-primary:hover { background: var(--primary-dark); }

@media (max-width: 640px) {
  header { padding: 12px 16px; }
  main { padding: 16px; }
  .row { flex-direction: column; align-items: stretch; }
  .field { min-width: 0; }
  nav { padding: 0 12px; }
  nav button { padding: 10px 12px; font-size: 12px; }
}
