  @import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&family=Playfair+Display:wght@600&display=swap');

  *,
  *::before,
  *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
  }

  :root {
    --red: #d62b2b;
    --blue: #1a6ef5;
    --blue-light: #e8f0fe;
    --green: #22c55e;
    --green-light: #dcfce7;
    --red-del: #ef4444;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --bg: #f1f5f9;
    --white: #ffffff;
    --sidebar-w: 220px;
    --header-h: 64px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    --radius: 12px;
  }

  body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
  }

  /* ─── HEADER ─────────────────────────────────────────────── */
  header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: var(--header-h);
    background: var(--white);
    border-bottom: 1px solid var(--border);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0 24px;
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  }

  .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
  }

  .logo svg {
    width: 40.166px;
    height: 40.166px;
  }

  .logo-text {
    color: #000;
    font-family: "Open Sans", sans-serif;
    font-size: 26.777px;
    font-weight: 700;
    line-height: normal;
  }

  .btn-book {
    background: var(--blue);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background 0.2s, transform 0.1s;
    font-family: 'DM Sans', sans-serif;
    grid-column: 2;
  }

  .btn-book:hover {
    background: #1558d4;
    transform: translateY(-1px);
  }

  .btn-book:active {
    transform: translateY(0);
  }

  /* ─── LAYOUT ──────────────────────────────────────────────── */
  .app-body {
    display: flex;
    margin-top: var(--header-h);
    min-height: calc(100vh - var(--header-h));
  }

  /* ─── SIDEBAR ─────────────────────────────────────────────── */
  aside {
    width: var(--sidebar-w);
    background: var(--white);
    border-right: 1px solid var(--border);
    padding: 20px 0;
    position: fixed;
    top: var(--header-h);
    bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: width 0.25s, transform 0.25s;
    z-index: 90;
    overflow: hidden;
  }

  aside.collapsed {
    width: 60px;
  }

  .sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 18px;
    margin-bottom: 8px;
    color: var(--text-muted);
    font-size: 1.1rem;
    align-self: flex-end;
  }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-family: 'DM Sans', sans-serif;
  }

  .nav-item svg {
    flex-shrink: 0;
  }

  .nav-item:hover {
    background: var(--blue-light);
    color: var(--blue);
  }

  .nav-item.active {
    background: var(--blue-light);
    color: var(--blue);
  }

  .nav-label {
    transition: opacity 0.2s;
  }

  aside.collapsed .nav-label {
    opacity: 0;
    pointer-events: none;
  }

  /* ─── MAIN ────────────────────────────────────────────────── */
  main {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 24px;
    transition: margin-left 0.25s;
    width: 100%;
    max-width: 100%;
  }

  main.sidebar-collapsed {
    margin-left: 60px;
  }

  /* ─── VIEWS ───────────────────────────────────────────────── */
  .view {
    display: none;
  }

  .view.active {
    display: block;
  }

  /* ─── CALENDAR TOOLBAR ────────────────────────────────────── */
  .cal-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-bottom: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) 0 0;
    padding: 12px 16px;
  }

  .cal-nav-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: background 0.15s;
    font-family: 'DM Sans', sans-serif;
  }

  .cal-nav-btn:hover {
    background: var(--blue-light);
    color: var(--blue);
    border-color: var(--blue);
  }

  .cal-date-display {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
  }

  .cal-date-display:hover {
    border-color: var(--blue);
    color: var(--blue);
  }

  .btn-today {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    font-family: 'DM Sans', sans-serif;
    color: var(--text);
  }

  .btn-today:hover {
    background: var(--blue-light);
    color: var(--blue);
    border-color: var(--blue);
  }

  .view-select {
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 28px 4px 8px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    background: var(--white);
    font-family: 'DM Sans', sans-serif;
    color: var(--text);
    outline: none;
    width: auto;
    min-width: 70px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg fill='%2364748b' height='10' viewBox='0 0 20 20' width='10' xmlns='http://www.w3.org/2000/svg'><path d='M5 7l5 5 5-5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px;
  }

  .view-select:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 2px rgba(26, 110, 245, 0.1);
  }

  .view-select:hover {
    border-color: var(--blue);
  }

  /* ─── CALENDAR ────────────────────────────────────────────── */
  .calendar-wrap {
    background: var(--white);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
  }

  .cal-provider-label {
    text-align: center;
    padding: 10px;
    font-weight: 600;
    color: var(--blue);
    font-size: 0.95rem;
    border-bottom: 1px solid var(--border);
  }

  .cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    min-width: 700px;
  }

  .cal-day-header {
    padding: 10px 0;
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
  }

  .cal-cell {
    min-height: 100px;
    padding: 6px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    cursor: pointer;
    transition: background 0.12s;
    position: relative;
  }

  .cal-cell:nth-child(7n) {
    border-right: none;
  }

  .cal-cell:hover {
    background: var(--blue-light);
  }

  .cal-cell.other-month .cal-date-num {
    color: #cbd5e1;
  }

  .cal-cell.today {
    background: #eff6ff;
  }

  .cal-cell.today .cal-date-num {
    color: var(--blue);
    font-weight: 700;
  }

  .cal-date-num {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
  }

  .appt-chip {
    background: var(--green);
    color: white;
    border-radius: 5px;
    padding: 3px 6px;
    font-size: 0.72rem;
    font-weight: 500;
    margin-bottom: 3px;
    cursor: pointer;
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    position: relative;
  }

  .appt-chip:hover {
    background: #16a34a;
  }

  .chip-actions-row {
    display: flex;
    gap: 4px;
    margin-top: 2px;
  }

  .chip-action-btn {
    background: rgba(255, 255, 255, 0.25);
    border: none;
    border-radius: 3px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    transition: background 0.1s;
  }

  .chip-action-btn:hover {
    background: rgba(255, 255, 255, 0.45);
  }

  /* ─── DASHBOARD ───────────────────────────────────────────── */
  .dashboard-wrap {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
  }

  .dashboard-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 20px;
  }

  .filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 20px;
  }

  .search-input-wrap {
    position: relative;
    flex: 1;
    min-width: 160px;
  }

  .search-input-wrap svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
  }

  .search-input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px 9px 34px;
    font-size: 0.875rem;
    outline: none;
    font-family: 'DM Sans', sans-serif;
    color: var(--text);
  }

  .search-input:focus {
    border-color: var(--blue);
  }

  .search-input::placeholder {
    color: var(--text-muted);
  }

  .date-input-wrap {
    position: relative;
  }

  .date-input-wrap svg {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
  }

  .date-filter-input {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px 9px 34px;
    font-size: 0.875rem;
    outline: none;
    font-family: 'DM Sans', sans-serif;
    color: var(--text);
    cursor: pointer;
  }

  .date-filter-input:focus {
    border-color: var(--blue);
  }

  .dash-separator {
    color: var(--text-muted);
    font-weight: 600;
    align-self: center;
  }

  .btn-update {
    background: var(--blue);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 9px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-family: 'DM Sans', sans-serif;
  }

  .btn-update:hover {
    background: #1558d4;
  }

  /* ─── TABLE ───────────────────────────────────────────────── */
  .appt-table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
  }

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

  th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--border);
  }

  td {
    padding: 13px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
  }

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

  tr:hover td {
    background: var(--bg);
  }

  .td-patient,
  .td-doctor {
    color: var(--blue);
    font-weight: 500;
    cursor: pointer;
  }

  .td-patient:hover,
  .td-doctor:hover {
    text-decoration: underline;
  }

  .td-time {
    color: var(--blue);
    font-weight: 500;
  }

  .action-btns {
    display: flex;
    gap: 10px;
    align-items: center;
  }

  .action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.12s;
    display: flex;
    align-items: center;
    justify-content: center;
  }

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

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

  .action-btn.del {
    color: var(--red-del);
  }

  .action-btn.del:hover {
    background: #fee2e2;
  }

  .empty-row td {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
  }

  /* ─── MODAL ───────────────────────────────────────────────── */
  .modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 16px;
    backdrop-filter: blur(2px);
  }

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

  .modal {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 600px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    animation: modalIn 0.2s ease;
    max-height: 92vh;
    overflow-y: auto;
  }

  @keyframes modalIn {
    from {
      opacity: 0;
      transform: translateY(-12px) scale(0.97);
    }

    to {
      opacity: 1;
      transform: none;
    }
  }

  .modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
  }

  .modal-title {
    font-size: 1.1rem;
    font-weight: 700;
  }

  .modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 1.2rem;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s;
  }

  .modal-close:hover {
    background: var(--bg);
    color: var(--text);
  }

  .modal-body {
    padding: 24px;
  }

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

  .form-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .form-field.full {
    grid-column: 1 / -1;
  }

  label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .field-wrap {
    position: relative;
    display: flex;
    align-items: center;
  }

  .field-wrap svg {
    position: absolute;
    left: 10px;
    color: var(--text-muted);
    pointer-events: none;
    flex-shrink: 0;
  }

  input[type="text"],
  input[type="date"],
  input[type="time"],
  select,
  textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px 10px 36px;
    font-size: 0.875rem;
    outline: none;
    font-family: 'DM Sans', sans-serif;
    color: var(--text);
    transition: border-color 0.15s;
    background: var(--white);
    appearance: none;
    -webkit-appearance: none;
  }

  input:focus,
  select:focus,
  textarea:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(26, 110, 245, 0.08);
  }

  input.error,
  select.error,
  textarea.error {
    border-color: var(--red-del);
  }

  textarea {
    resize: vertical;
    min-height: 80px;
    padding-top: 10px;
  }

  .select-wrap {
    position: relative;
  }

  .select-wrap::after {
    content: '▾';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--text-muted);
    font-size: 0.8rem;
  }

  .error-msg {
    font-size: 0.75rem;
    color: var(--red-del);
    display: none;
  }

  .error-msg.show {
    display: block;
  }

  .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
  }

  .btn-cancel {
    background: none;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    font-family: 'DM Sans', sans-serif;
    color: var(--text);
  }

  .btn-cancel:hover {
    background: var(--bg);
  }

  .btn-save {
    background: var(--blue);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-family: 'DM Sans', sans-serif;
  }

  .btn-save:hover {
    background: #1558d4;
  }

  /* ─── TOAST ───────────────────────────────────────────────── */
  .toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
    background: var(--text);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.25s, transform 0.25s;
    pointer-events: none;
  }

  .toast.show {
    opacity: 1;
    transform: none;
  }

  .toast.green {
    background: var(--green);
  }

  .toast.red {
    background: var(--red-del);
  }

  /* ─── MOBILE ──────────────────────────────────────────────── */
  .mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--text-muted);
    align-items: center;
    justify-content: center;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 89;
  }

  .sidebar-backdrop.show {
    display: block;
  }

  .table-scroll {
    overflow-x: auto;
    width: 100%;
  }

  ::-webkit-scrollbar {
    width: 6px;
    height: 6px;
  }

  ::-webkit-scrollbar-track {
    background: transparent;
  }

  ::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
  }

  .sidebar-toggle svg {
    transition: transform 0.3s ease;
  }

  aside.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
  }

  /* ─── RESPONSIVE ──────────────────────────────────────────── */
  @media (max-width: 900px) {
    aside {
      transform: translateX(-100%);
      position: fixed;
      z-index: 1000;
    }

    aside.mobile-open {
      transform: translateX(0);
      width: var(--sidebar-w);
    }

    main {
      margin-left: 0 !important;
      width: 100%;
    }

    .mobile-menu-btn {
      display: flex !important;
    }

    .cal-cell {
      min-height: 70px;
    }

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

  @media (max-width: 600px) {
    .cal-provider-label {
      font-size: 0.8rem;
      padding: 8px;
    }

    header {
      display: flex;
      justify-content: space-between;
      padding: 0 12px;
      gap: 10px;
    }

    .btn-book {
      padding: 8px 12px;
      font-size: 0.75rem;
    }

    main {
      padding: 12px;
    }

    .dashboard-wrap {
      padding: 12px;
    }

    .filter-row {
      flex-direction: column;
      align-items: stretch;
    }

    .btn-update {
      width: 100%;
    }

    .cal-day-header {
      font-size: 0.65rem;
      padding: 6px 0;
    }

    .cal-date-num {
      font-size: 0.72rem;
    }

    .appt-chip {
      font-size: 0.65rem;
    }

    .cal-cell {
      min-height: 55px;
      padding: 4px;
    }

    th,
    td {
      padding: 8px 10px;
      font-size: 0.8rem;
    }

    .modal {
      max-width: 100%;
      border-radius: 12px 12px 0 0;
      position: fixed;
      bottom: 0;
      margin: 0;
      max-height: 90vh;
    }

    .modal-overlay {
      align-items: flex-end;
    }
  }

  @media (max-width: 400px) {
    .logo-text {
      font-size: 18px;
    }

    .btn-book {
      padding: 6px 10px;
      font-size: 0.7rem;
    }

    .cal-grid {
      min-width: 600px;
    }
  }

  .calendar-scroll {
    overflow-x: auto;
  }

  .cal-grid {
    min-width: 700px;
  }

  .appt-header {
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    padding: 14px;
    background: var(--blue-light);
    color: var(--blue);
    border-bottom: 1px solid var(--border);
  }