:root {
  --bg: #f4f5f9;
  --card: #ffffff;
  --border: #e4e6ef;
  --text: #14142b;
  --muted: #6e7191;
  --primary: #4d3edb;
  --primary-dark: #372aa8;
  --danger: #b42318;
  --pending: #b54708;
  --pending-bg: #fef0c7;
  --approved: #067647;
  --approved-bg: #d1fadf;
  --declined: #b42318;
  --declined-bg: #fee4e2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.topbar .brand .logo {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.topbar nav {
  display: flex;
  gap: 24px;
}

.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding-bottom: 4px;
}

.topbar nav a.active {
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}

.topbar .clinic-name {
  color: var(--muted);
  font-size: 14px;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px;
}

h1 {
  font-size: 28px;
  margin: 0 0 4px;
}

.subtitle {
  color: var(--muted);
  margin: 0 0 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

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

thead th {
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: uppercase;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  vertical-align: middle;
}

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

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.pending { color: var(--pending); background: var(--pending-bg); }
.badge.approved { color: var(--approved); background: var(--approved-bg); }
.badge.declined, .badge.auto_declined { color: var(--declined); background: var(--declined-bg); }

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

button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 999px;
  padding: 8px 18px;
  border: none;
  cursor: pointer;
}

button.btn-primary {
  background: var(--primary);
  color: #fff;
}
button.btn-primary:hover { background: var(--primary-dark); }

button.btn-secondary {
  background: #eceefb;
  color: var(--text);
}

button.btn-secondary:hover { background: #dde0f7; }

button:disabled { opacity: 0.5; cursor: not-allowed; }

.empty-state {
  padding: 48px 20px;
  text-align: center;
  color: var(--muted);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 43, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal-overlay.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 480px;
  padding: 28px;
}

.modal h2 { margin: 0 0 8px; font-size: 20px; }
.modal p { color: var(--muted); font-size: 14px; margin: 0 0 16px; }

.modal label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.modal textarea {
  width: 100%;
  min-height: 90px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

/* Login page */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 380px;
}

.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card p.subtitle { margin-bottom: 24px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin: 10px 0 0;
  display: none;
}

.error-text.visible { display: block; }

.filters { display: flex; gap: 8px; margin-bottom: 16px; }
.filters button {
  background: #eceefb;
  color: var(--text);
  padding: 6px 14px;
  font-size: 13px;
}
.filters button.active { background: var(--primary); color: #fff; }
