:root {
  /* Tiffany Blue & iOS Glassmorphism Light Palette */
  --tiffany: #0ABAB5;
  --tiffany-hover: #089E9A;
  --tiffany-light: rgba(10, 186, 181, 0.12);
  --tiffany-glow: rgba(10, 186, 181, 0.28);

  --bg-primary: #F4F9F9;
  --bg-secondary: #FFFFFF;
  --bg-glass: rgba(255, 255, 255, 0.76);
  --bg-glass-strong: rgba(255, 255, 255, 0.90);
  --border-glass: rgba(10, 186, 181, 0.18);
  --border-subtle: rgba(15, 23, 42, 0.08);

  --text-main: #0F172A;
  --text-muted: #475569;
  --text-light: #64748B;

  --danger: #EF4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --success: #10B981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning: #F59E0B;
  --warning-bg: rgba(245, 158, 11, 0.12);

  /* Squircle Geometry & Font Scale */
  --squircle-lg: 26px;
  --squircle-md: 18px;
  --squircle-sm: 13px;
  --squircle-icon: 22.5%;
  --font-scale: 1;

  --shadow-ios: 0 10px 30px -5px rgba(10, 186, 181, 0.08), 0 4px 12px rgba(15, 23, 42, 0.04);
  --shadow-float: 0 20px 45px -10px rgba(15, 23, 42, 0.12);
}

[data-theme="dark"] {
  --bg-primary: #0B1316;
  --bg-secondary: #111D21;
  --bg-glass: rgba(17, 29, 33, 0.78);
  --bg-glass-strong: rgba(20, 35, 40, 0.92);
  --border-glass: rgba(10, 186, 181, 0.25);
  --border-subtle: rgba(255, 255, 255, 0.10);

  --text-main: #F1F5F9;
  --text-muted: #94A3B8;
  --text-light: #64748B;

  --shadow-ios: 0 12px 32px rgba(0, 0, 0, 0.45);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: calc(16px * var(--font-scale));
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'SF Pro Display', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* Subtle organic botanical leaf motif in background */
  background-image:
    radial-gradient(circle at 12% 8%, rgba(10, 186, 181, 0.10) 0%, transparent 36%),
    radial-gradient(circle at 88% 82%, rgba(16, 185, 129, 0.08) 0%, transparent 40%),
    url("data:image/svg+xml,%3Csvg width='120' height='120' viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M60 20 C80 20, 95 38, 95 60 C75 60, 60 45, 60 20 Z M60 20 C40 40, 45 70, 60 95' stroke='%230ABAB5' stroke-width='1' fill='none' opacity='0.06'/%3E%3C/svg%3E");
  transition: background-color 0.25s ease, color 0.25s ease;
}

/* --- TOP ACCESSIBILITY & CONTACTS BAR --- */
.top-utility-bar {
  background: var(--bg-glass-strong);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-subtle);
  padding: 6px 24px;
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.contacts-strip {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.contacts-strip a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: color 0.2s;
}

.contacts-strip a:hover {
  color: var(--tiffany);
}

.utility-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pill-group {
  display: inline-flex;
  background: var(--tiffany-light);
  border: 1px solid var(--border-glass);
  border-radius: 999px;
  padding: 2px;
}

.pill-btn {
  border: none;
  background: transparent;
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.pill-btn.active {
  background: var(--tiffany);
  color: #FFFFFF;
  box-shadow: 0 2px 8px var(--tiffany-glow);
}

/* --- MAIN GLASS HEADER --- */
.main-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(190%);
  -webkit-backdrop-filter: blur(24px) saturate(190%);
  border-bottom: 1px solid var(--border-glass);
  padding: 12px 24px;
}

.header-inner {
  max-width: 1320px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--text-main);
}

.squircle-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--squircle-icon);
  background: linear-gradient(135deg, var(--tiffany), #069490);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px var(--tiffany-glow);
  flex-shrink: 0;
}

.nav-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  padding: 9px 16px;
  border-radius: var(--squircle-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.nav-tab:hover {
  background: var(--tiffany-light);
  color: var(--tiffany);
}

.nav-tab.active {
  background: var(--tiffany);
  color: #FFFFFF;
  box-shadow: 0 6px 16px var(--tiffany-glow);
}

/* --- LAYOUT & SQUIRCLE GLASS CARDS --- */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

.role-section {
  display: none;
  animation: fadeIn 0.25s ease;
}

.role-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: var(--squircle-lg);
  padding: 24px;
  box-shadow: var(--shadow-ios);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 24px;
}

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

/* --- BUTTONS & INPUTS --- */
.btn {
  border: none;
  border-radius: var(--squircle-sm);
  padding: 11px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--tiffany);
  color: #FFFFFF;
  box-shadow: 0 6px 18px var(--tiffany-glow);
}

.btn-primary:hover {
  background: var(--tiffany-hover);
  transform: translateY(-1px);
}

