/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: #1e293b;
  background: #f1f5f9;
  line-height: 1.5;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Navbar ===== */
.navbar {
  background: #1e3a5f;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.navbar-brand { display: flex; align-items: center; gap: 12px; }

.navbar-logo {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.25);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  padding: 4px 8px;
  border-radius: 4px;
}

.navbar-title {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
}

.navbar-sub {
  font-size: 12px;
  font-weight: 400;
  color: rgba(255,255,255,0.6);
  margin-left: 6px;
}

/* ===== Page Container ===== */
.page-container {
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
}

/* ===== Alerts ===== */
.alert {
  padding: 12px 16px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.5;
}

.alert-success { background: #dcfce7; border: 1px solid #86efac; color: #166534; }
.alert-danger  { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; }
.alert-warning { background: #fef9c3; border: 1px solid #fde047; color: #854d0e; }

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  border-top: 4px solid transparent;
}

.stat-blue   { border-top-color: #2563eb; }
.stat-green  { border-top-color: #16a34a; }
.stat-orange { border-top-color: #d97706; }
.stat-red    { border-top-color: #dc2626; }
.stat-purple { border-top-color: #7c3aed; }

.stat-number {
  font-size: 36px;
  font-weight: 700;
  line-height: 1;
  color: #1e293b;
  margin-bottom: 6px;
}

.stat-label {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar-search { flex: 1; min-width: 220px; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Table ===== */
.table-wrapper {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  overflow-x: auto;
}

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

thead th {
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: #64748b;
  white-space: nowrap;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
}

thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { background: #f1f5f9; color: #334155; }
thead th.sorted-asc .sort-icon::after  { content: ' ↑'; }
thead th.sorted-desc .sort-icon::after { content: ' ↓'; }

tbody tr { border-bottom: 1px solid #f1f5f9; transition: background 0.1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

td { padding: 10px 12px; vertical-align: middle; }

.td-name   { min-width: 150px; white-space: nowrap; }
.td-email  { min-width: 180px; }
.td-room   { min-width: 70px;  }
.td-arrival { min-width: 120px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.td-transport { min-width: 140px; }
.td-actions { min-width: 100px; white-space: nowrap; }
.td-emailsent { font-size: 12px; white-space: nowrap; min-width: 110px; }

.link-subtle { color: #475569; }
.link-subtle:hover { color: #1e3a5f; }
.text-muted { color: #94a3b8; }

.table-empty {
  text-align: center;
  padding: 48px 24px;
  color: #94a3b8;
  font-size: 15px;
}

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-info    { background: #dbeafe; color: #1d4ed8; }

/* ===== Key Button ===== */
.btn-key {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  color: #64748b;
  transition: all 0.15s;
}

.btn-key:hover { background: #e2e8f0; }

.btn-key.collected {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.btn-key.collected:hover { background: #bbf7d0; }

/* ===== Action Icon Buttons ===== */
.btn-icon {
  background: none;
  border: 1px solid #e2e8f0;
  border-radius: 5px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0 2px;
  transition: all 0.15s;
  color: #475569;
}

.btn-icon:hover { background: #f1f5f9; border-color: #cbd5e1; }
.btn-icon:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-edit:hover  { background: #dbeafe; border-color: #93c5fd; color: #1d4ed8; }
.btn-email:hover { background: #dcfce7; border-color: #86efac; color: #166534; }
.btn-delete:hover { background: #fee2e2; border-color: #fca5a5; color: #dc2626; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
  line-height: 1;
}

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }

.btn-primary   { background: #1e3a5f; color: #fff; border-color: #1e3a5f; }
.btn-primary:hover { background: #162d4a; }

.btn-secondary { background: #fff; color: #475569; border-color: #cbd5e1; }
.btn-secondary:hover { background: #f8fafc; border-color: #94a3b8; }

.btn-warning   { background: #d97706; color: #fff; border-color: #d97706; }
.btn-warning:hover { background: #b45309; }

.btn-danger    { background: #dc2626; color: #fff; border-color: #dc2626; }
.btn-danger:hover { background: #b91c1c; }

.btn-ghost     { background: transparent; color: #475569; border-color: #cbd5e1; }
.btn-ghost:hover { background: #f1f5f9; }

.btn-ghost-light { background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(255,255,255,0.2); }
.btn-ghost-light:hover { background: rgba(255,255,255,0.2); text-decoration: none; }

/* ===== Form Controls ===== */
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 14px;
  color: #1e293b;
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.form-control:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-group { margin-bottom: 0; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ===== Modals ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  overflow: hidden;
  animation: modal-in 0.15s ease;
}

.modal-wide { max-width: 640px; }

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(-8px); }
  to   { opacity: 1; transform: none; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 { font-size: 16px; font-weight: 600; color: #1e293b; }

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #94a3b8;
  line-height: 1;
  padding: 0 4px;
}
.modal-close:hover { color: #475569; }

.modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

.modal-section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: -4px;
}

/* ===== Login Page ===== */
.login-page { background: #1e3a5f; min-height: 100vh; display: flex; align-items: center; justify-content: center; }

.login-container {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

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

.login-logo-mark {
  display: inline-block;
  background: #1e3a5f;
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.1em;
  padding: 10px 18px;
  border-radius: 8px;
  margin-bottom: 14px;
}

.login-logo h1 { font-size: 20px; font-weight: 700; color: #1e293b; margin-bottom: 4px; }
.login-logo p  { font-size: 14px; color: #64748b; }

.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-form label { display: block; font-size: 13px; font-weight: 500; color: #475569; margin-bottom: 6px; }

/* ===== CSV helper ===== */
.csv-columns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.csv-columns code {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 12px;
  color: #334155;
}

.help-text { font-size: 13px; color: #64748b; line-height: 1.6; }

/* ===== Misc ===== */
.req { color: #dc2626; }
