:root {
  --excel-green: #107c41;
  --excel-green-dark: #0b5a2e;
  --excel-green-light: #e6f4ea;
  --excel-selection-bg: rgba(16, 124, 65, 0.11);
  --grid-border: #e2e8f0;
  --header-bg: #f8fafc;
  --header-text: #475569;
  --surface: #ffffff;
  --text-main: #0f172a;
}

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

html,
body,
#root {
  height: 100%;
  width: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-main);
  background: #f1f5f9;
  user-select: none;
}

.excel-app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
}

/* 1. Top Header Bar */
.excel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 14px;
  background: linear-gradient(90deg, #0d6534 0%, #107c41 60%, #138a49 100%);
  color: #ffffff;
  flex-shrink: 0;
  gap: 12px;
}

.excel-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.app-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  flex-shrink: 0;
}

.title-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workbook-title-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  padding: 4px 8px;
  width: 245px;
  transition: background 0.15s, border-color 0.15s;
}

.workbook-title-input:hover {
  background: rgba(255, 255, 255, 0.12);
}

.workbook-title-input:focus {
  outline: none;
  background: #ffffff;
  color: #0f172a;
  border-color: #ffffff;
}

.autosave-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.86);
  background: rgba(0, 0, 0, 0.18);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.excel-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.24);
  margin: 0 2px;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.14s ease;
}

.header-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.22);
}

.header-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.header-btn.active {
  background: #ffffff;
  color: var(--excel-green-dark);
}

.header-btn.primary-export {
  background: #ffffff;
  color: var(--excel-green-dark);
  font-weight: 600;
  border-color: #ffffff;
}

.header-btn.primary-export:hover {
  background: #f0fdf4;
}

/* 2. Formatting Toolbar */
.formatting-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f8fafc;
  border-bottom: 1px solid #cbd5e1;
  flex-shrink: 0;
  overflow-x: auto;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 3px;
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: #cbd5e1;
  margin: 0 4px;
  flex-shrink: 0;
}

.toolbar-select {
  height: 28px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  background: #ffffff;
  color: #1e293b;
  font-size: 12px;
  padding: 0 6px;
  cursor: pointer;
}

.font-family-select {
  width: 130px;
}

.font-size-select {
  width: 54px;
}

.format-select {
  width: 112px;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: #334155;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.tool-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.tool-btn.active {
  background: #dcfce7;
  border-color: #86efac;
  color: #0f5132;
}

.tool-btn.with-label {
  padding: 0 7px;
  font-size: 11.5px;
}

.color-picker-btn {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 5px;
  cursor: pointer;
  color: #334155;
}

.color-picker-btn:hover {
  background: #e2e8f0;
}

.color-picker-btn .color-bar {
  width: 16px;
  height: 3.5px;
  border-radius: 2px;
  margin-top: 2px;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.color-picker-btn input[type='color'] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

/* 3. Formula Bar & Search Row */
.formula-and-search-row {
  display: flex;
  align-items: center;
  background: #ffffff;
  border-bottom: 1px solid #cbd5e1;
  height: 34px;
  flex-shrink: 0;
}

.formula-bar {
  display: flex;
  align-items: center;
  flex: 1;
  height: 100%;
  padding: 0 8px;
  gap: 6px;
}

.name-box-wrapper {
  display: flex;
  align-items: center;
}

.name-box-input {
  width: 84px;
  height: 24px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #1e293b;
  font-family: 'JetBrains Mono', monospace;
  background: #f8fafc;
}

.name-box-input:focus {
  outline: 2px solid var(--excel-green);
  background: #ffffff;
}

.fx-dropdown-wrapper {
  position: relative;
}

.fx-button {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 24px;
  padding: 0 7px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  background: #f8fafc;
  color: #334155;
  cursor: pointer;
  font-size: 12px;
}

.fx-button:hover {
  background: #e2e8f0;
}

.fx-symbol {
  font-family: Georgia, serif;
  font-style: italic;
  font-weight: 700;
  color: var(--excel-green);
}

.fx-menu {
  position: absolute;
  top: 28px;
  left: 0;
  width: 250px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.14);
  z-index: 100;
  padding: 5px;
}

