:root {
  --bg: #f4f7ff;
  --surface: #ffffff;
  --text: #172033;
  --muted: #5f6b83;
  --line: #d9e2f2;
  --primary: #0f766e;
  --primary-2: #115e59;
  --blue: #2563eb;
  --danger: #dc2626;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Poppins", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 10%, #dbeafe, transparent 36%),
    radial-gradient(circle at 90% 0%, #dcfce7, transparent 30%),
    var(--bg);
  color: var(--text);
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-card {
  width: min(420px, 100%);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.1rem;
}

.auth-card h1 {
  margin: 0 0 0.3rem;
  font-size: 1.45rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.auth-card p {
  margin: 0 0 0.9rem;
  color: var(--muted);
}

.auth-error {
  margin-top: 0.75rem !important;
  color: #991b1b !important;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  padding: 1rem;
  border-right: 1px solid var(--line);
  background: #f7fbff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.8rem;
  border-radius: 14px;
  background: #ebf6ff;
  margin-bottom: 1rem;
}

.brand i {
  font-size: 1.3rem;
  color: #0c4a6e;
}

.brand small {
  display: block;
  color: var(--muted);
}

.menu {
  display: grid;
  gap: 0.55rem;
}

.menu-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  padding: 0.75rem;
  font: inherit;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
}

.menu-item.active {
  background: #dff7f4;
  border-color: #7dd3c7;
  color: #0f766e;
}

.main-content {
  padding: 1.2rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.9rem;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.25rem, 2.5vw, 1.95rem);
}

.topbar p {
  margin: 0.45rem 0 1rem;
  color: var(--muted);
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-user span {
  color: var(--muted);
  font-size: 0.92rem;
}

.topbar-user button {
  width: auto;
  margin-top: 0;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}

.kpi-card,
.card {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.kpi-card p {
  margin: 0;
  color: var(--muted);
}

.kpi-card strong {
  font-size: 1.75rem;
}

.card {
  margin-bottom: 0.9rem;
}

h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr));
  gap: 0.75rem;
}

label {
  font-size: 0.92rem;
  display: block;
}

input,
textarea,
button {
  width: 100%;
  margin-top: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.68rem 0.78rem;
  font: inherit;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: #67e8f9;
  box-shadow: 0 0 0 4px rgba(103, 232, 249, 0.26);
}

textarea {
  resize: vertical;
}

.form-actions {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.7rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.65rem;
}

.checkbox-label input {
  width: auto;
  margin: 0;
}

button {
  border: none;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  cursor: pointer;
}

button:hover {
  background: var(--primary-2);
}

.secondary-btn {
  background: #64748b;
}

.secondary-btn:hover {
  background: #475569;
}

.danger-btn,
.delete-btn {
  background: var(--danger);
}

.danger-btn:hover,
.delete-btn:hover {
  background: #b91c1c;
}

.edit-btn {
  background: var(--blue);
}

.edit-btn:hover {
  background: #1d4ed8;
}

.done-btn {
  background: #0284c7;
}

.done-btn:hover {
  background: #0369a1;
}

.appointments-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.appointment {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem;
  margin-bottom: 0.65rem;
  background: linear-gradient(180deg, #fff, #f9fbff);
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
}

.appointment.done {
  border-color: #86efac;
  background: linear-gradient(180deg, #f0fdf4, #ffffff);
}

.appointment strong {
  display: block;
  margin-bottom: 0.3rem;
}

.appointment-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  margin-top: 0.45rem;
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
}

.badge.done {
  background: #dcfce7;
  color: #166534;
}

.appointment-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-content: flex-start;
}

.appointment-actions button {
  width: auto;
  min-width: 105px;
}

.empty-message {
  color: var(--muted);
  border: 1px dashed var(--line);
  padding: 0.75rem;
  border-radius: 10px;
  text-align: center;
}

.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: grid;
  place-items: center;
  z-index: 999;
  padding: 1rem;
}

.modal-card {
  width: min(440px, 100%);
  background: #fff;
  border-radius: 16px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 48px rgba(15, 23, 42, 0.2);
  padding: 1rem;
}

.modal-card h3 {
  margin: 0;
  color: #991b1b;
}

.modal-card p {
  margin: 0.8rem 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

body.no-scroll {
  overflow: hidden;
}

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .menu {
    grid-template-columns: repeat(3, minmax(100px, 1fr));
  }

  .kpi-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .topbar {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-actions,
  .modal-actions,
  .topbar-user {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-user button {
    width: 100%;
  }

  .appointment {
    flex-direction: column;
  }

  .appointment-actions button {
    width: 100%;
  }

  .menu {
    grid-template-columns: 1fr;
  }
}