.btn-outline {
  background: var(--bg-secondary);
  color: var(--text-main);
  border: 1px solid var(--border-glass);
}

.btn-outline:hover {
  border-color: var(--tiffany);
  color: var(--tiffany);
}

.btn-danger {
  background: var(--danger);
  color: #FFFFFF;
}

.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--squircle-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  color: var(--text-main);
  font-size: 0.92rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--tiffany);
  box-shadow: 0 0 0 3px var(--tiffany-light);
}

/* --- PATIENT ROUTE STEPPER --- */
.route-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.route-step-card {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--squircle-md);
  padding: 20px;
}

.step-badge {
  width: 36px;
  height: 36px;
  border-radius: var(--squircle-icon);
  background: var(--tiffany-light);
  color: var(--tiffany);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

/* --- SIP SOFTPHONE DIALER (FREEPBX) --- */
.sip-dialer-box {
  max-width: 380px;
  margin: 0 auto;
  background: var(--bg-glass-strong);
  border: 1px solid var(--border-glass);
  border-radius: var(--squircle-lg);
  padding: 22px;
  box-shadow: var(--shadow-float);
}

.sip-display {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--squircle-md);
  padding: 14px;
  text-align: center;
  margin-bottom: 14px;
}

.sip-equalizer {
  height: 44px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  margin-top: 8px;
}

.eq-bar {
  width: 5px;
  height: 6px;
  background: var(--tiffany);
  border-radius: 99px;
  transition: height 0.08s ease;
}

.dial-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.dial-key {
  height: 54px;
  border-radius: var(--squircle-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  color: var(--text-main);
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.dial-key span {
  font-size: 0.62rem;
  font-weight: 500;
  color: var(--text-light);
  letter-spacing: 1px;
}

.dial-key:active, .dial-key:hover {
  background: var(--tiffany-light);
  border-color: var(--tiffany);
  color: var(--tiffany);
}

/* --- CALENDAR SLOTS --- */
.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.slot-btn {
  padding: 9px 8px;
  border-radius: var(--squircle-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-secondary);
  color: var(--text-main);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  text-align: center;
}

.slot-btn.selected {
  background: var(--tiffany);
  color: #FFFFFF;
  border-color: var(--tiffany);
}

.slot-btn.blocked {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
  text-decoration: line-through;
  cursor: not-allowed;
}

/* --- WEBRTC VIDEO STAGE --- */
.webrtc-stage {
  position: relative;
  background: #091014;
  border-radius: var(--squircle-md);
  height: 300px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-glass);
}

.webrtc-stage video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pip-video {
  position: absolute;
  bottom: 12px;
  right: 12px;
  width: 110px;
  height: 76px;
  border-radius: 12px;
  border: 2px solid var(--tiffany);
  background: #1E293B;
  overflow: hidden;
}

/* --- BADGES & TABLES --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
}

.badge-tiffany { background: var(--tiffany-light); color: var(--tiffany); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.data-table th, .data-table td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
}

/* --- OFFICIAL FORM 028/O PRINT CONTAINER (INTEGRATED FROM 028.HTML) --- */
#pdf-export-container {
  display: none;
  background: #FFFFFF;
  color: #000000;
}

#pdf-template {
  width: 800px;
  height: 1131px;
  padding: 28px 34px;
  background: #FFFFFF;
  color: #000000;
  font-family: "Times New Roman", Times, serif;
  font-size: 9.5pt;
  line-height: 1.25;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.pdf-border-wrapper {
  border: 1.5px solid #000;
  padding: 14px 18px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
}

.pdf-header-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
  border-bottom: 1.5px solid #000;
  padding-bottom: 6px;
}

.pdf-header-table td {
  vertical-align: top;
  font-size: 8pt;
  line-height: 1.2;
  padding: 2px 4px;
}

.pdf-main-title {
  text-align: center;
  font-weight: bold;
  font-size: 12pt;
  text-transform: uppercase;
  margin: 6px 0 8px 0;
  letter-spacing: 0.3px;
}

.pdf-item-row {
  border: 1px solid #000;
  padding: 6px 10px;
  margin-bottom: 4px;
}

.pdf-item-label {
  font-weight: bold;
  display: block;
  margin-bottom: 2px;
}

.pdf-item-content p {
  margin: 0 0 2px 0;
}

.pdf-footer-section {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 8px;
}

/* --- TOAST --- */
#toast-box {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text-main);
  color: var(--bg-secondary);
  padding: 12px 20px;
  border-radius: var(--squircle-sm);
  font-weight: 600;
  font-size: 0.88rem;
  box-shadow: var(--shadow-float);
  z-index: 9999;
  opacity: 0;
  transform: translateY(15px);
  pointer-events: none;
  transition: all 0.25s ease;
}

#toast-box.show {
  opacity: 1;
  transform: translateY(0);
}