.fx-menu-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  padding: 4px 8px;
}

.fx-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 8px;
  border: none;
  background: transparent;
  border-radius: 5px;
  cursor: pointer;
  text-align: left;
}

.fx-menu-item:hover {
  background: #f1f5f9;
}

.fx-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  font-weight: 600;
  color: var(--excel-green);
}

.fx-desc {
  font-size: 11px;
  color: #64748b;
}

.formula-input {
  flex: 1;
  height: 25px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0 8px;
  font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  color: #0f172a;
}

.formula-input:focus {
  outline: none;
  border-color: var(--excel-green);
  background: #f8fafc;
}

.find-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  border-left: 1px solid #cbd5e1;
  height: 100%;
  background: #fefce8;
}

.find-icon {
  color: #854d0e;
}

.find-bar input {
  border: 1px solid #fde047;
  border-radius: 4px;
  height: 24px;
  padding: 0 8px;
  font-size: 12px;
  width: 170px;
  background: #ffffff;
}

.find-bar input:focus {
  outline: 2px solid #eab308;
}

.find-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #713f12;
  cursor: pointer;
}

/* 4. Main Spreadsheet Grid */
.spreadsheet-grid-container {
  flex: 1;
  overflow: auto;
  position: relative;
  background: #ffffff;
}

.spreadsheet-table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  width: max-content;
}

/* Sticky Top-Left Corner */
.corner-header {
  position: sticky;
  top: 0;
  left: 0;
  z-index: 30;
  width: 46px;
  min-width: 46px;
  height: 26px;
  background: #f1f5f9;
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
  cursor: pointer;
}

.corner-triangle {
  display: block;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 0 10px 10px;
  border-color: transparent transparent #94a3b8 transparent;
  margin: 10px 4px 2px auto;
}

/* Sticky Column Headers */
.col-header {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 26px;
  background: #f8fafc;
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #cbd5e1;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  text-align: center;
  cursor: pointer;
  transition: background 0.1s;
}

.col-header:hover {
  background: #e2e8f0;
}

.col-header.highlighted {
  background: #dcfce7;
  color: #0f5132;
  border-bottom: 2px solid var(--excel-green);
}

.col-header-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.col-resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 7px;
  height: 100%;
  cursor: col-resize;
  z-index: 25;
}

.col-resizer:hover {
  background: var(--excel-green);
}

/* Sticky Row Headers */
.row-header {
  position: sticky;
  left: 0;
  z-index: 15;
  width: 46px;
  min-width: 46px;
  background: #f8fafc;
  border-right: 1px solid #cbd5e1;
  border-bottom: 1px solid #e2e8f0;
  font-size: 11.5px;
  font-weight: 500;
  color: #64748b;
  text-align: center;
  cursor: pointer;
}

.row-header:hover {
  background: #e2e8f0;
}

.row-header.highlighted {
  background: #dcfce7;
  color: #0f5132;
  font-weight: 700;
  border-right: 2px solid var(--excel-green);
}

.row-header-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.row-resizer {
  position: absolute;
  bottom: -3px;
  left: 0;
  width: 100%;
  height: 6px;
  cursor: row-resize;
  z-index: 20;
}

.row-resizer:hover {
  background: var(--excel-green);
}

/* Data Cells */
.grid-cell {
  position: relative;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: cell;
  vertical-align: middle;
}

