@import url('https://fonts.googleapis.com/css2?family=Heebo:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  --bg-app: #f4f6f9;
  --bg-surface: #ffffff;
  --bg-subtle: #f8fafc;
  --bg-dark: #0f172a;
  --bg-dark-elevated: #1e293b;

  --text-main: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --brand-primary: #0d9488;
  --brand-primary-hover: #0f766e;
  --brand-primary-soft: #ccfbf1;
  --brand-accent: #4f46e5;
  --brand-accent-soft: #eef2ff;

  --success: #10b981;
  --success-soft: #ecfdf5;
  --warning: #f59e0b;
  --warning-soft: #fffbeb;
  --danger: #ef4444;
  --danger-soft: #fef2f2;

  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 10px 28px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 22px 48px rgba(15, 23, 42, 0.14);
}

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

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Heebo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}

body.drawer-open {
  overflow: hidden;
}

button, a, .btn, .nav-item, .tab-btn, .emp-nav-btn, .quick-tag, .shift-chip {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.mono-num {
  font-family: 'JetBrains Mono', 'Heebo', monospace;
  font-variant-numeric: tabular-nums;
}

a {
  color: var(--brand-primary);
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: 0.95rem;
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
  text-decoration: none;
}

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

.btn-primary {
  background: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(13, 148, 136, 0.25);
}
.btn-primary:hover:not(:disabled) {
  background: var(--brand-primary-hover);
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--brand-accent);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.22);
}
.btn-accent:hover:not(:disabled) {
  background: #4338ca;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--border-strong);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: #94a3b8;
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}
.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-danger-ghost {
  background: var(--danger-soft);
  color: #b91c1c;
  border-color: #fecaca;
}
.btn-danger-ghost:hover:not(:disabled) {
  background: #fee2e2;
}

.btn-whatsapp {
  background: #16a34a;
  color: #ffffff;
  border-color: #15803d;
  box-shadow: 0 2px 8px rgba(22, 163, 74, 0.25);
}
.btn-whatsapp:hover:not(:disabled) {
  background: #15803d;
  color: #ffffff;
  transform: translateY(-1px);
}

/* ==================== ONBOARDING LAUNCHPAD ==================== */
.onboarding-card {
  background: linear-gradient(135deg, #0f172a 0%, #134e4a 100%);
  color: #f8fafc;
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  margin-bottom: 22px;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(45, 212, 191, 0.3);
}

.onboarding-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.onboarding-progress-track {
  height: 8px;
  background: rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}

.onboarding-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2dd4bf, #38bdf8);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.onboarding-steps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.onboarding-step-item {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 14px 15px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.onboarding-step-item.done {
  background: rgba(16, 185, 129, 0.17);
  border-color: rgba(52, 211, 153, 0.48);
}

@media (max-width: 900px) {
  .onboarding-steps-grid {
    grid-template-columns: 1fr;
  }
  .onboarding-card {
    padding: 16px 14px;
  }
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.84rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 14px 24px;
  font-size: 1.05rem;
  border-radius: 14px;
}

.btn-block {
  width: 100%;
}

/* ==================== FORMS ==================== */
.form-group {
  margin-bottom: 14px;
}

.form-label {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 13px;
  background: var(--bg-surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.14);
}

