/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --primary:       #163d40;
  --primary-dark:  #0f2b2e;
  --primary-light: #e6f1f2;
  --gold:          #eaad13;
  --gold-dark:     #c4920f;
  --gold-light:    #fdf8e1;
  --success:       #059669;
  --success-light: #ECFDF5;
  --warning:       #D97706;
  --warning-light: #FFFBEB;
  --danger:        #DC2626;
  --danger-light:  #FEF2F2;
  --neutral:       #6B7280;
  --neutral-light: #F3F5F5;
  --bg:            #eef1f1;
  --white:         #FFFFFF;
  --text:          #0d1f20;
  --text-muted:    #4d6e72;
  --border:        #d0dada;
  --radius:        10px;
  --shadow-sm:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow:        0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:     0 20px 40px rgba(0,0,0,.14);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

/* ── Pages ────────────────────────────────────────────────── */
.page { min-height: 100vh; }

/* ── Login ────────────────────────────────────────────────── */
#login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #0b2527 0%, #163d40 60%, #1e5055 100%);
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo svg {
  width: 48px;
  height: 48px;
  stroke: var(--gold);
  margin-bottom: 12px;
}

.login-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}

.login-logo p {
  color: var(--text-muted);
  font-size: 13px;
}

.version-label {
  text-align: center;
  font-size: 11px;
  color: var(--border);
  margin-top: 24px;
}

/* ── Login sent / error states ───────────────────────────── */
.sent-icon {
  width: 60px;
  height: 60px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
}

.sent-icon svg {
  width: 28px;
  height: 28px;
  stroke: var(--primary);
}

.sent-icon.error { background: var(--danger-light); }
.sent-icon.error svg { stroke: var(--danger); }

.sent-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  margin-bottom: 10px;
}

.sent-desc {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.6;
  margin-bottom: 24px;
}

/* ── Form fields ──────────────────────────────────────────── */
.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 6px;
}

.field input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.field input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22,61,64,.15);
}

.field input::placeholder { color: #94A3B8; }

/* ── Buttons ──────────────────────────────────────────────── */
button { cursor: pointer; font-family: inherit; font-size: 14px; }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  transition: background .15s, transform .1s;
}

.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-full { width: 100%; justify-content: center; padding: 12px; }

/* Gold variant — New Voucher */
#new-voucher-btn, #empty-new-btn, #another-btn {
  background: var(--gold);
  color: var(--primary);
}

#new-voucher-btn:hover:not(:disabled),
#empty-new-btn:hover:not(:disabled),
#another-btn:hover:not(:disabled) { background: var(--gold-dark); color: #fff; }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-weight: 500;
  transition: background .15s, color .15s, border-color .15s;
}

.btn-ghost:hover {
  background: var(--neutral-light);
  border-color: #a8bdbf;
  color: var(--text);
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 600;
  transition: background .15s;
}

.btn-danger:hover:not(:disabled) { background: #B91C1C; }
.btn-danger:disabled { opacity: .6; cursor: not-allowed; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  transition: background .15s, color .15s, border-color .15s;
}

.btn-icon svg { width: 14px; height: 14px; pointer-events: none; }

.btn-icon.renew:hover {
  background: var(--gold-light);
  border-color: var(--gold);
  color: var(--gold-dark);
}

.btn-icon.delete:hover {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-icon.email:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.actions-cell {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

/* ── Expand button ────────────────────────────────────────── */
.expand-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  transition: color .15s, transform .2s;
  border-radius: 4px;
}

.expand-btn:hover { color: var(--gold); }
.expand-btn.open { transform: rotate(90deg); color: var(--gold); }
.expand-btn svg { width: 14px; height: 14px; pointer-events: none; }

/* ── Error message ────────────────────────────────────────── */
.error-msg {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #FECACA;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── Top bar ──────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  background: var(--primary);
  border-bottom: 3px solid var(--gold);
  box-shadow: var(--shadow);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-icon {
  width: 28px;
  height: 28px;
  stroke: var(--gold);
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-display {
  font-size: 13px;
  color: rgba(255,255,255,.65);
  font-weight: 500;
}

.topbar .btn-ghost {
  color: rgba(255,255,255,.8);
  border-color: rgba(255,255,255,.25);
}

.topbar .btn-ghost:hover {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.4);
  color: #fff;
}

/* ── Main content ─────────────────────────────────────────── */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px;
}

/* ── Summary cards ────────────────────────────────────────── */
.summary-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 700px) {
  .summary-row { grid-template-columns: repeat(2, 1fr); }
}

.summary-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border-left: 4px solid var(--gold);
}

.summary-card.success { border-left-color: var(--success); }
.summary-card.warning { border-left-color: var(--warning); }
.summary-card.neutral { border-left-color: var(--neutral); }

.summary-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
  margin-bottom: 4px;
}

.summary-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: .5px;
}

/* ── Toolbar ──────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 380px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  stroke: var(--text-muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: var(--white);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22,61,64,.12);
}

.toolbar-actions { display: flex; gap: 10px; }

/* ── Table ────────────────────────────────────────────────── */
.table-wrap {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}

.voucher-table {
  width: 100%;
  border-collapse: collapse;
}

.voucher-table thead {
  background: #edf2f2;
  border-bottom: 1px solid var(--border);
}

.voucher-table th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  white-space: nowrap;
}

.voucher-table td {
  padding: 14px 16px;
  border-bottom: 1px solid #edf2f2;
  vertical-align: middle;
}

.voucher-table tbody tr:last-child td { border-bottom: none; }