.cell-content {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.grid-cell.selected-cell {
  background-color: var(--excel-selection-bg);
}

.grid-cell.active-cell {
  background-color: #ffffff;
}

/* Selection Range Outer Box */
.grid-cell.sel-top {
  box-shadow: inset 0 2px 0 0 var(--excel-green);
}
.grid-cell.sel-bottom {
  box-shadow: inset 0 -2px 0 0 var(--excel-green);
}
.grid-cell.sel-left {
  box-shadow: inset 2px 0 0 0 var(--excel-green);
}
.grid-cell.sel-right {
  box-shadow: inset -2px 0 0 0 var(--excel-green);
}

.grid-cell.active-cell {
  outline: 2px solid var(--excel-green);
  outline-offset: -2px;
  z-index: 5;
}

.grid-cell.fill-preview-cell {
  background-color: rgba(16, 124, 65, 0.08);
  border: 1px dashed var(--excel-green);
}

/* Fill Handle Square */
.fill-handle {
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 7px;
  height: 7px;
  background: var(--excel-green);
  border: 1px solid #ffffff;
  cursor: crosshair;
  z-index: 12;
}

/* Inline Cell Editor */
.cell-inline-editor {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  padding: 0 6px;
  font-size: inherit;
  font-family: inherit;
  color: #0f172a;
  background: #ffffff;
  outline: 2px solid var(--excel-green);
  z-index: 10;
}

/* Context Menu */
.grid-context-menu {
  position: fixed;
  width: 210px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
  padding: 5px;
  z-index: 200;
}

.grid-context-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 10px;
  border: none;
  background: transparent;
  border-radius: 5px;
  font-size: 12.5px;
  color: #1e293b;
  cursor: pointer;
  text-align: left;
}

.grid-context-menu button:hover {
  background: #f1f5f9;
  color: var(--excel-green-dark);
}

.grid-context-menu kbd {
  font-size: 11px;
  color: #64748b;
  font-family: 'Inter', sans-serif;
}

.ctx-divider {
  height: 1px;
  background: #e2e8f0;
  margin: 4px 0;
}

/* 5. Bottom Sheet Tabs & Status Bar */
.sheet-tabs-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 36px;
  background: #f1f5f9;
  border-top: 1px solid #cbd5e1;
  padding: 0 12px 0 8px;
  flex-shrink: 0;
  gap: 12px;
}

.sheet-tabs-list {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 100%;
  overflow-x: auto;
}

.add-sheet-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 5px;
  border: 1px solid transparent;
  background: transparent;
  color: #475569;
  cursor: pointer;
}

.add-sheet-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.sheet-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  background: #e2e8f0;
  border: 1px solid #cbd5e1;
  border-bottom-width: 3px;
  border-radius: 6px 6px 0 0;
  font-size: 12px;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  align-self: flex-end;
  transition: background 0.12s;
}

.sheet-tab:hover {
  background: #f8fafc;
}

.sheet-tab.active {
  background: #ffffff;
  color: #0f172a;
  font-weight: 600;
}

.sheet-tab-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.sheet-rename-input {
  width: 110px;
  height: 20px;
  border: 1px solid var(--excel-green);
  border-radius: 3px;
  padding: 0 4px;
  font-size: 12px;
}

.sheet-tab-menu {
  position: absolute;
  bottom: 34px;
  left: 0;
  width: 185px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  padding: 5px;
  z-index: 150;
}

.sheet-tab-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  background: transparent;
  border-radius: 5px;
  font-size: 12px;
  color: #1e293b;
  cursor: pointer;
}

.sheet-tab-menu button:hover {
  background: #f1f5f9;
}

.sheet-tab-menu button.danger {
  color: #dc2626;
}

.tab-color-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  color: #475569;
}

.tab-swatches {
  display: flex;
  align-items: center;
  gap: 4px;
}

.swatch-dot {
  width: 14px !important;
  height: 14px !important;
  padding: 0 !important;
  border-radius: 999px !important;
  border: 1px solid rgba(0, 0, 0, 0.15) !important;
}

/* Status Bar Metrics */
.status-bar-metrics {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  color: #475569;
  white-space: nowrap;
}

.metric-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  background: #e2e8f0;
}

.metric-pill.highlight {
  background: #dcfce7;
  color: #0f5132;
  font-weight: 600;
}

.metric-label {
  color: #64748b;
}

.metric-pill.highlight .metric-label {
  color: #166534;
}

.metric-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

.status-ready {
  color: #64748b;
  font-size: 11.5px;
}


/* ==========================================================================
   6. Dental Clinic Role Banner & Admin / Sales Girl Dashboards
   ========================================================================== */
.clinic-dashboard-banner {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid #cbd5e1;
  flex-shrink: 0;
}