textarea.form-control {
  resize: vertical;
  min-height: 76px;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

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

/* ==================== AVATARS & BADGES ==================== */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  color: #ffffff;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
  background: var(--brand-accent);
  position: relative;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-live {
  background: var(--success-soft);
  color: #047857;
  border: 1px solid #a7f3d0;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulseDot 1.8s infinite;
}

@keyframes pulseDot {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.65); }
  70% { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.badge-free {
  background: rgba(45, 212, 191, 0.15);
  color: #5eead4;
  border: 1px solid rgba(45, 212, 191, 0.35);
  padding: 5px 13px;
  font-size: 0.84rem;
}

.badge-note {
  background: var(--warning-soft);
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-neutral {
  background: #f1f5f9;
  color: #334155;
}

.badge-danger {
  background: var(--danger-soft);
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* ==================== LANDING / AUTH PORTAL ==================== */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  background: var(--bg-dark);
}

.auth-hero {
  padding: 52px 56px;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(circle at 85% 15%, rgba(13, 148, 136, 0.28), transparent 45%),
    radial-gradient(circle at 15% 85%, rgba(79, 70, 229, 0.25), transparent 50%),
    linear-gradient(145deg, #0b1120 0%, #0f172a 60%, #111c33 100%);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

.brand-name {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.hero-headline {
  font-size: 2.55rem;
  font-weight: 800;
  line-height: 1.18;
  margin: 22px 0 16px;
}

.hero-headline span {
  color: #2dd4bf;
}

.hero-sub {
  font-size: 1.08rem;
  color: #cbd5e1;
  line-height: 1.65;
  max-width: 560px;
  margin-bottom: 32px;
}

.feature-list {
  display: grid;
  gap: 16px;
  max-width: 560px;
}

.feature-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px 18px;
  border-radius: var(--radius-md);
}

.feature-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(45, 212, 191, 0.16);
  color: #2dd4bf;
  display: grid;
  place-items: center;
  font-weight: 800;
  flex-shrink: 0;
}

.feature-item h4 {
  margin: 0 0 3px;
  font-size: 0.98rem;
  color: #f8fafc;
}

.feature-item p {
  margin: 0;
  font-size: 0.86rem;
  color: #94a3b8;
  line-height: 1.45;
}

.auth-panel {
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 36px 28px;
}

.auth-card {
  width: 100%;
  max-width: 470px;
}

.tabs-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  background: #f1f5f9;
  padding: 5px;
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 9px 8px;
  border: none;
  background: transparent;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--brand-primary);
  box-shadow: var(--shadow-xs);
}

@media (max-width: 980px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }
  .auth-hero {
    padding: 32px 24px;
  }
  .hero-headline {
    font-size: 1.9rem;
  }
}

/* ==================== MANAGER DASHBOARD SHELL ==================== */
.manager-layout {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-dark);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  border-inline-end: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 16px;
}

.biz-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 18px;
}

.biz-pill-name {
  font-weight: 700;
  font-size: 0.98rem;
  margin-bottom: 3px;
}

.biz-pill-code {
  font-size: 0.8rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 13px;
  border-radius: 10px;
  color: #cbd5e1;
  background: transparent;
  border: none;
  font-weight: 600;
  font-size: 0.93rem;
  cursor: pointer;
  text-align: right;
  transition: all 0.15s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
}

.nav-item.active {
  background: var(--brand-primary);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.35);
}

.nav-item-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-badge {
  background: #f59e0b;
  color: #0f172a;
  font-size: 0.74rem;
  font-weight: 800;
  padding: 1px 7px;
  border-radius: 999px;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 14px;
  display: grid;
  gap: 8px;
}

.main-area {
  padding: 28px 34px 48px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-title {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-main);
}

.page-subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.93rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Mobile topbar & backdrop for Manager */
.mobile-topbar {
  display: none;
  background: var(--bg-dark);
  color: #fff;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 45;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.62);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 55;
}

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

.sidebar-close-btn {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.mgr-mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.08);
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom, 0px));
  z-index: 44;
}

.mgr-mnav-btn {
  background: none;
  border: none;
  padding: 5px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 10px;
  min-height: 44px;
}

.mgr-mnav-btn.active {
  color: var(--brand-primary);
  background: rgba(13, 148, 136, 0.09);
}

.mgr-mnav-icon {
  font-size: 1.12rem;
  line-height: 1.1;
}

.mgr-mnav-dot {
  position: absolute;
  top: 5px;
  inset-inline-end: 24%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 2px #fff;
}

@media (max-width: 1024px) {
  .manager-layout {
    grid-template-columns: 1fr;
  }
  .mobile-topbar {
    display: flex;
  }
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(86vw, 300px);
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-top: calc(18px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    z-index: 60;
    transform: translateX(104%);
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s linear 0.24s;
    box-shadow: -16px 0 40px rgba(0, 0, 0, 0.45);
  }
  .sidebar.open {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1), visibility 0s;
  }
  .sidebar-close-btn {
    display: inline-flex;
  }
  .main-area {
    padding: 18px 14px 44px;
  }
}

/* ==================== CARDS & KPI GRID ==================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
}

.kpi-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.15;
}

.kpi-foot {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.card-body {
  padding: 20px;
}

/* ==================== TABLES ==================== */
.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

.data-table th {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  text-align: right;
}

.data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.data-table tr:hover td {
  background: #fafcff;
}