.voucher-table tbody tr:hover { background: #f2f6f6; }

/* ── Table cell specifics ─────────────────────────────────── */
.guest-name {
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.code-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-mono {
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: .5px;
  background: var(--primary-light);
  padding: 3px 8px;
  border-radius: 6px;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  transition: background .15s, color .15s, border-color .15s;
  flex-shrink: 0;
}

.copy-btn:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.copy-btn.copied {
  background: var(--success-light);
  border-color: var(--success);
  color: var(--success);
}

.copy-btn svg { width: 13px; height: 13px; }

/* ── Status badge ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-active   { background: var(--success-light); color: var(--success); }
.badge-warning  { background: var(--warning-light); color: var(--warning); }
.badge-danger   { background: var(--danger-light);  color: var(--danger); }
.badge-pending  { background: var(--gold-light); color: var(--gold-dark); }
.badge-neutral  { background: #F3F4F6; color: var(--neutral); }

/* ── Uses display ─────────────────────────────────────────── */
.uses-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.uses-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.uses-dots {
  display: flex;
  gap: 4px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border);
}

.dot.used { background: var(--gold); }

/* ── Expires cell ─────────────────────────────────────────── */
.expires-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 120px;
}

.expires-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.expires-bar-bg {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.expires-bar {
  height: 100%;
  border-radius: 2px;
  transition: width .3s;
}

.expires-bar.green  { background: var(--success); }
.expires-bar.amber  { background: var(--warning); }
.expires-bar.red    { background: var(--danger); }

/* ── Loading / empty / error states ──────────────────────── */
.loading-state, .empty-state, .error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 24px;
  color: var(--text-muted);
}

.loading-state { flex-direction: row; gap: 12px; }

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state svg {
  width: 48px;
  height: 48px;
  stroke: var(--border);
}

.empty-state p {
  font-size: 15px;
  color: var(--text-muted);
}

.error-state {
  color: var(--danger);
  font-size: 14px;
}

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11,22,24,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 200;
  backdrop-filter: blur(2px);
  animation: fade-in .15s ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--white);
  border-radius: 16px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
  animation: slide-up .2s ease;
  overflow: hidden;
}

@keyframes slide-up {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-header h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--primary);
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--text-muted);
}

.modal-close:hover { background: var(--neutral-light); color: var(--text); }
.modal-close svg { width: 16px; height: 16px; }

.modal-body { padding: 20px 24px; }
.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 0 24px 20px;
}

.modal-desc {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 20px;
  line-height: 1.6;
}

/* ── Modal success view ───────────────────────────────────── */
.success-body { text-align: center; }

.success-icon {
  width: 56px;
  height: 56px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.success-icon svg {
  width: 28px;
  height: 28px;
  stroke: var(--primary);
}

.success-name {
  font-weight: 600;
  color: var(--primary);
  font-size: 16px;
  margin-bottom: 16px;
}

.code-display {
  background: var(--primary);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.code-label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  font-weight: 700;
  color: rgba(255,255,255,.6);
  margin-bottom: 8px;
}

.code-value-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.code-value {
  font-family: 'Courier New', Courier, monospace;
  font-size: 26px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 2px;
}

.copy-btn.on-dark {
  border-color: rgba(255,255,255,.3);
  color: rgba(255,255,255,.7);
}

.copy-btn.on-dark:hover {
  background: rgba(255,255,255,.1);
  border-color: var(--gold);
  color: var(--gold);
}

.code-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ── Email section (success modal) ───────────────────────── */
.email-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 4px;
}

.email-input-row {
  display: flex;
  gap: 8px;
}

.email-input-row input[type="email"] {
  flex: 1;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.email-input-row input[type="email"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22,61,64,.12);
}

.email-input-row input[type="email"]::placeholder { color: #94A3B8; }

.btn-send-email {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  background: var(--gold);
  color: var(--primary);
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .15s;
  flex-shrink: 0;
}

.btn-send-email:hover:not(:disabled) { background: var(--gold-dark); color: #fff; }
.btn-send-email:disabled { opacity: .6; cursor: not-allowed; }
.btn-send-email svg { width: 14px; height: 14px; }

.email-status {
  margin-top: 8px;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 8px;
}

.email-status.ok {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid #A7F3D0;
}

.email-status.err {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #FECACA;
}

/* ── Manage access modal ──────────────────────────────────── */
.topbar-manage-btn { font-size: 13px; }

.access-list {
  list-style: none;
  margin-bottom: 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.access-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}

.access-list li:last-child { border-bottom: none; }
.access-list li:nth-child(even) { background: var(--bg); }

.access-list .remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: background .15s, color .15s, border-color .15s;
}

.access-list .remove-btn:hover {
  background: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger);
}

.access-list .remove-btn svg { width: 12px; height: 12px; pointer-events: none; }

.access-list-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.access-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.access-add-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.access-add-row input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22,61,64,.12);
}

/* ── Device panel ─────────────────────────────────────────── */
.device-row td {
  padding: 0;
  background: #f2f6f6;
  border-bottom: 1px solid var(--border);
}

.device-panel {
  padding: 12px 16px 16px 48px;
  border-top: 1px solid var(--border);
}

.device-panel-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px 0;
}

.device-panel-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 8px 0;
}

.device-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.device-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 6px 12px 6px 0;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.device-table td {
  padding: 8px 12px 8px 0;
  border-bottom: 1px solid #e2ecec;
  vertical-align: middle;
  color: var(--text);
}

.device-table tr:last-child td { border-bottom: none; }

.device-name {
  font-weight: 600;
  color: var(--text);
}

.device-mac {
  font-family: 'Courier New', Courier, monospace;
  font-size: 12px;
  color: var(--text-muted);
}

.online-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--neutral);
  margin-right: 6px;
  flex-shrink: 0;
}

.online-dot.online { background: var(--success); }