.clinic-dashboard-banner.admin-mode {
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.clinic-dashboard-banner.sales-mode {
  background: linear-gradient(180deg, #eff6ff 0%, #f8fafc 100%);
}

.role-status-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  border-bottom: 1px solid #e2e8f0;
  gap: 10px;
}

.role-strip-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.role-pill.admin-pill {
  background: #0f766e;
  color: #ffffff;
}

.role-pill.sales-pill {
  background: #1d4ed8;
  color: #ffffff;
}

.signed-in-user {
  font-size: 12px;
  color: #334155;
}

.sheet-readonly-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 11px;
  font-weight: 600;
}

.role-strip-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.switch-role-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px;
  border-radius: 6px;
  border: 1px solid #0f766e;
  background: #ffffff;
  color: #0f766e;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s;
}

.switch-role-btn:hover {
  background: #0f766e;
  color: #ffffff;
}

.toggle-dash-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
}

.toggle-dash-btn:hover {
  background: #e2e8f0;
}

.dashboard-expanded-content {
  padding: 10px 14px;
}

/* Admin Dashboard Grid */
.admin-dashboard-grid {
  display: grid;
  grid-template-columns: 1.55fr 1fr 1.25fr;
  gap: 12px;
  align-items: stretch;
}

.admin-kpi-cards {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.kpi-card {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.kpi-card.emerald {
  border-left: 3px solid #107c41;
  background: #f0fdf4;
}

.kpi-card.danger {
  border-left: 3px solid #dc2626;
  background: #fef2f2;
}

.kpi-card.purple {
  border-left: 3px solid #7c3aed;
  background: #f5f3ff;
}

.kpi-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  color: #475569;
}

.kpi-value {
  font-size: 17px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: #0f172a;
  margin: 3px 0;
}

.kpi-sub {
  font-size: 10.5px;
  color: #64748b;
}

.admin-panel-box {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.panel-box-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: #1e293b;
  padding-bottom: 4px;
  border-bottom: 1px solid #e2e8f0;
}

.sales-girl-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sales-girl-stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  padding: 4px 6px;
  border-radius: 5px;
  background: #f8fafc;
}

.sg-name {
  font-weight: 600;
  color: #0f172a;
}

.sg-patients {
  color: #64748b;
  font-size: 11px;
}

.sg-amount {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  color: #107c41;
}

.sheet-access-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 98px;
  overflow-y: auto;
}

.sheet-access-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 2px 4px;
  border-radius: 5px;
}

.sheet-access-row.active-row {
  background: #f1f5f9;
}

.sheet-jump-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  color: #1e293b;
  cursor: pointer;
  text-align: left;
}

.sheet-jump-btn:hover {
  color: #107c41;
  text-decoration: underline;
}

.sheet-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex-shrink: 0;
}

.access-select {
  height: 22px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  padding: 0 4px;
  cursor: pointer;
}

.access-select.sales_edit {
  background: #dcfce7;
  color: #166534;
  border-color: #86efac;
}

.access-select.sales_view {
  background: #dbeafe;
  color: #1e40af;
  border-color: #93c5fd;
}

.access-select.admin_only {
  background: #fee2e2;
  color: #991b1b;
  border-color: #fca5a5;
}

/* Sales Girl Dashboard Bar */
.sales-dashboard-grid {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.sales-personal-stats {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sales-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  font-size: 12px;
  color: #334155;
}

.sales-stat-pill.highlight {
  background: #dcfce7;
  border-color: #86efac;
  color: #0f5132;
}

.quick-sale-form {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  background: #ffffff;
  padding: 5px 10px;
  border-radius: 7px;
  border: 1px solid #bfdbfe;
  flex-wrap: wrap;
}

.quick-form-title {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: #1e40af;
  white-space: nowrap;
}

.quick-sale-form input[type='text'],
.quick-sale-form select {
  height: 27px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 0 7px;
  font-size: 12px;
}

.quick-amount-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: #475569;
}

.quick-amount-field input {
  width: 68px;
  height: 27px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 0 6px;
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
}

.quick-add-submit {
  height: 27px;
  padding: 0 12px;
  border: none;
  border-radius: 5px;
  background: #107c41;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.quick-add-submit:hover {
  background: #0d6534;
}

/* Sheet Tab Access Badges */
.tab-access-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 10px;
}

.tab-access-badge.admin-lock {
  background: #fee2e2;
  color: #b91c1c;
}

