@import url("https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=Outfit:wght@500;600;700&display=swap");

:root {
  --ink: #eef6f8;
  --ink-soft: #b7cdd4;
  --sidebar: rgba(8, 28, 38, 0.62);
  --accent: #2ee6c5;
  --accent-2: #f0c56a;
  --accent-deep: #149e88;
  --bg: #07141c;
  --card: rgba(255, 255, 255, 0.08);
  --glass: rgba(255, 255, 255, 0.09);
  --glass-2: rgba(255, 255, 255, 0.14);
  --line: rgba(255, 255, 255, 0.16);
  --danger: #ff7b7b;
  --ok: #3ee0a4;
  --warn: #f0c56a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  --radius: 18px;
}

html, body { height: 100%; }
body.app-body {
  margin: 0;
  color: var(--ink);
  font-family: "DM Sans", "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(1200px 700px at -10% -20%, #163a4a 0%, transparent 55%),
              radial-gradient(900px 600px at 110% 10%, #1a4d3d 0%, transparent 50%),
              radial-gradient(800px 500px at 70% 110%, #2a3a6a 0%, transparent 48%),
              var(--bg);
  background-attachment: fixed;
}

body.app-body::before,
body.app-body::after {
  content: "";
  position: fixed;
  z-index: 0;
  pointer-events: none;
  border-radius: 50%;
  filter: blur(40px);
}
body.app-body::before {
  width: 420px;
  height: 420px;
  left: -80px;
  top: 12%;
  background: rgba(46, 230, 197, 0.18);
  animation: floaty 14s ease-in-out infinite;
}
body.app-body::after {
  width: 360px;
  height: 360px;
  right: -70px;
  bottom: 8%;
  background: rgba(240, 197, 106, 0.14);
  animation: floaty 18s ease-in-out infinite reverse;
}

@keyframes floaty {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(24px, -18px, 0) scale(1.08); }
}

.app-shell { display: flex; min-height: 100%; position: relative; z-index: 1; }
.app-sidebar {
  width: 268px;
  background: var(--sidebar);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  color: #e8f1f3;
  padding: 1.25rem 1rem;
  flex-shrink: 0;
  border-right: 1px solid var(--line);
}
.brand { display: flex; gap: 0.75rem; align-items: center; margin-bottom: 1.5rem; }
.brand-mark {
  background: linear-gradient(145deg, var(--accent), #0e8f7c);
  color: #04231e;
  font-family: Outfit, DM Sans, sans-serif;
  font-weight: 700;
  padding: 0.5rem 0.58rem;
  border-radius: 12px;
  letter-spacing: 0.04em;
  box-shadow: 0 8px 22px rgba(46, 230, 197, 0.28);
}
.brand-title { font-family: Outfit, sans-serif; font-weight: 650; font-size: 0.98rem; }
.brand-sub { font-size: 0.72rem; opacity: 0.72; }
.side-nav { display: flex; flex-direction: column; gap: 0.22rem; }
.side-link {
  color: #d7e6ea;
  text-decoration: none;
  padding: 0.52rem 0.7rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  transition: background 0.18s ease, transform 0.18s ease, color 0.18s ease;
}
.side-link:hover { background: rgba(255,255,255,0.1); color: #fff; transform: translateX(3px); }
.side-link.active {
  background: linear-gradient(90deg, rgba(46, 230, 197, 0.28), rgba(46, 230, 197, 0.08));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(46, 230, 197, 0.35);
}
.side-group { margin: 0; }
.side-group-toggle {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.side-group-toggle::-webkit-details-marker { display: none; }
.side-group-toggle::after {
  content: "";
  margin-left: auto;
  width: 0.42rem;
  height: 0.42rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  opacity: 0.7;
  transition: transform 0.18s ease;
}
.side-group[open] > .side-group-toggle::after { transform: rotate(-135deg); }
.side-group-toggle.group-active {
  background: rgba(255,255,255,0.08);
  color: #fff;
}
.side-sub {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin: 0.2rem 0 0.35rem 0.7rem;
  padding-left: 0.55rem;
  border-left: 1px solid rgba(255,255,255,0.14);
}
.side-sub .side-link { padding: 0.42rem 0.65rem; font-size: 0.92rem; }
.side-sub .side-link:hover { transform: none; }
.mobile-group summary {
  cursor: pointer;
  list-style: none;
  color: inherit;
}
.mobile-group summary::-webkit-details-marker { display: none; }
.side-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.5; margin: 1rem 0 0.3rem; padding-left: 0.4rem; }
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app-top {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: rgba(8, 24, 32, 0.45);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  color: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.phi-banner { font-size: 0.8rem; opacity: 0.88; flex: 1; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.85rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.35rem 0.25rem 0.85rem;
}
.user-chip .btn-link { text-decoration: none; color: var(--accent) !important; font-weight: 600; }
.app-content { padding: 1.35rem 1.6rem 2.8rem; }
.page-title {
  font-family: Outfit, sans-serif;
  font-size: 1.7rem;
  font-weight: 650;
  margin-bottom: 0.25rem;
  letter-spacing: -0.03em;
}
.welcome-title {
  font-family: Outfit, sans-serif;
  font-size: 2.35rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.15;
  margin-bottom: 0.85rem;
}
.dash-title {
  font-size: 2.75rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
}
.page-lead { color: var(--ink-soft); margin-bottom: 1.25rem; }

.glass,
.card,
.kpi-card,
.mobile-card,
.table-responsive,
.login-card {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.25);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  color: var(--ink);
}
.card { background: var(--glass); }
.card-body { color: var(--ink); }
.card .h6, .card .h5, .card h2 { font-family: Outfit, sans-serif; letter-spacing: -0.02em; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.9rem; }
.kpi-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi-card { padding: 1.05rem 1.1rem; transition: transform 0.2s ease, border-color 0.2s ease; }
.kpi-card:hover { transform: translateY(-3px); border-color: rgba(46, 230, 197, 0.4); }
.kpi-card.met { box-shadow: inset 3px 0 0 var(--ok); }
.kpi-card.miss { box-shadow: inset 3px 0 0 var(--danger); }
.kpi-label { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
.kpi-value { font-family: Outfit, sans-serif; font-size: 1.75rem; font-weight: 700; }
.kpi-meta { font-size: 0.8rem; color: var(--ink-soft); }

.status-badge { display: inline-block; font-size: 0.72rem; padding: 0.22rem 0.6rem; border-radius: 999px; font-weight: 600; border: 1px solid transparent; }
.badge-info { background: rgba(90, 180, 220, 0.18); color: #c6e8f6; border-color: rgba(90, 180, 220, 0.3); }
.badge-primary { background: rgba(46, 230, 197, 0.16); color: #baf8ea; border-color: rgba(46, 230, 197, 0.32); }
.badge-warn { background: rgba(240, 197, 106, 0.16); color: #ffe3a3; border-color: rgba(240, 197, 106, 0.32); }
.badge-alert { background: rgba(255, 123, 123, 0.16); color: #ffc4c4; border-color: rgba(255, 123, 123, 0.3); }
.badge-ok { background: rgba(62, 224, 164, 0.16); color: #c4f8e0; border-color: rgba(62, 224, 164, 0.3); }
.badge-muted { background: rgba(255,255,255,0.08); color: #d5d5d5; }

.mobile-card { padding: 0.9rem 1rem; margin-bottom: 0.7rem; transition: transform 0.18s ease, border-color 0.18s ease; }
.mobile-card:hover { transform: translateY(-2px); border-color: rgba(46, 230, 197, 0.4); color: #fff; }
.action-stack { display: flex; flex-direction: column; gap: 0.75rem; }
.action-stack .card { margin: 0; }

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(900px 500px at 20% 0%, #1a5a4c, transparent 55%),
              radial-gradient(700px 500px at 90% 80%, #16324a, transparent 50%),
              #07141c;
  font-family: "DM Sans", sans-serif;
}
.login-wrap { width: min(440px, 92vw); position: relative; z-index: 1; }
.login-card { padding: 1.9rem; color: #eef6f8; }
.login-card .brand-title, .login-card .brand-sub, .login-card .text-muted, .login-card .form-label { color: #d5e6ea; }
.login-card code { color: var(--accent); }

.btn {
  border-radius: 12px;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: linear-gradient(180deg, #3af0cf, var(--accent-deep));
  border-color: transparent;
  color: #04231e;
  box-shadow: 0 10px 24px rgba(46, 230, 197, 0.28);
}
.btn-primary:hover, .btn-primary:focus {
  background: linear-gradient(180deg, #64f6dc, #128574);
  border-color: transparent;
  color: #04231e;
}
.btn-outline-secondary, .btn-outline-primary, .btn-outline-light {
  color: var(--ink);
  border-color: var(--line);
  background: rgba(255,255,255,0.04);
}
.btn-outline-secondary:hover, .btn-outline-primary:hover {
  background: rgba(46, 230, 197, 0.16);
  border-color: rgba(46, 230, 197, 0.45);
  color: #fff;
}
.btn-group .btn { backdrop-filter: blur(10px); }

.form-control, .form-select {
  background: rgba(7, 20, 28, 0.45);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 12px;
}
.form-control[type="date"] {
  color-scheme: dark;
  min-height: 42px;
}
.form-control:focus, .form-select:focus {
  background: rgba(7, 20, 28, 0.62);
  color: #fff;
  border-color: rgba(46, 230, 197, 0.55);
  box-shadow: 0 0 0 0.2rem rgba(46, 230, 197, 0.18);
}
.form-control::placeholder { color: #8aa3ab; }
.form-label, .form-check-label, .text-muted, .small.text-muted { color: var(--ink-soft) !important; }
.form-check-input { background-color: rgba(255,255,255,0.12); border-color: var(--line); }
.form-check-input:checked { background-color: var(--accent-deep); border-color: var(--accent); }

.table { --bs-table-bg: transparent; --bs-table-color: var(--ink); color: var(--ink); background: transparent; }
.table > :not(caption) > * > * { background: transparent; border-bottom-color: rgba(255,255,255,0.08); color: var(--ink); }
.table thead th { color: var(--ink-soft); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.table-responsive {
  padding: 0.35rem;
}
.table-warning, .table-warning > * { --bs-table-bg: rgba(240, 197, 106, 0.12) !important; --bs-table-accent-bg: transparent; color: #fff; }
.click-row { cursor: pointer; transition: background 0.16s ease, transform 0.16s ease; }
.click-row:hover { background: rgba(46, 230, 197, 0.12) !important; }
.status-choice,
.kpi-card,
.mobile-card {
  background-image: radial-gradient(180px circle at var(--mx, 50%) var(--my, 0%), rgba(46, 230, 197, 0.16), transparent 60%);
}

.alert { border-radius: 14px; border: 1px solid var(--line); backdrop-filter: blur(12px); }
.alert-success { background: rgba(62, 224, 164, 0.16); color: #d6ffe9; }
.alert-danger { background: rgba(255, 123, 123, 0.16); color: #ffd6d6; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  padding: 0.9rem;
  margin-bottom: 1rem;
}
.queue-count {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(46, 230, 197, 0.12);
  border: 1px solid rgba(46, 230, 197, 0.28);
  font-size: 0.82rem;
}
.days-chip {
  display: inline-flex;
  min-width: 2.4rem;
  justify-content: center;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  font-weight: 650;
}
.days-chip.hot { background: rgba(255, 123, 123, 0.18); color: #ffd0d0; }
.processed-flag {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: rgba(62, 224, 164, 0.18);
  color: #c4f8e0;
  border: 1px solid rgba(62, 224, 164, 0.32);
  white-space: nowrap;
}
.due-chip {
  display: inline-flex;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 650;
}
.due-chip.overdue { background: rgba(255, 123, 123, 0.18); color: #ffd0d0; }
.due-chip.today { background: rgba(255, 196, 72, 0.18); color: #ffd58a; }
.due-chip.upcoming { background: rgba(46, 230, 197, 0.14); color: #9cf0dc; }

.patient-nav { display: flex; align-items: center; gap: 0.4rem; }
.patient-hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}
.patient-name-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin-bottom: 0.15rem;
}
.fact-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
}
.fact {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.7rem 0.8rem;
}
.fact span { display: block; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); }
.fact strong { font-size: 0.95rem; }

.live-timer {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(46, 230, 197, 0.12);
  border: 1px solid rgba(46, 230, 197, 0.3);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}
.live-timer .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(46, 230, 197, 0.7);
  animation: pulse 1.6s infinite;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(46, 230, 197, 0); }
}

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li {
  position: relative;
  padding: 0 0 0.95rem 1.1rem;
  border-left: 1px solid rgba(46, 230, 197, 0.28);
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -5px;
  top: 0.25rem;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(46, 230, 197, 0.15);
}
.history-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.65rem;
}
.history-tags strong + strong::before {
  content: "·";
  margin-right: 0.65rem;
  color: var(--ink-soft);
  font-weight: 500;
}
}

.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.call-type-grid {
  grid-template-columns: 1fr 1fr 1fr;
}
.status-choice {
  display: block;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  color: var(--ink);
  border-radius: 14px;
  padding: 0.7rem 0.75rem;
  font-size: 0.88rem;
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.status-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.status-choice:hover {
  transform: translateY(-2px);
  background: rgba(255,255,255,0.1);
  border-color: rgba(46, 230, 197, 0.35);
}
.status-choice.active,
.status-choice:has(input:checked) {
  background: linear-gradient(180deg, rgba(46, 230, 197, 0.28), rgba(46, 230, 197, 0.1));
  border-color: rgba(46, 230, 197, 0.55);
  box-shadow: 0 10px 24px rgba(46, 230, 197, 0.18);
  color: #fff;
}

.history-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid var(--line);
  background: rgba(46, 230, 197, 0.12);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  font-weight: 650;
  font-size: 0.82rem;
  text-decoration: none;
}
.history-icon-btn:hover { color: #fff; background: rgba(46, 230, 197, 0.22); }
button.history-icon-btn { cursor: pointer; }
.history-modal {
  background: rgba(10, 28, 36, 0.92);
  border: 1px solid var(--line);
  color: var(--ink);
  backdrop-filter: blur(18px);
}
.history-modal .modal-header { border-bottom-color: var(--line); }
.history-modal .modal-footer { border-top-color: var(--line); }
.history-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}
.history-close:hover { background: rgba(255,123,123,0.25); border-color: #ff7b7b; }
.modal-content.history-modal { border-radius: 18px; }
#historyModal,
#queueHistoryModal {
  z-index: 1080;
}

.flatpickr-calendar {
  background: #10242d !important;
  border: 1px solid rgba(46, 230, 197, 0.28) !important;
  box-shadow: 0 18px 50px rgba(0,0,0,0.4) !important;
  font-family: "DM Sans", sans-serif;
}
.flatpickr-months, .flatpickr-weekdays, .flatpickr-weekday { background: transparent !important; }
.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
  background: #2ee6c5 !important;
  border-color: #2ee6c5 !important;
  color: #04231e !important;
}
.flatpickr-day:hover { background: rgba(46, 230, 197, 0.18) !important; }
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year { color: #eef6f8 !important; }
.duration-fields {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.duration-fields .form-control { max-width: 6rem; }
.office-hours {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.office-hours-label {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-right: 0.15rem;
}
.office-hours .form-select { max-width: 7.5rem; }
.office-hours-to { color: var(--ink-soft); }

hr { border-color: var(--line); opacity: 1; }
.offcanvas { background: #0c1e27; color: #fff; }
.offcanvas a { color: #e8f1f3; text-decoration: none; }
code { color: var(--accent); }

.chart-wrap { height: 360px; position: relative; }
.chart-wrap-round { height: 320px; }
.chart-wrap-wide { height: 280px; }
.chart-wrap-dash { height: 260px; }
details.card > summary { list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }

.workbook-sync { color: var(--ink-soft); }
.workbook-sync.is-ok { color: var(--ok); }
.workbook-sync.is-err { color: var(--danger); }
.prod-section-title {
  font-family: Outfit, sans-serif;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-bottom: 0.25rem;
}
.prod-section-lead {
  color: var(--ink-soft);
  font-size: 0.9rem;
  max-width: 68rem;
  margin-bottom: 0.9rem;
}
.status-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.75rem;
}
.status-tile {
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.95rem 1rem 0.9rem;
  box-shadow: var(--shadow);
}
.status-tile-bar {
  height: 4px;
  border-radius: 99px;
  margin-bottom: 0.7rem;
}
.status-tile-name { font-weight: 650; font-size: 0.92rem; }
.status-tile-count {
  font-family: Outfit, sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  line-height: 1;
}
.status-tile-share { font-size: 0.75rem; color: var(--ink-soft); margin: 0.2rem 0 0.45rem; }
.status-tile-meaning {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.4;
}

@media (max-width: 991.98px) {
  .app-sidebar { display: none; }
  .app-content { padding: 1rem; }
  .status-grid { grid-template-columns: 1fr; }
  .fact-grid { grid-template-columns: 1fr; }
  .kpi-grid-4 { grid-template-columns: 1fr 1fr; }
  .status-board { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