/* ==================== WEEKLY ROSTER BOARD ==================== */
.roster-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(118px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.roster-day-col {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  min-height: 290px;
}

.roster-day-col.is-today {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.12);
}

.roster-day-head {
  padding: 10px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  border-radius: 11px 11px 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.roster-day-name {
  font-weight: 700;
  font-size: 0.92rem;
}

.roster-day-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.roster-shifts-list {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.shift-chip {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--brand-accent);
  border-radius: 9px;
  padding: 9px 10px;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}

.shift-chip:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.shift-chip-top {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
}

.shift-chip-name {
  font-weight: 700;
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shift-chip-time {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--brand-primary-hover);
}

.shift-chip-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 3px;
}

/* ==================== NOTE BOXES ==================== */
.note-bubble {
  background: var(--warning-soft);
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 10px 13px;
  font-size: 0.87rem;
  color: #78350f;
  line-height: 1.45;
  white-space: pre-wrap;
}

.note-bubble.unread {
  border-inline-start: 4px solid var(--warning);
}

.manager-reply-bubble {
  background: var(--brand-accent-soft);
  border: 1px solid #c7d2fe;
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 0.82rem;
  color: #312e81;
  margin-top: 6px;
}

/* ==================== CHARTS / BARS ==================== */
.bar-row {
  margin-bottom: 12px;
}
.bar-row-head {
  display: flex;
  justify-content: space-between;
  font-size: 0.86rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.bar-track {
  height: 10px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-accent));
  border-radius: 999px;
}

/* ==================== MODALS ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 100;
}

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

.modal-card {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.16s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
}

.modal-close {
  background: #f1f5f9;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-weight: 700;
  color: var(--text-secondary);
}

.modal-body {
  padding: 22px;
}

.modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Avatar Uploader Box */
.avatar-upload-box {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px;
  background: var(--bg-subtle);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

/* ==================== EMPLOYEE MOBILE/PWA APP ==================== */
.emp-app-body {
  background: #0f172a;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
}

.emp-phone-frame {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-app);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.45);
  position: relative;
}

.emp-topbar {
  background: linear-gradient(135deg, #0f172a 0%, #134e4a 100%);
  color: #ffffff;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 18px 22px;
  border-radius: 0 0 24px 24px;
}

.emp-content {
  flex: 1;
  padding: 16px 14px calc(94px + env(safe-area-inset-bottom, 0px));
}

.clock-hero-card {
  background: var(--bg-surface);
  border-radius: 22px;
  padding: 22px 18px;
  box-shadow: var(--shadow-md);
  text-align: center;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.live-timer-display {
  font-size: clamp(2.05rem, 9.5vw, 2.75rem);
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-main);
  margin: 10px 0 6px;
}

.btn-clock-in {
  width: 100%;
  padding: 18px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, #10b981 0%, #0d9488 100%);
  color: #ffffff;
  font-size: 1.22rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(16, 185, 129, 0.32);
  transition: transform 0.14s;
}
.btn-clock-in:active {
  transform: scale(0.98);
}

.btn-clock-out {
  width: 100%;
  padding: 18px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #ffffff;
  font-size: 1.22rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(239, 68, 68, 0.32);
}

.quick-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 12px;
}

.quick-tag {
  background: #f1f5f9;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
}
.quick-tag:hover {
  background: var(--brand-primary-soft);
  color: var(--brand-primary-hover);
  border-color: #5eead4;
}

.emp-bottom-nav {
  position: fixed;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 6px 6px calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 30;
}

.emp-nav-btn {
  background: none;
  border: none;
  padding: 6px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 10px;
  min-height: 46px;
}

.emp-nav-btn.active {
  color: var(--brand-primary);
  background: rgba(13, 148, 136, 0.08);
}

/* ==================== TOASTS ==================== */
.toast-container {
  position: fixed;
  bottom: calc(22px + env(safe-area-inset-bottom, 0px));
  inset-inline-start: 16px;
  inset-inline-end: 16px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  z-index: 200;
}

.toast {
  pointer-events: auto;
  max-width: 100%;
  background: var(--bg-dark);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: var(--shadow-md);
  border-inline-start: 4px solid var(--brand-primary);
  animation: modalIn 0.18s ease-out;
}
.toast.error {
  border-inline-start-color: var(--danger);
}