.tab-access-badge.view-only {
  background: #dbeafe;
  color: #1d4ed8;
}

.tab-menu-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  color: #64748b;
  padding: 2px 8px;
}

/* ==========================================================================
   7. Role Login & Switcher Modal
   ========================================================================== */
.login-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
}

.login-modal-card {
  width: 100%;
  max-width: 780px;
  background: #ffffff;
  border-radius: 14px;
  border: 1px solid #cbd5e1;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.28);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-modal-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
  margin-top: 4px;
}

.login-modal-header p {
  font-size: 13px;
  color: #475569;
  margin-top: 3px;
}

.clinic-brand-badge {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 700;
  color: #0f766e;
  background: #ccfbf1;
  padding: 3px 10px;
  border-radius: 999px;
}

.login-role-columns {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 14px;
}

.role-section {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.role-section-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: #1e293b;
  margin-bottom: 2px;
}

.account-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  cursor: pointer;
  transition: all 0.14s;
}

.account-card:hover {
  border-color: #94a3b8;
}

.account-card.selected {
  border-color: #107c41;
  background: #f0fdf4;
  box-shadow: 0 0 0 2px rgba(16, 124, 65, 0.14);
}

.account-avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.account-info {
  flex: 1;
  min-width: 0;
}

.account-name {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.account-sub {
  font-size: 11px;
  color: #64748b;
}

.account-perms {
  font-size: 10.5px;
  color: #0f766e;
  font-weight: 500;
  margin-top: 2px;
}

.instant-login-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 9px;
  border-radius: 6px;
  border: none;
  background: #0f766e;
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.instant-login-chip.sales-chip {
  background: #2563eb;
}

.instant-login-chip:hover {
  opacity: 0.92;
}

.pin-login-form {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: #f1f5f9;
  border-radius: 9px;
  border: 1px solid #cbd5e1;
  flex-wrap: wrap;
}

.pin-form-left {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: #334155;
}

.pin-form-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pin-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 0 8px;
  height: 32px;
}

.pin-input-wrap input {
  border: none;
  outline: none;
  font-size: 13px;
  width: 140px;
  font-family: 'JetBrains Mono', monospace;
}

.pin-submit-btn {
  height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  border: none;
  background: #107c41;
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.pin-cancel-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #475569;
  font-size: 12.5px;
  cursor: pointer;
}

.login-error-msg {
  font-size: 12px;
  font-weight: 600;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 7px 12px;
  border-radius: 6px;
}


/* ==========================================================================
   8. Multi-Clinic Switcher (Reign, Busybit, Prodent, Omabod) & Quick Call Bar
   ========================================================================== */
.clinic-switcher-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: #0f172a;
  color: #f8fafc;
  gap: 10px;
  flex-shrink: 0;
  overflow-x: auto;
}

.clinic-tabs-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.clinic-bar-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
  margin-right: 4px;
  white-space: nowrap;
}

.clinic-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
  white-space: nowrap;
}

.clinic-pill-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.clinic-pill-btn.active {
  background: #ffffff;
  color: #0f172a;
  border-color: #ffffff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.clinic-color-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  flex-shrink: 0;
}

.clinic-tab-count {
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.12);
  font-family: 'JetBrains Mono', monospace;
}

.clinic-pill-btn:not(.active) .clinic-tab-count {
  background: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
}

.gsheet-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.gsheet-link-btn:hover {
  background: rgba(16, 185, 129, 0.28);
  color: #ffffff;
}

/* Admin Clinic Assignment Matrix */
.staff-assignment-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 105px;
  overflow-y: auto;
}

.staff-assign-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  background: #f8fafc;
  font-size: 11.5px;
}

.staff-assign-chips {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.clinic-assign-toggle {
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #64748b;
  font-size: 10.5px;
  font-weight: 600;
  cursor: pointer;
}

.clinic-assign-toggle.assigned {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

/* Sales Girl Active Lead Call & Feedback Bar */
.selected-lead-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #ffffff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 6px 10px;
  flex: 1;
  flex-wrap: wrap;
}

.lead-summary-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #1e293b;
  flex-wrap: wrap;
}

.lead-badge-name {
  font-weight: 700;
  color: #0f172a;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  padding: 2px 8px;
  border-radius: 5px;
}

.lead-phone-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11.5px;
  font-weight: 600;
  color: #15803d;
  background: #dcfce7;
  padding: 2px 8px;
  border-radius: 5px;
  text-decoration: none;
}

.lead-phone-link:hover {
  background: #bbf7d0;
}

.lead-quick-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.quick-status-btn {
  height: 27px;
  padding: 0 9px;
  border-radius: 5px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #1e293b;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}

.quick-status-btn.called {
  background: #dbeafe;
  border-color: #93c5fd;
  color: #1e40af;
}

.quick-status-btn.scheduled {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.quick-status-btn.unreachable {
  background: #fef3c7;
  border-color: #fde68a;
  color: #92400e;
}

.quick-status-btn:hover {
  filter: brightness(0.95);
}

.feedback-inline-form {
  display: flex;
  align-items: center;
  gap: 5px;
}

.feedback-inline-form input {
  height: 27px;
  width: 210px;
  border: 1px solid #cbd5e1;
  border-radius: 5px;
  padding: 0 8px;
  font-size: 12px;
}


/* ==========================================================================
   9. Live Google Sheets Auto-Sync Indicator & New Booking Toast
   ========================================================================== */
.live-sync-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: #ecfdf5;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.22);
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
}

.live-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.28);
  animation: pulseDot 1.8s infinite;
}

.live-pulse-dot.paused {
  background: #fbbf24;
  box-shadow: none;
  animation: none;
}

@keyframes pulseDot {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(74, 222, 128, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(74, 222, 128, 0);
  }
}

.new-booking-toast {
  position: fixed;
  top: 58px;
  right: 18px;
  z-index: 600;
  background: #065f46;
  color: #ffffff;
  border: 1px solid #34d399;
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.28);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  animation: slideInToast 0.25s ease-out;
}

@keyframes slideInToast {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}


/* ==========================================================================
   10. Secure Login Screen & Hosted Portal Extras
   ========================================================================== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #0f766e 55%, #107c41 100%);
  padding: 20px;
  user-select: text;
}

.login-box {
  width: 100%;
  max-width: 400px;
  background: #ffffff;
  border-radius: 16px;
  padding: 30px 28px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-box h1 {
  font-size: 21px;
  color: #0f172a;
}

.login-box p {
  font-size: 13px;
  color: #475569;
}

.login-box label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #334155;
}

.login-box input {
  height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 14px;
}

.login-box input:focus {
  outline: 2px solid #107c41;
  border-color: #107c41;
}

.login-box button {
  height: 42px;
  border: none;
  border-radius: 8px;
  background: #107c41;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.login-box button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.login-clinics-hint {
  font-size: 11.5px;
  color: #64748b;
  text-align: center;
}

.logout-btn {
  background: rgba(0, 0, 0, 0.22) !important;
}

.error-toast {
  background: #7f1d1d !important;
  border-color: #f87171 !important;
}

.empty-state {
  padding: 40px;
  text-align: center;
  color: #64748b;
  font-size: 14px;
}

.clinic-summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11.5px;
}

.clinic-summary-table td,
.clinic-summary-table th {
  padding: 3px 6px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

.clinic-summary-table th {
  color: #64748b;
  font-weight: 600;
}

.clinic-summary-table td.num {
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

.truncation-note {
  font-size: 11px;
  color: #92400e;
  background: #fef3c7;
  padding: 2px 8px;
  border-radius: 4px;
}


/* ==========================================================================
   11. Responsive Layout — Cards View, Mobile Action Sheet, Breakpoints
   ========================================================================== */
.excel-app-shell {
  height: 100vh;
  height: 100dvh;
}