/* ==================== UNIVERSAL SMARTPHONE ADAPTATION ==================== */
@media (max-width: 768px) {
  /* Prevent iOS Safari automatic page zoom when focusing inputs (< 16px) */
  input, select, textarea, .form-control {
    font-size: 16px !important;
  }

  .form-control {
    min-height: 44px;
  }

  /* Landing & Registration / Login Mobile Polish */
  .auth-shell {
    min-height: 100dvh;
  }
  .auth-panel {
    order: 1;
    padding: calc(20px + env(safe-area-inset-top, 0px)) 16px 26px;
  }
  .auth-hero {
    order: 2;
    padding: 26px 16px calc(28px + env(safe-area-inset-bottom, 0px));
  }
  .brand-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .hero-headline {
    font-size: 1.55rem;
    margin: 14px 0 10px;
  }
  .hero-sub {
    font-size: 0.94rem;
    margin-bottom: 18px;
  }
  .tabs-bar {
    gap: 4px;
    padding: 4px;
    margin-bottom: 18px;
  }
  .tab-btn {
    font-size: 0.78rem;
    padding: 9px 4px;
    line-height: 1.2;
    white-space: normal;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  /* Manager Mobile Bottom Nav & Spacing */
  .mgr-mobile-bottom-nav {
    display: grid;
  }
  .main-area {
    padding: 16px 12px calc(88px + env(safe-area-inset-bottom, 0px));
  }
  .page-header {
    gap: 12px;
    margin-bottom: 16px;
  }
  .page-title {
    font-size: 1.32rem;
    line-height: 1.25;
  }
  .page-subtitle {
    font-size: 0.85rem;
  }
  .header-actions {
    width: 100%;
    gap: 8px;
  }
  .header-actions .btn {
    flex: 1 1 calc(50% - 8px);
    min-height: 42px;
    padding: 9px 12px;
    font-size: 0.85rem;
    white-space: normal;
    text-align: center;
  }

  /* KPI Grid: 2 crisp cards per row on phones */
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 16px;
  }
  .kpi-card {
    padding: 13px 14px;
  }
  .kpi-value {
    font-size: 1.42rem;
  }

  .card-header {
    padding: 13px 14px;
  }
  .card-body {
    padding: 14px;
  }
  #empSearchInput {
    max-width: 100% !important;
    width: 100%;
  }

  /* Weekly Shift Roster: Vertical Day Stack on Smartphones */
  .roster-grid {
    grid-template-columns: 1fr;
    overflow-x: visible;
    gap: 12px;
  }
  .roster-day-col {
    min-height: auto;
  }

  /* Touch-friendly horizontal scroll tables */
  .table-wrap {
    -webkit-overflow-scrolling: touch;
  }
  .data-table th,
  .data-table td {
    padding: 10px 10px;
    font-size: 0.83rem;
  }

  /* Native-like Bottom-Sheet Modals on Smartphones */
  .modal-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .modal-card {
    max-width: 100% !important;
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 22px 22px 0 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .modal-header {
    padding: 14px 16px;
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    z-index: 5;
  }
  .modal-close {
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }
  .modal-body {
    padding: 16px;
  }
  .modal-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
  }
  .modal-footer .btn {
    flex: 1 1 auto;
  }

  .avatar-upload-box {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .toast-container {
    bottom: calc(78px + env(safe-area-inset-bottom, 0px));
  }
}

/* Ultra-narrow smartphones (iPhone SE / Galaxy Fold outer display <= 370px) */
@media (max-width: 370px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .header-actions .btn {
    flex: 1 1 100%;
  }
  #restaurantQrPreviewBox,
  #qrCodeBox {
    width: 190px !important;
    height: 190px !important;
  }
  #loginInstallBanner {
    flex-direction: column;
    align-items: stretch !important;
    text-align: center;
  }
}

/* ==================== PRINT ==================== */
@media print {
  body {
    background: #ffffff !important;
  }
  .sidebar, .sidebar-backdrop, .mobile-topbar, .mgr-mobile-bottom-nav, .header-actions, .no-print, .modal-backdrop, .toast-container {
    display: none !important;
  }
  .manager-layout {
    display: block !important;
  }
  .main-area {
    padding: 0 !important;
    max-width: 100% !important;
  }
  .card, .kpi-card {
    box-shadow: none !important;
    border: 1px solid #cbd5e1 !important;
    break-inside: avoid;
  }
}