.portal-title {
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.portal-header .excel-header-left,
.portal-header .title-container {
  min-width: 0;
}

.row-count-note {
  font-size: 11.5px;
  color: #475569;
}

/* Search + view toggle (in clinic bar) */
.search-and-view {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.search-box input {
  height: 30px;
  width: 240px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  padding: 0 10px;
  font-size: 13px;
}

.search-box input::placeholder {
  color: #94a3b8;
}

.search-box input:focus {
  outline: 2px solid #4ade80;
  background: rgba(255, 255, 255, 0.16);
}

.view-toggle {
  display: inline-flex;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  overflow: hidden;
}

.view-toggle button {
  height: 30px;
  padding: 0 10px;
  border: none;
  background: transparent;
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.view-toggle button.active {
  background: #ffffff;
  color: #0f172a;
}

/* Cards view */
.cards-container {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #f1f5f9;
  padding: 12px;
  user-select: text;
}

.cards-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
  align-items: start;
}

.lead-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #107c41;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  cursor: pointer;
  transition: box-shadow 0.12s, border-color 0.12s;
}

.lead-card.selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.lead-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.lead-card-name {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  word-break: break-word;
}

.lead-card-row {
  font-size: 11px;
  font-weight: 600;
  color: #94a3b8;
  font-family: 'JetBrains Mono', monospace;
}

.lead-card-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
  flex-shrink: 0;
  max-width: 50%;
}

.status-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  white-space: nowrap;
}

.lead-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 12.5px;
  color: #475569;
}

.lead-card-concern {
  font-size: 13px;
  color: #1e293b;
  line-height: 1.4;
}

.lead-card-feedback {
  font-size: 12.5px;
  color: #475569;
  background: #f8fafc;
  border-radius: 6px;
  padding: 6px 8px;
  white-space: pre-line;
}

.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lead-card-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  color: #1e293b;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.card-btn.call {
  background: #e0e7ff;
  border-color: #c7d2fe;
  color: #3730a3;
}

.card-btn.wa {
  background: #dcfce7;
  border-color: #86efac;
  color: #166534;
}

.card-btn.save {
  background: #107c41;
  border-color: #107c41;
  color: #ffffff;
}

.card-btn.more {
  margin-left: auto;
}

.lead-card-details {
  border-top: 1px solid #e2e8f0;
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: default;
}

.detail-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.detail-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #64748b;
}

.detail-edit {
  border: none;
  background: transparent;
  color: #2563eb;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0 4px 8px;
  text-transform: none;
  letter-spacing: 0;
}

.detail-value {
  font-size: 13.5px;
  color: #0f172a;
  white-space: pre-line;
  word-break: break-word;
}

.detail-editor textarea {
  width: 100%;
  border: 1px solid #93c5fd;
  border-radius: 8px;
  padding: 8px;
  font-size: 16px;
  font-family: inherit;
  resize: vertical;
}

.detail-editor-btns {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}

.detail-editor-btns .card-btn.more {
  margin-left: 0;
}

/* Mobile bottom action sheet */
.mobile-action-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 400;
  background: #ffffff;
  border-top: 1px solid #cbd5e1;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -10px 30px rgba(15, 23, 42, 0.18);
  padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: sheetUp 0.18s ease-out;
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.sheet-lead {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sheet-lead b {
  font-size: 15px;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sheet-lead span {
  font-size: 12px;
  color: #64748b;
}

.sheet-close {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  font-size: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.sheet-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.sheet-actions .quick-status-btn {
  height: 44px;
  font-size: 13px;
}

.mobile-action-sheet .feedback-inline-form input {
  flex: 1;
  width: auto;
  height: 44px;
  font-size: 16px;
}

.mobile-action-sheet .feedback-inline-form .quick-add-submit {
  height: 44px;
  padding: 0 16px;
}

.excel-app-shell:has(.mobile-action-sheet) .cards-container {
  padding-bottom: 240px;
}

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

/* ---------- Tablet (≤ 1100px) ---------- */
@media (max-width: 1100px) {
  .admin-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .admin-kpi-cards {
    grid-template-columns: repeat(4, 1fr);
  }

  .search-box input {
    width: 180px;
  }

  .clinic-pill-btn {
    padding: 5px 10px;
  }
}

/* ---------- Mobile (≤ 768px) ---------- */
@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }

  .excel-header {
    height: auto;
    min-height: 50px;
    padding: 6px 10px;
    padding-top: calc(6px + env(safe-area-inset-top));
    gap: 8px;
  }

  .app-logo {
    width: 30px;
    height: 30px;
  }

  .title-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }

  .portal-title {
    font-size: 14px;
    max-width: 60vw;
  }

  .portal-title-tab {
    display: none;
  }

  .live-sync-pill {
    padding: 1px 8px;
    font-size: 10.5px;
  }

  .excel-header-actions {
    gap: 6px;
  }

  .header-btn {
    min-width: 38px;
    min-height: 36px;
    justify-content: center;
    padding: 4px 9px;
    font-size: 15px;
  }

  .clinic-switcher-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 8px 10px;
    overflow: visible;
  }

  .clinic-tabs-group {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }

  .clinic-tabs-group::-webkit-scrollbar {
    display: none;
  }

  .clinic-pill-btn {
    min-height: 36px;
    flex-shrink: 0;
  }

  .search-and-view {
    width: 100%;
  }

  .search-box {
    flex: 1;
  }

  .search-box input {
    width: 100%;
    height: 38px;
    font-size: 16px;
  }

  .view-toggle button {
    height: 38px;
  }

  .role-status-strip {
    padding: 6px 10px;
    flex-wrap: wrap;
  }

  .role-strip-left {
    gap: 6px;
  }

  .dashboard-expanded-content {
    padding: 8px 10px;
  }

  .admin-kpi-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }

  .kpi-value {
    font-size: 20px;
  }

  .cards-container {
    padding: 8px;
  }

  .cards-list {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .sheet-tabs-footer {
    height: auto;
    min-height: 46px;
    padding: 4px 6px calc(4px + env(safe-area-inset-bottom));
  }

  .sheet-tabs-list {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100%;
  }

  .sheet-tabs-list::-webkit-scrollbar {
    display: none;
  }

  .sheet-tab {
    height: 36px;
    flex-shrink: 0;
    font-size: 12.5px;
    white-space: nowrap;
  }

  /* Grid view on phones (optional) */
  .corner-header,
  .row-header {
    width: 36px;
    min-width: 36px;
  }

  .new-booking-toast {
    left: 10px;
    right: 10px;
    top: calc(10px + env(safe-area-inset-top));
    font-size: 13px;
  }

  /* Prevent iOS zoom on focus */
  input,
  select,
  textarea {
    font-size: 16px;
  }

  .login-box {
    padding: 24px 20px;
  }

  .login-box input {
    font-size: 16px;
    height: 44px;
  }
}

/* ---------- Small phones (≤ 380px) ---------- */
@media (max-width: 380px) {
  .live-sync-text {
    display: none;
  }

  .sheet-actions .quick-status-btn {
    font-size: 12px;
    padding: 0 4px;
  }

  .view-toggle button {
    padding: 0 8px;
  }
}


/* ==========================================================================
   12. Responsive polish (from device screenshots)
   ========================================================================== */
/* Grid: single-line cells so rows stay compact (full text in formula bar / tooltip) */
.spreadsheet-table .grid-cell {
  white-space: nowrap;
  height: 28px;
  max-height: 28px;
}

.spreadsheet-table .grid-cell .cell-content {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Header buttons never wrap */
.excel-header-actions > * {
  white-space: nowrap;
  flex-shrink: 0;
}

.live-sync-pill {
  white-space: nowrap;
}

.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Sheet tabs: one line, horizontal scroll on every screen size */
.sheet-tabs-list {
  overflow-x: auto;
  scrollbar-width: thin;
  min-width: 0;
}

.sheet-tab {
  white-space: nowrap;
  flex-shrink: 0;
}

/* Desktop admin dashboard: KPIs left, clinic table right */
.admin-dashboard-grid {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  align-items: start;
}

.admin-kpi-cards {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi-card {
  min-height: 92px;
}

/* ---------- Tablet (≤ 1100px) ---------- */
@media (max-width: 1100px) {
  .hide-tablet {
    display: none !important;
  }

  .admin-dashboard-grid {
    grid-template-columns: 1fr;
  }

  .portal-title-tab {
    display: none;
  }
}

/* ---------- Mobile (≤ 768px) ---------- */
@media (max-width: 768px) {
  .clinic-tabs-group.single-clinic {
    display: none;
  }

  .admin-kpi-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-card {
    min-height: 0;
  }
}
