/* ===== Andeco Horizon CRM — Professional theme ===== */
:root {
  --bg-app: #eef1f6;
  --bg-app-home: #e8ecf4;
  --bg-sidebar: #151821;
  --bg-header: rgba(255, 255, 255, 0.88);
  --bg-card: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-on-dark: #e2e8f0;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-light: #eef2ff;
  --border: #e2e8f0;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-tile: 0 4px 14px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-tile: 16px;
  --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --tile-blue: #4f46e5;
  --tile-green: #059669;
  --tile-orange: #ea580c;
  --tile-purple: #7c3aed;
  --tile-teal: #0d9488;
  --sidebar-purple: #151821;
  --metric-blue: #4f46e5;
  --metric-orange: #ea580c;
  --metric-green: #059669;
  --status-progress: #eab308;
  --status-done: #059669;
}

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

.embedded-file-blocker {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(26, 29, 36, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.embedded-file-blocker.hidden {
  display: none;
}

.embedded-file-blocker-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-width: 520px;
  padding: 1.5rem 1.75rem;
}

.embedded-file-blocker-card h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
}

.embedded-file-blocker-card p,
.embedded-file-blocker-card li {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.embedded-file-blocker-card ol {
  margin: 0.75rem 0;
  padding-left: 1.25rem;
}

.embedded-file-blocker-hint {
  margin-top: 1rem;
  font-size: 0.85rem;
}

body.embedded-file-blocked #app-screen,
body.embedded-file-blocked #login-screen,
body.embedded-file-blocked #setup-screen,
body.embedded-file-blocked .file-protocol-banner {
  display: none !important;
}

.file-protocol-banner {
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
  color: #9a3412;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  z-index: 2000;
}

.file-protocol-banner.hidden {
  display: none;
}

.file-protocol-banner p {
  margin: 0;
  flex: 1 1 280px;
}

.file-protocol-banner code {
  font-size: 0.85em;
}

html, body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  background: linear-gradient(165deg, var(--bg-app) 0%, #e4e9f2 100%);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
body.home-view {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

/* ----- Screens ----- */
.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.screen.hidden { display: none; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ----- Auth / Login (split panel) ----- */
.auth-screen {
  --auth-accent: #e11d48;
  --auth-accent-deep: #be123c;
  --auth-accent-soft: #fff1f2;
  --auth-ink: #1f2937;
  --auth-muted: #6b7280;
  --auth-line: #e5e7eb;
  --auth-brand-font: 'Outfit', 'Plus Jakarta Sans', sans-serif;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 10% 0%, rgba(225, 29, 72, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 100%, rgba(15, 23, 42, 0.12), transparent 50%),
    linear-gradient(160deg, #f8fafc 0%, #eef2ff 45%, #fce7f3 100%);
  animation: auth-bg-in 0.7s ease-out both;
}

@keyframes auth-bg-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  width: min(980px, 100%);
  min-height: min(620px, calc(100vh - 48px));
  background: #fff;
  border-radius: 22px;
  overflow: hidden;
  box-shadow:
    0 25px 50px -12px rgba(15, 23, 42, 0.22),
    0 0 0 1px rgba(15, 23, 42, 0.04);
  animation: auth-shell-in 0.65s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes auth-shell-in {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px 44px;
}

.auth-panel--form {
  background: #fff;
}

.auth-brand {
  text-align: left;
  margin-bottom: 28px;
}

.auth-eyebrow {
  margin: 0 0 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--auth-muted);
}

.auth-wordmark {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
}

.auth-company-logo {
  display: block;
  width: min(280px, 72%);
  height: auto;
  max-width: 320px;
  max-height: 320px;
  margin: 0 auto;
  object-fit: contain;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.auth-form.login-form input,
.auth-screen .auth-form input {
  width: 100%;
  box-sizing: border-box;
  padding: 14px 48px 14px 48px !important;
  border: 1.5px solid var(--auth-line);
  border-radius: 999px;
  font-family: var(--font);
  font-size: 0.98rem;
  background: #fff;
  color: var(--auth-ink);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-field-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: #9ca3af;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 1;
}

.auth-toggle-password {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

.auth-wordmark h1 {
  margin: 0;
  font-family: var(--auth-brand-font);
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.15;
  color: var(--auth-accent);
}

.auth-brand .app-logo {
  margin: 0;
  flex-shrink: 0;
  border-radius: 10px;
  box-shadow: 0 6px 16px rgba(225, 29, 72, 0.28);
}

.auth-tagline {
  margin: 0;
  max-width: 34ch;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--auth-muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-field {
  position: relative;
}

.auth-form input::placeholder {
  color: #9ca3af;
}

.auth-form.login-form input:focus,
.auth-screen .auth-form input:focus {
  outline: none;
  border-color: var(--auth-accent);
  box-shadow: 0 0 0 4px rgba(225, 29, 72, 0.12);
}

.auth-toggle-password:hover {
  color: var(--auth-accent);
  background: var(--auth-accent-soft);
}

.btn-auth {
  width: 100%;
  margin-top: 8px;
  padding: 14px 18px;
  border: 0;
  border-radius: 999px;
  font-family: var(--auth-brand-font);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(135deg, #fb7185 0%, var(--auth-accent) 45%, var(--auth-accent-deep) 100%);
  box-shadow: 0 12px 24px -10px rgba(225, 29, 72, 0.55);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn-auth:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
  box-shadow: 0 16px 28px -10px rgba(225, 29, 72, 0.6);
}

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

.auth-screen .login-error {
  margin: 0;
  padding: 10px 14px;
  font-size: 0.88rem;
  color: #b91c1c;
  background: #fef2f2;
  border-radius: 12px;
}

.auth-screen .login-error.hidden { display: none; }

.auth-panel--visual {
  position: relative;
  overflow: hidden;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(251, 113, 133, 0.55) 0%, rgba(225, 29, 72, 0.72) 40%, rgba(136, 19, 55, 0.88) 100%),
    radial-gradient(circle at 70% 30%, rgba(253, 224, 71, 0.35), transparent 45%),
    linear-gradient(180deg, #0ea5e9 0%, #0369a1 40%, #0f172a 100%);
  background-size: 100% 100%, 120% 120%, 100% 100%;
  animation: auth-visual-shift 14s ease-in-out infinite alternate;
}

@keyframes auth-visual-shift {
  from { background-position: 0% 0%, 0% 0%, 0% 0%; }
  to { background-position: 0% 0%, 18% 12%, 0% 0%; }
}

.auth-visual-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 40% at 50% 100%, rgba(255, 255, 255, 0.18), transparent 60%),
    linear-gradient(180deg, transparent 55%, rgba(15, 23, 42, 0.25) 100%);
  pointer-events: none;
}

.auth-visual-glow::before {
  content: '';
  position: absolute;
  left: -10%;
  right: -10%;
  bottom: 28%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.35);
  animation: auth-horizon 4.5s ease-in-out infinite alternate;
}

@keyframes auth-horizon {
  from { transform: translateY(0); opacity: 0.65; }
  to { transform: translateY(-8px); opacity: 1; }
}

.auth-visual-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  padding: 12px;
  animation: auth-visual-copy 0.8s 0.15s ease-out both;
}

@keyframes auth-visual-copy {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.auth-visual-logo {
  border-radius: 14px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.35);
  background: rgba(255, 255, 255, 0.12);
}

.auth-visual-title {
  margin: 0;
  font-family: var(--auth-brand-font);
  font-size: clamp(1.5rem, 2.8vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 18px rgba(15, 23, 42, 0.25);
}

.auth-visual-copy {
  margin: 0;
  max-width: 28ch;
  font-size: 0.95rem;
  line-height: 1.55;
  color: rgba(255, 255, 255, 0.92);
}

.app-logo {
  display: block;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(11, 31, 51, 0.28);
}
.app-logo--sm {
  margin-right: 10px;
  box-shadow: 0 2px 8px rgba(11, 31, 51, 0.22);
}
.header-brand {
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
}
.logo-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--accent), #6366f1);
  color: white;
  font-size: 28px;
  font-weight: 700;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}
.logo-icon.small {
  width: 36px;
  height: 36px;
  font-size: 18px;
  margin-right: 10px;
}

.login-form label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  margin-top: 16px;
}
.login-form label:first-of-type { margin-top: 0; }
.login-form input,
.login-form select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 1rem;
  background: #fff;
  transition: border-color 0.2s;
}
.login-form input:focus,
.login-form select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}
.login-form .btn {
  width: 100%;
  margin-top: 24px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
}
.login-error {
  margin-top: 12px;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: #b91c1c;
  background: #fef2f2;
  border-radius: var(--radius-sm);
}
.login-error.hidden { display: none; }

@media (max-width: 860px) {
  .auth-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .auth-panel--visual {
    min-height: 220px;
    order: -1;
    padding: 36px 28px;
  }
  .auth-panel--form {
    padding: 32px 24px 40px;
  }
  .auth-brand {
    text-align: center;
  }
  .auth-wordmark {
    align-items: center;
  }
  .auth-tagline {
    margin-left: auto;
    margin-right: auto;
  }
}

.supabase-cloud-panel {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border, #e5e7eb);
}
.supabase-cloud-title {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary, #111827);
}
.supabase-cloud-status {
  margin: 0 0 12px;
  font-size: 0.85rem;
  color: var(--text-muted, #6b7280);
}
.supabase-cloud-panel.is-connected .supabase-signin-form { display: none; }
.supabase-cloud-panel.is-connected .supabase-cloud-status { color: #047857; }
.hidden { display: none !important; }

/* ----- Admin page ----- */
.admin-actions { margin-bottom: 20px; }
.admin-user-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.admin-user-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 14px 18px;
  background: var(--bg-app);
  border-radius: var(--radius-sm);
}
.admin-user-row .user-name { font-weight: 600; }
.admin-user-row .user-username { color: var(--text-muted); font-size: 0.9rem; }
.admin-user-row .user-modules { font-size: 0.85rem; color: var(--text-secondary); }
.admin-user-row .user-admin-badge {
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--tile-purple);
  color: #fff;
  border-radius: 999px;
}
.admin-user-actions {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.admin-user-row .btn-delete { color: #b91c1c; }
.admin-user-row .btn-delete:hover {
  background: #fef2f2;
  color: #991b1b;
}
.admin-user-list .user-muted { color: var(--text-muted); font-size: 0.9rem; }
.admin-form-wrap.hidden { display: none !important; }
.admin-section-panel.hidden { display: none !important; }
.admin-history-panel { overflow: hidden; }
.admin-history-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.admin-history-filters .search-input,
.admin-history-filters select {
  min-width: 140px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font);
  font-size: 0.8rem;
  background: #fff;
}
.admin-history-filters .search-input { flex: 1; min-width: 180px; }
.admin-history-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-secondary);
}
.admin-history-table-wrap {
  overflow: auto;
  max-height: min(68vh, 640px);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.admin-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  line-height: 1.3;
}
.admin-history-table th,
.admin-history-table td {
  padding: 5px 8px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-history-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  white-space: nowrap;
}
.admin-history-table td:nth-child(1),
.admin-history-table td:nth-child(2),
.admin-history-table td:nth-child(3),
.admin-history-table td:nth-child(4),
.admin-history-table td:nth-child(5) {
  white-space: nowrap;
}
.admin-history-table td:nth-child(1) { width: 5.6rem; color: var(--text-secondary); }
.admin-history-table td:nth-child(2) { width: 4.2rem; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.admin-history-table td:nth-child(3) { width: 8.5rem; }
.admin-history-table td:nth-child(4) { width: 8.2rem; }
.admin-history-table td:nth-child(5) { width: 8.5rem; font-weight: 600; }
.admin-history-table td:nth-child(6) {
  white-space: normal;
  color: var(--text-secondary);
  min-width: 180px;
}
.admin-history-table tbody tr:last-child td { border-bottom: 0; }
.admin-history-table tbody tr:hover { background: var(--bg-app); }
.admin-history-empty {
  margin: 0;
  padding: 14px 12px;
  color: var(--text-secondary);
  font-size: 0.82rem;
}
.admin-history-empty.hidden { display: none !important; }
@media (max-width: 720px) {
  .admin-history-table thead { display: none; }
  .admin-history-table tr {
    display: block;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
  }
  .admin-history-table td {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    border: 0;
    padding: 2px 0;
    width: auto !important;
    white-space: normal !important;
  }
  .admin-history-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
    min-width: 4.5rem;
  }
}
.admin-user-form label { display: block; margin-top: 12px; margin-bottom: 4px; font-size: 0.9rem; font-weight: 500; color: var(--text-secondary); }
.admin-user-form label:first-of-type { margin-top: 0; }
.admin-user-form input[type="text"],
.admin-user-form input[type="password"] {
  width: 100%;
  max-width: 320px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
}
.label-optional { font-weight: 400; color: var(--text-muted); }
.admin-check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-weight: 400;
  cursor: pointer;
}
.admin-module-checkboxes { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.admin-form-buttons { display: flex; gap: 12px; margin-top: 20px; }
.admin-user-form select {
  width: 100%;
  max-width: 420px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  background: var(--surface, #fff);
  color: inherit;
}
.admin-access-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 0.9rem;
}
.admin-access-table th,
.admin-access-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-access-table th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; letter-spacing: 0.03em; }
.admin-access-table select { max-width: 180px; padding: 6px 8px; }
.access-mode-banner {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: #1e293b;
  color: #e2e8f0;
  font-size: 0.88rem;
}
.access-mode-banner.hidden { display: none; }
.page.access-readonly .btn-primary,
.page.access-readonly .btn-danger,
.page.access-readonly button {
  pointer-events: none;
  opacity: 0.45;
}
.page.access-readonly button.payroll-pdf-btn,
.page.access-readonly button.shifts-nav-btn {
  pointer-events: auto;
  opacity: 1;
}
.payroll-portal-list { margin-top: 4px; }
.payroll-portal-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
}
.payroll-portal-toolbar label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.payroll-portal-toolbar select {
  padding: 4px 8px;
  font: inherit;
  font-size: 0.84rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface, #fff);
  color: inherit;
}
.payroll-portal-year { margin: 0 0 10px; }
.payroll-portal-year-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0;
  padding: 4px 2px 6px;
  font-size: 0.92rem;
  font-weight: 600;
}
.payroll-portal-year-count {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}
.payroll-portal-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.payroll-portal-table th,
.payroll-portal-table td {
  text-align: left;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
  line-height: 1.3;
}
.payroll-portal-table tr:last-child td { border-bottom: none; }
.payroll-portal-table th {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding-top: 6px;
  padding-bottom: 6px;
}
.payroll-portal-money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.payroll-portal-action { width: 1%; white-space: nowrap; text-align: right; }
.payroll-portal-table .payroll-pdf-btn {
  padding: 3px 8px;
  font-size: 0.75rem;
  line-height: 1.3;
}
.payroll-portal-empty {
  padding: 16px 4px;
  color: var(--text-muted);
}
.nav-item--admin.hidden-module,
.module-card--admin.hidden-module { display: none !important; }

/* ----- Buttons ----- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #6366f1 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-hover) 0%, #4f46e5 100%); }
.btn-secondary {
  background: #fff;
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-app); }
.btn-secondary:disabled,
.btn-primary:disabled {
  opacity: 0.65;
  cursor: default;
}
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--border); color: var(--text-primary); }
.btn-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
}

/* ----- App layout ----- */
#app-screen {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
}
.andeco-save-banner {
  position: sticky;
  top: 60px;
  z-index: 120;
  margin: 0;
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #92400e;
  background: #fffbeb;
  border-bottom: 1px solid #fcd34d;
}
.andeco-save-banner.andeco-save-banner--error {
  color: #991b1b;
  background: #fef2f2;
  border-bottom-color: #fecaca;
}
.andeco-save-banner.hidden { display: none; }

#app-screen.home-view {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: var(--bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  z-index: 100;
  min-width: 0;
}
.app-header .header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
}
.header-brand-full,
.header-brand-short {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.header-brand-short { display: none; }
.header-brand .app-logo { flex-shrink: 0; }
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  margin-right: 12px;
}
.menu-toggle span {
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
}
.header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.btn-logout-label { white-space: nowrap; }
.header-icon-wrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s;
}
.header-icon-wrap:hover {
  background: var(--bg-app);
  color: var(--text-primary);
}
.header-icon {
  font-size: 1.2rem;
}
.header-icon-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
  color: #fff;
  background: #dc2626;
  border-radius: 9px;
}
.header-user {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border);
}
.header-user-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 6px 4px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.header-user-trigger:hover,
.header-user-trigger[aria-expanded="true"] {
  background: var(--bg-app);
  border-color: var(--border);
}
.header-user-label {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
}
.header-avatar {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #3b82f6);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  pointer-events: none;
}
.header-user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.14);
  z-index: 80;
}
.header-user-dropdown.hidden { display: none; }
.header-user-menu-item {
  width: 100%;
  display: block;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
}
.header-user-menu-item:hover {
  background: var(--bg-app);
}

#header-notify-slot {
  display: flex;
  align-items: center;
}
.header-notify {
  position: relative;
  display: flex;
  align-items: center;
}
.header-notify-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
}
.header-notify-btn.has-unread {
  color: var(--accent);
}
.header-notify-icon {
  display: block;
}
.header-notify-panel {
  position: fixed;
  top: 68px;
  right: 12px;
  width: min(380px, calc(100vw - 24px));
  max-height: min(520px, calc(100vh - 80px));
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.16);
  z-index: 130;
  overflow: hidden;
  color: var(--text-primary);
}
.header-notify-panel.hidden { display: none; }
.header-notify-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px 8px;
}
.header-notify-head h2 {
  margin: 0;
  font-size: 1rem;
}
.header-notify-head .btn,
.header-notify-actions .btn-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
}
.header-notify-actions {
  padding: 0 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.header-notify-actions .btn { width: 100%; }
.header-notify-device-hint {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: var(--text-secondary);
}
.header-notify-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 125;
}
.header-notify-backdrop.hidden { display: none; }
.header-notify-list {
  overflow: auto;
  padding: 0 8px 10px;
  border-top: 1px solid var(--border);
}
.header-notify-empty {
  margin: 0;
  padding: 16px 10px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.45;
}
.header-notify-item {
  width: 100%;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  font-family: var(--font);
  cursor: pointer;
  color: inherit;
}
.header-notify-item:hover { background: var(--bg-app); }
.header-notify-item-dot {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: transparent;
  flex-shrink: 0;
}
.header-notify-item.is-unread .header-notify-item-dot {
  background: var(--accent);
}
.header-notify-item-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.header-notify-item-title {
  font-size: 0.92rem;
  font-weight: 600;
}
.header-notify-item.is-unread .header-notify-item-title { color: var(--text-primary); }
.header-notify-item-body,
.header-notify-item-meta {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.35;
}
.header-notify-item-body {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.header-notify-item-row {
  display: flex;
  align-items: flex-start;
  gap: 2px;
}
.header-notify-item-row .header-notify-item {
  flex: 1;
  min-width: 0;
}
.header-notify-dismiss {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  margin-top: 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  font-family: inherit;
}
.header-notify-dismiss:hover,
.header-notify-dismiss:focus-visible {
  background: var(--bg-app);
  color: var(--text-primary);
}
.notify-compose-form select,
.notify-compose-form textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font);
  font-size: 0.95rem;
  background: #fff;
}
.notify-compose-form textarea { resize: vertical; min-height: 84px; }
.notify-recipients {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 180px;
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-app);
}
.notify-recipient {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.92rem;
  cursor: pointer;
}
.notify-recipient:hover { background: #fff; }
.notify-recipient--all {
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
  padding-bottom: 10px;
}
.notify-toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 140;
  padding: 10px 16px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-size: 0.88rem;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.24);
}
.notify-toast.hidden { display: none; }

.btn-logout { margin-left: 4px; }
.user-badge {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 6px 12px;
  background: var(--bg-app);
  border-radius: var(--radius-sm);
}

.profile-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.45);
}
.profile-modal.hidden { display: none; }
.profile-modal-content {
  width: min(460px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.22);
  padding: 0;
}
.profile-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.profile-modal .modal-header h2 {
  margin: 0;
  font-size: 1.15rem;
}
.profile-form {
  padding: 18px 20px 22px;
}
.profile-form label {
  display: block;
  margin: 12px 0 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.profile-form label:first-of-type { margin-top: 0; }
.profile-form input {
  width: 100%;
  box-sizing: border-box;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-family: var(--font);
  font-size: 0.95rem;
  background: #fff;
}
.profile-form input[readonly] {
  background: var(--bg-app);
  color: var(--text-muted);
}
.profile-password-block {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.profile-password-block h3 {
  margin: 0 0 4px;
  font-size: 0.95rem;
}
.profile-hint {
  margin: 0 0 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.profile-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
.profile-success {
  margin-top: 12px;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: #047857;
  background: #ecfdf5;
  border-radius: var(--radius-sm);
}
.profile-success.hidden { display: none; }

.sidebar {
  position: fixed;
  top: 60px;
  left: 0;
  width: 260px;
  height: calc(100vh - 60px);
  height: calc(100dvh - 60px);
  background: linear-gradient(180deg, #1a1d28 0%, var(--sidebar-purple) 100%);
  padding: 20px 0;
  z-index: 90;
  overflow-y: auto;
  transition: transform 0.2s ease, opacity 0.2s ease;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}
/* Home view: no sidebar, full-width centered content */
#app-screen.home-view .sidebar {
  transform: translateX(-100%);
  pointer-events: none;
  opacity: 0;
}
#app-screen.home-view .main-content {
  margin-left: 0;
  overflow: hidden;
  height: calc(100vh - 60px);
  height: calc(100dvh - 60px);
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
}
#app-screen.home-view .menu-toggle {
  display: none;
}
#app-screen.home-view #page-home.active,
#app-screen.home-view .page-home.active {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.module-grid-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: calc(100vh - 60px - 56px);
  min-height: calc(100dvh - 60px - 56px);
  padding: 40px 24px;
}
#app-screen.home-view .module-grid-wrap {
  flex: 1;
  min-height: 0;
  padding: 28px 24px 40px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-items: flex-start;
  justify-content: center;
}
.home-dashboard {
  width: 100%;
  max-width: 880px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.home-greeting {
  width: 100%;
  text-align: center;
  margin: 0 0 1.25rem;
  padding: 0 0.5rem;
}
.home-greeting-eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.home-greeting-title {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 1.75rem);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.module-grid-wrap .module-grid {
  margin: 0 auto;
  width: 100%;
  max-width: 880px;
}

.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text-on-dark);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 0;
  transition: background 0.2s, color 0.2s;
  border-left: 3px solid transparent;
}
.sidebar-nav .nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}
.sidebar-nav .nav-item.active {
  background: rgba(79, 70, 229, 0.28);
  color: #fff;
  border-left-color: #818cf8;
}
.sidebar-nav .nav-item.hidden-module { display: none; }
.nav-icon { font-size: 1.2rem; opacity: 0.9; }
.nav-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 12px 20px; }
.nav-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 8px 20px;
}

.main-content {
  flex: 1;
  margin-left: 260px;
  margin-top: 60px;
  padding: 28px 32px 48px;
  min-height: calc(100vh - 60px);
}
.main-content #page-home,
.main-content .page-home {
  background: linear-gradient(180deg, var(--bg-app-home) 0%, var(--bg-app) 100%);
  margin: -28px -32px -48px;
  padding: 0;
}

/* ----- Pages ----- */
.page {
  display: none;
  animation: fadeIn 0.2s ease;
}
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 28px;
  min-width: 0;
}
.page-header h1,
.page-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-header h2 { font-size: 1.35rem; }
.page-header .header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex: 0 1 auto;
  min-width: 0;
  margin-left: auto;
}
.page-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ----- Module grid (home) — dense icon grid ----- */
.module-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 24px;
  max-width: 1200px;
}
#app-screen.home-view .module-grid {
  gap: 10px 8px;
  max-width: 100%;
  justify-items: center;
}
#app-screen.home-view .module-card--tile {
  padding: 10px 6px;
  border: none;
  box-shadow: none;
  background: transparent;
}
#app-screen.home-view .module-card--tile:hover {
  border: none;
  box-shadow: none;
  background: transparent;
  transform: translateY(-2px);
}
#app-screen.home-view .module-icon-tile {
  width: 48px;
  height: 48px;
  font-size: 22px;
  margin-bottom: 6px;
}
#app-screen.home-view .module-title {
  font-size: 0.84rem;
}

.module-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 20px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text-primary);
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
  border: 1px solid rgba(255, 255, 255, 0.8);
}
.module-card--tile {
  min-width: 0;
  width: 100%;
  padding: 24px 16px;
  border-radius: var(--radius-tile);
  box-shadow: var(--shadow-tile);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}
.module-card--tile:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: rgba(79, 70, 229, 0.25);
}
.module-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}
.module-card.hidden-module { display: none; }
.module-icon-tile {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  border-radius: var(--radius-tile);
  margin-bottom: 12px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.module-icon-tile svg {
  width: 28px;
  height: 28px;
  display: block;
  flex-shrink: 0;
}
#app-screen.home-view .module-icon-tile svg {
  width: 24px;
  height: 24px;
}
.module-icon--blue  { background: var(--tile-blue);  color: #fff; }
.module-icon--green { background: var(--tile-green); color: #fff; }
.module-icon--orange { background: var(--tile-orange); color: #fff; }
.module-icon--purple { background: var(--tile-purple); color: #fff; }
.module-icon--teal   { background: var(--tile-teal);   color: #fff; }
.module-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
.module-title {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.module-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.module-placeholder {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  color: var(--text-secondary);
  box-shadow: var(--shadow);
}

/* ----- Module detail page (Creatio-style) ----- */
.module-detail-page {
  display: none;
  background: linear-gradient(180deg, #f1f5f9 0%, #eef1f6 120px);
  margin: -28px -32px -48px;
  padding: 0;
  min-height: calc(100vh - 60px);
}
.module-detail-page.active {
  display: flex;
  flex-direction: column;
}
.module-detail-wrap {
  display: flex;
  flex: 1;
  min-height: 0;
}
.module-detail {
  flex: 1;
  padding: 24px 28px 40px;
  overflow-y: auto;
  min-width: 0;
}

/* Accounting uses the full content width. */
#page-accounting .module-detail-wrap {
  display: block;
  width: 100%;
  min-height: 0;
}
#page-accounting .module-detail {
  min-width: 0;
  overflow-y: auto;
}

/* Detail bar */
.module-detail-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 12px 16px;
  margin-bottom: 16px;
  min-width: 0;
}
.module-back {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.module-back:hover { text-decoration: underline; }
.module-detail-title {
  flex: 1;
  min-width: 0;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.module-detail-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  min-width: 0;
}
.module-detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--bg-app);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-icon:hover { background: var(--border); }
.module-detail-secondary {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}
.module-tool {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
}
.module-tool:hover { color: var(--accent); }

/* Process bar */
.module-process-bar {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 20px;
  background: #e5e7eb;
  border-radius: 999px;
  padding: 4px;
  max-width: 400px;
}
.module-step {
  flex: 1;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
  color: var(--text-muted);
  border-radius: 999px;
  transition: background 0.2s, color 0.2s;
}
.module-step--done {
  background: var(--status-done);
  color: #fff;
}
.module-step--active {
  background: var(--accent);
  color: #fff;
}

/* Tabs */
.module-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.module-tab {
  padding: 10px 18px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.module-tab:hover { color: var(--text-primary); }
.module-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Subsection tabs (horizontal bar under module header) */
.module-subtabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
  min-height: 42px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
.module-subtabs[hidden] {
  display: none !important;
}
.module-subtab {
  padding: 10px 16px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.2s, border-color 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
}
.module-subtab:hover { color: var(--text-primary); }
.module-subtab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.module-subsection-panel {
  display: none;
}
.module-subsection-panel.active {
  display: block;
}
.module-subsection-placeholder {
  padding: 2rem 1.5rem;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-secondary);
}
.module-subsection-placeholder .module-meta {
  margin-top: 0.5rem;
}
#accounting-subsection-overlay {
  display: none;
  margin-bottom: 1rem;
}

/* Status row */
.module-status-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}
.status-tag {
  display: inline-block;
  padding: 4px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 999px;
}
.status--progress {
  background: #fef3c7;
  color: #b45309;
}
.status--done {
  background: #d1fae5;
  color: #047857;
}
.module-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Metric cards */
.module-metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.metric-card {
  padding: 20px;
  border-radius: var(--radius);
  color: #fff;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.metric--blue   { background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%); }
.metric--orange { background: linear-gradient(135deg, #ea580c 0%, #f97316 100%); }
.metric--green  { background: linear-gradient(135deg, #059669 0%, #10b981 100%); }
.metric-value {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}
.metric-label {
  font-size: 0.85rem;
  opacity: 0.95;
  margin-top: 4px;
}

/* Info panel */
.module-info-panel,
.module-description-panel,
.module-table-panel {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.panel-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 14px;
}
.hr-overview-ytd-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
  margin-bottom: 4px;
}
.hr-overview-ytd-header .panel-title {
  margin-bottom: 0;
}
.hr-overview-ytd-year-wrap {
  margin: 0;
}
.hr-overview-ytd-year-wrap label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.hr-overview-ytd-year-wrap select {
  min-width: 6rem;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border, #e5e7eb);
}
.hr-overview-ytd-table tfoot .hr-overview-ytd-total-row th,
.hr-overview-ytd-table tfoot .hr-overview-ytd-total-row td {
  font-weight: 600;
  border-top: 2px solid var(--border, #e5e7eb);
  background: var(--bg-app, #f9fafb);
}
.hr-payroll-ytd-panel {
  margin-top: 0;
}
.info-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 24px;
  font-size: 0.9rem;
}
.info-grid dt {
  color: var(--text-muted);
  font-weight: 500;
}
.info-grid dd { margin: 0; }
.info-grid a {
  color: var(--accent);
  text-decoration: none;
}
.info-grid a:hover { text-decoration: underline; }

.module-description-panel p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

/* Cards row */
.module-cards-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}
.module-info-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
}
.card-avatar {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 50%;
  margin-bottom: 12px;
}
.card-name { font-weight: 600; font-size: 1rem; margin-bottom: 2px; }
.card-role, .card-muted { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 4px; }
.card-contact { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 2px; }

/* Data table */
.table-wrap {
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.data-table th,
.data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.data-table tbody tr:hover { background: var(--bg-app); }

.clients-directory-table .clients-row-actions {
  white-space: nowrap;
  text-align: right;
}
.clients-directory-table .clients-row-actions .btn {
  margin-left: 0.25rem;
}
.clients-directory-table td,
.clients-directory-table th {
  vertical-align: middle;
}

/* Copilot sidebar */
.module-copilot {
  width: 320px;
  flex-shrink: 0;
  background: #f8f9fb;
  border-left: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
}
.copilot-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 16px;
}
.copilot-logo {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  border-radius: 8px;
}
.copilot-drafts-section { margin-bottom: 1rem; }
.copilot-drafts-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 0.5rem 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.copilot-drafts-list { display: flex; flex-direction: column; gap: 0.5rem; }
.copilot-draft-item {
  padding: 0.5rem 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: background 0.2s, border-color 0.2s;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}
.copilot-draft-item-main { flex: 1; min-width: 0; cursor: pointer; display: flex; flex-direction: column; gap: 0.15rem; }
.copilot-draft-item:hover { background: var(--accent-light); border-color: var(--primary-color); }
.btn-delete-draft {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: 0.25rem;
  background: transparent;
  color: var(--text-muted, #666);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-delete-draft:hover { background: rgba(239, 68, 68, 0.15); color: var(--danger-color, #dc2626); }
.copilot-draft-label { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.copilot-draft-client { font-size: 0.85rem; font-weight: 500; color: var(--text-primary); }
.copilot-draft-amount { font-size: 0.8rem; color: var(--primary-color); font-weight: 600; }
.copilot-drafts-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  padding: 0.5rem 0;
}
.copilot-prompt {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.copilot-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.copilot-suggestion {
  padding: 10px 14px;
  font-size: 0.85rem;
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s;
}
.copilot-suggestion:hover { background: var(--accent-light); }
.copilot-response { margin-top: 16px; }
.copilot-response-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.copilot-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.copilot-card {
  padding: 8px 12px;
  font-size: 0.8rem;
  background: #d1fae5;
  color: #047857;
  border-radius: var(--radius-sm);
}

/* ----- Accounting: Invoice/Receipt embed ----- */
.accounting-embed { margin-top: 0; }
.accounting-embed-inner { padding: 0; }
/* Payroll forms: avoid horizontal scroll inside accounting module */
#page-accounting .payroll-sub-panel {
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}
.accounting-placeholder { min-height: 200px; }
.accounting-reports-panel { padding: 0; min-height: 200px; }
.accounting-reports-content { padding: 0; margin-top: 0; }
.accounting-reports-content .page-header { margin-bottom: 1.25rem; }
.accounting-reports-content .reports-subsection { margin-bottom: 2rem; }
.accounting-reports-content .reports-subsection-title { font-size: 1.15rem; font-weight: 600; margin: 0 0 0.35rem 0; color: var(--text-primary); }
.accounting-reports-content .reports-subsection-desc { font-size: 0.875rem; color: var(--text-secondary); margin: 0 0 1rem 0; }
.accounting-reports-panel.reports-panel-visible { display: block !important; visibility: visible !important; }
.accounting-reports-panel .page-header { margin-bottom: 1rem; }
.accounting-reports-panel .reports-section-title { font-size: 1.25rem; font-weight: 600; margin: 0 0 0.5rem 0; }
.accounting-reports-panel .reports-section-desc { font-size: 0.875rem; color: var(--text-secondary); margin: 0 0 1rem 0; }
.reports-view { padding: 0; }
.reports-view .page-header { margin-bottom: 1rem; }
.reports-view .reports-section-title { font-size: 1.25rem; font-weight: 600; margin: 0 0 0.5rem 0; }
.reports-view .reports-section-desc { font-size: 0.875rem; color: var(--text-secondary); margin: 0 0 1rem 0; }
#accounting-invoice-app .page { display: none; }
#accounting-invoice-app .page.active { display: block; }
.accounting-modal.modal {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  overflow-y: auto;
  align-items: flex-start;
  justify-content: center;
  padding: 24px;
}
.accounting-modal.modal.active {
  display: flex;
}
.accounting-modal .modal-content {
  background: var(--bg-card);
  border-radius: var(--radius);
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}
.accounting-modal .modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.accounting-modal .modal-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Sidebar backdrop (mobile drawer) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 60px 0 0 0;
  background: rgba(15, 23, 42, 0.42);
  z-index: 85;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.sidebar-backdrop[hidden] { display: none !important; }

/* Shared compact toolbars — prefer single-row scroll over wrapping */
.app-toolbar,
.fleet-toolbar,
.crew-toolbar,
.shifts-toolbar,
.sc-toolbar,
.dist-toolbar,
.lms-toolbar,
.dist-quote-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

/* ----- Responsive ----- */
@media (max-width: 1200px) {
  .module-grid { grid-template-columns: repeat(4, 1fr); }
  .module-metrics { grid-template-columns: repeat(2, 1fr); }
  .module-copilot { width: 280px; }
}

@media (max-width: 1024px) {
  .module-grid { grid-template-columns: repeat(4, 1fr); gap: 18px; }
  .main-content { padding: 24px 20px 40px; }
  .module-detail { padding: 22px 20px 36px; }
  .page-header h1 { font-size: 1.4rem; }
  .page-header h2 { font-size: 1.25rem; }
}

@media (max-width: 1024px) {
  .header-notify-btn {
    width: 44px;
    height: 44px;
  }
  .header-notify-panel {
    position: fixed;
    top: auto;
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
    max-height: min(72vh, 620px);
    z-index: 130;
    border-radius: 16px;
  }
  .header-notify-item {
    padding: 12px 10px;
    min-height: 48px;
  }
  .header-notify-dismiss {
    width: 40px;
    height: 40px;
    font-size: 1.35rem;
  }
  #notify-compose-modal.profile-modal {
    align-items: flex-end;
    padding: 0;
  }
  #notify-compose-modal .notify-compose-content {
    width: 100%;
    max-width: none;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
  }
}

@media (max-width: 900px) {
  .module-grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .header-user-label { display: none; }
  .header-brand-full { display: none; }
  .header-brand-short { display: inline; }
  .app-header { padding: 0 14px; }
}

@media (max-width: 768px) {
  .menu-toggle { display: flex; flex-shrink: 0; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 95;
    box-shadow: 8px 0 24px rgba(15, 23, 42, 0.18);
  }
  .sidebar.open { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop {
    display: block;
  }
  .main-content { margin-left: 0; padding: 20px 16px 36px; }
  .module-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .main-content #page-home,
  .main-content .page-home { margin: -20px -16px -36px; padding: 0; }
  #app-screen.home-view .module-grid-wrap { padding: 16px 12px 28px; }
  .home-greeting { margin-bottom: 1rem; }
  .home-greeting-title { font-size: 1.3rem; }
  #app-screen.home-view .module-grid { gap: 8px 6px; }
  #app-screen.home-view .module-card--tile { padding: 8px 4px; }
  #app-screen.home-view .module-icon-tile {
    width: 44px;
    height: 44px;
    font-size: 20px;
    margin-bottom: 5px;
  }
  #app-screen.home-view .module-title { font-size: 0.8rem; }
  .module-detail-page { margin: -20px -16px -36px; min-height: calc(100dvh - 60px); }
  .module-detail { padding: 16px 14px 28px; }
  .module-detail-wrap { flex-direction: column; }
  .module-copilot {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
  }
  .module-metrics { grid-template-columns: 1fr 1fr; gap: 12px; }
  .module-cards-row { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .page-header {
    margin-bottom: 1.25rem;
    flex-wrap: nowrap;
  }
  .page-header h1,
  .page-header h2 { font-size: 1.2rem; }
  .page-header .header-actions {
    flex: 1 1 auto;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .page-header .header-actions::-webkit-scrollbar { display: none; }
  .page-header .header-actions .btn,
  .page-header .header-actions .search-input {
    flex-shrink: 0;
  }
  .search-input {
    width: min(100%, 11.5rem);
    min-width: 8rem;
  }
  .btn-logout { padding: 0.4rem 0.65rem; }
  .btn-logout-label { font-size: 0.85rem; }
  .module-detail-bar { gap: 10px; }
  .module-detail-title { font-size: 1.15rem; }
  .module-subtab { padding: 10px 12px; font-size: 0.72rem; }
  .app-toolbar,
  .fleet-toolbar,
  .crew-toolbar,
  .shifts-toolbar,
  .sc-toolbar,
  .dist-toolbar,
  .lms-toolbar,
  .dist-quote-toolbar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    padding-bottom: 2px;
  }
  .app-toolbar > *,
  .fleet-toolbar > *,
  .crew-toolbar > *,
  .shifts-toolbar > *,
  .sc-toolbar > *,
  .dist-toolbar > *,
  .lms-toolbar > *,
  .dist-quote-toolbar > * {
    flex-shrink: 0;
  }
  .table-wrap {
    margin: 0 -2px;
    -webkit-overflow-scrolling: touch;
  }
  table th,
  table td {
    white-space: nowrap;
  }
}

@media (max-width: 480px) {
  .module-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .main-content { padding: 16px 12px 32px; }
  .app-header { padding: 0 10px; }
  .header-icon-wrap { width: 36px; height: 36px; }
  .header-icon-badge { font-size: 0.65rem; min-width: 16px; height: 16px; line-height: 16px; }
  .module-detail-title { font-size: 1.05rem; }
  .module-detail { padding: 14px 12px 24px; }
  .module-detail-page { margin: -16px -12px -32px; }
  .main-content #page-home,
  .main-content .page-home { margin: -16px -12px -32px; }
  #app-screen.home-view .module-grid-wrap { padding: 12px 10px 24px; }
  #app-screen.home-view .module-grid { gap: 6px 4px; }
  #app-screen.home-view .module-card--tile { padding: 6px 2px; }
  #app-screen.home-view .module-title { font-size: 0.76rem; }
  /* Prefer short labels on very small screens to avoid clipping */
  .module-title[data-short] {
    font-size: 0;
  }
  .module-title[data-short]::before {
    content: attr(data-short);
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.3;
  }
  .btn-logout-label { display: none; }
  .btn-logout::before {
    content: "Out";
    font-size: 0.82rem;
    font-weight: 600;
  }
  .page-header h1,
  .page-header h2 { font-size: 1.1rem; }
  .module-metrics { grid-template-columns: 1fr 1fr; gap: 10px; }
  .search-input {
    width: 9.5rem;
    min-width: 7.5rem;
    padding: 0.55rem 0.75rem;
  }
}

/* 24-hour time / datetime text inputs (no AM/PM pickers) */
.app-time-input,
.app-datetime-input {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.app-time-input {
  min-width: 5.5rem;
  max-width: 7rem;
}
.app-datetime-input {
  min-width: 9.5rem;
}

/* ----- Home launcher (smart TV) ----- */
body.home-view {
  background: #070b14;
}
#app-screen.home-view .app-header {
  background: linear-gradient(180deg, rgba(7, 11, 20, 0.78), rgba(7, 11, 20, 0.28));
  border-bottom-color: transparent;
  box-shadow: none;
}
#app-screen.home-view .app-header .header-brand,
#app-screen.home-view .header-user-label,
#app-screen.home-view .btn-logout {
  color: #e8eef8;
}
#app-screen.home-view .header-user {
  border-left-color: rgba(255, 255, 255, 0.14);
}
#app-screen.home-view .header-user-trigger:hover,
#app-screen.home-view .header-user-trigger[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}
#app-screen.home-view .header-notify-btn {
  color: #e8eef8;
}
#app-screen.home-view .header-notify-btn.has-unread {
  color: #c7d2fe;
}
#app-screen.home-view .header-notify-btn:hover,
#app-screen.home-view .header-notify-btn[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
#app-screen.home-view .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
#app-screen.home-view .main-content #page-home,
#app-screen.home-view .main-content .page-home {
  margin: 0;
  --tv-tile-w: clamp(108px, min(13.2vw, 3.6vw + 148px), 240px);
  --tv-tile-h: clamp(92px, min(11vw, 3vw + 122px), 200px);
  --tv-gap: clamp(12px, min(1.25vw, 0.5vw + 16px), 28px);
  --tv-control: clamp(40px, min(2.8vw, 0.6vw + 32px), 48px);
  position: relative;
  background:
    radial-gradient(900px 480px at 12% 0%, color-mix(in srgb, var(--tv-glow, #6366f1) 28%, transparent), transparent 62%),
    radial-gradient(720px 420px at 100% 100%, rgba(14, 165, 233, 0.12), transparent 58%),
    linear-gradient(180deg, #10182a 0%, #070b14 46%, #05070d 100%);
  --tv-glow: #4f46e5;
}
#app-screen.home-view .tv-ambient {
  position: absolute;
  z-index: 0;
  left: max(0px, calc(8vw - 80px));
  top: 36px;
  width: min(560px, 70vw);
  height: 320px;
  pointer-events: none;
  background: radial-gradient(circle, color-mix(in srgb, var(--tv-glow, #6366f1) 46%, transparent), transparent 68%);
  filter: blur(18px);
  transition: background 0.45s ease;
}
#app-screen.home-view .module-grid-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  container-type: inline-size;
  container-name: home;
  padding: clamp(8px, 2vw, 40px) clamp(12px, 2.4vw, 56px) clamp(20px, 3vw, 56px);
}
#app-screen.home-view .home-dashboard {
  width: 100%;
  max-width: none;
  align-items: stretch;
  gap: clamp(6px, 0.8cqi, 20px);
  --tv-tile-w: clamp(108px, min(15.5cqi, 4.2cqi + 148px), 240px);
  --tv-tile-h: clamp(92px, min(12.8cqi, 3.5cqi + 122px), 200px);
  --tv-gap: clamp(12px, min(1.6cqi, 0.55cqi + 16px), 28px);
  --tv-control: clamp(40px, min(3.2cqi, 0.8cqi + 32px), 48px);
}
#app-screen.home-view .home-greeting {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
  text-align: left;
  margin: 0 0 8px;
  padding: 0 6px;
}
#app-screen.home-view .home-greeting-copy {
  min-width: 0;
  flex: 1 1 auto;
}
#app-screen.home-view .home-greeting-eyebrow {
  color: rgba(226, 232, 240, 0.62);
  letter-spacing: 0.16em;
  font-size: clamp(0.68rem, min(0.85cqi, 0.35cqi + 0.55rem), 0.84rem);
}
#app-screen.home-view .home-greeting-title {
  color: #f8fafc;
  font-size: clamp(1.35rem, min(3.1cqi, 1.35cqi + 1.15rem), 2.75rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#app-screen.home-view .tv-clock {
  flex: 0 0 auto;
  margin-left: auto;
  max-width: 100%;
  text-align: right;
  color: #f8fafc;
}
#app-screen.home-view .tv-clock-time {
  display: block;
  font-size: clamp(1.35rem, min(2.8cqi, 1.15cqi + 1.05rem), 2.5rem);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
}
#app-screen.home-view .tv-clock-date {
  display: block;
  margin-top: 4px;
  font-size: clamp(0.75rem, min(1cqi, 0.4cqi + 0.62rem), 0.95rem);
  color: rgba(226, 232, 240, 0.68);
}
#app-screen.home-view .tv-stage {
  min-height: 0;
  padding: 10px 6px 6px;
}
#app-screen.home-view .tv-stage-kicker {
  display: none;
}
#app-screen.home-view .tv-stage-title {
  margin: 0;
  font-size: clamp(1.45rem, min(3.6cqi, 1.55cqi + 1.2rem), 3rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.05;
  color: #fff;
}
#app-screen.home-view .tv-stage-blurb {
  margin: 8px 0 0;
  max-width: min(52rem, 70%);
  font-size: clamp(0.92rem, min(1.35cqi, 0.55cqi + 0.72rem), 1.15rem);
  color: rgba(226, 232, 240, 0.78);
}
#app-screen.home-view .tv-stage-hint {
  margin: 10px 0 0;
  font-size: clamp(0.75rem, min(0.9cqi, 0.35cqi + 0.58rem), 0.88rem);
  letter-spacing: 0.02em;
  color: rgba(148, 163, 184, 0.9);
}
#app-screen.home-view .tv-shelves {
  display: flex;
  flex-direction: column;
  gap: clamp(4px, 0.6cqi, 16px);
  margin-top: 6px;
}
#app-screen.home-view .tv-shelf-label {
  margin: 0;
  padding: 0 6px;
  font-size: clamp(0.72rem, min(0.9cqi, 0.3cqi + 0.58rem), 0.84rem);
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.55);
}
#app-screen.home-view .tv-shelf--system:not(:has(.module-card:not(.hidden-module))) {
  display: none;
}
#app-screen.home-view .tv-rail {
  overflow-x: auto;
  overflow-y: hidden;
  scroll-padding-inline: 28px;
  width: 100%;
  min-width: 0;
  padding: 6px 0 8px;
  margin: 0;
  scrollbar-width: none;
}
#app-screen.home-view .home-dashboard,
#app-screen.home-view .tv-shelves,
#app-screen.home-view .tv-shelf {
  min-width: 0;
  max-width: 100%;
}
#app-screen.home-view .tv-rail::-webkit-scrollbar { display: none; }
#app-screen.home-view .module-grid-wrap .module-grid,
#app-screen.home-view .module-grid {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: var(--tv-gap, 22px);
  width: max-content;
  max-width: none;
  margin: 0;
  justify-items: stretch;
  /* Room inside the scroll content so a zoomed tile and its ring stay visible. */
  padding: clamp(16px, 1.4vw, 36px) clamp(18px, 2vw, 48px) clamp(24px, 2.2vw, 56px);
}
#app-screen.home-view .module-card.hidden-module {
  display: none !important;
}
#app-screen.home-view .module-card--tile {
  position: relative;
  isolation: isolate;
  flex: 0 0 auto;
  width: var(--tv-tile-w, 176px);
  height: var(--tv-tile-h, 148px);
  padding: clamp(12px, 0.8vw, 16px);
  align-items: flex-start;
  justify-content: space-between;
  text-align: left;
  color: #fff;
  border: 0;
  border-radius: clamp(16px, min(1.5cqi, 0.45cqi + 14px), 22px);
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.02) 42%, rgba(0, 0, 0, 0.2) 100%),
    linear-gradient(180deg, color-mix(in srgb, var(--tile-tint, #334155) 78%, white), var(--tile-tint, #334155) 48%, color-mix(in srgb, var(--tile-tint, #334155) 62%, #020617));
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.32);
  transform: scale(1);
  opacity: 0.9;
  transition: transform 0.42s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.42s ease, box-shadow 0.42s ease;
}
#app-screen.home-view .module-card--tile[data-tint="blue"] { --tile-tint: #4f46e5; }
#app-screen.home-view .module-card--tile[data-tint="teal"] { --tile-tint: #0f766e; }
#app-screen.home-view .module-card--tile[data-tint="orange"] { --tile-tint: #ea580c; }
#app-screen.home-view .module-card--tile[data-tint="green"] { --tile-tint: #059669; }
#app-screen.home-view .module-card--tile[data-tint="purple"] { --tile-tint: #7c3aed; }
#app-screen.home-view .module-card--tile::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.28), transparent 46%);
  pointer-events: none;
}
#app-screen.home-view .module-card--tile.is-tv-focus,
#app-screen.home-view .module-card--tile:focus-visible {
  opacity: 1;
  transform: scale(1.06) translateY(-2px);
  transform-origin: center center;
  z-index: 2;
  box-shadow:
    0 0 0 3px #fff,
    0 12px 22px rgba(0, 0, 0, 0.34);
  outline: none;
}
#app-screen.home-view .module-card--tile:hover {
  border: 0;
  background:
    linear-gradient(155deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.02) 42%, rgba(0, 0, 0, 0.2) 100%),
    linear-gradient(180deg, color-mix(in srgb, var(--tile-tint, #334155) 78%, white), var(--tile-tint, #334155) 48%, color-mix(in srgb, var(--tile-tint, #334155) 62%, #020617));
}
#app-screen.home-view .module-icon-tile {
  width: 40%;
  height: auto;
  aspect-ratio: 1;
  min-width: 34px;
  max-width: 84px;
  margin: 0;
  border-radius: clamp(10px, min(0.9cqi, 0.3cqi + 8px), 16px);
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}
#app-screen.home-view .module-icon-tile svg {
  width: 58%;
  height: 58%;
}
#app-screen.home-view .module-title,
#app-screen.home-view .module-title[data-short] {
  position: relative;
  z-index: 1;
  width: 100%;
  font-size: clamp(0.8rem, min(1.15cqi, 0.45cqi + 0.62rem), 1.05rem);
  font-weight: 680;
  line-height: 1.2;
  color: #fff;
  text-align: left;
  white-space: normal;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
#app-screen.home-view .module-title[data-short]::before {
  content: none;
}
@media (prefers-reduced-motion: reduce) {
  #app-screen.home-view .module-card--tile,
  #app-screen.home-view .tv-ambient {
    transition: none;
  }
}
@media (max-width: 768px) {
  #app-screen.home-view .module-grid-wrap { padding: 4px 16px 24px; }
  #app-screen.home-view .home-greeting {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  #app-screen.home-view .tv-clock { text-align: left; }
  #app-screen.home-view .tv-stage-hint { display: none; }
  #app-screen.home-view .module-title[data-short]::before { content: none; }
}
@media (max-width: 480px) {
  #app-screen.home-view .module-title[data-short]::before { content: none; }
}

/* Home desk: sticky note + shared to-do */
#app-screen.home-view .home-desk {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: clamp(14px, 2vw, 24px);
  width: 100%;
  margin-top: 8px;
  padding: 8px 6px 12px;
}
#app-screen.home-view .home-desk-heading {
  grid-column: 1 / -1;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.55);
}
#app-screen.home-view .home-sticky {
  position: relative;
  min-width: 0;
  min-height: clamp(200px, 28vh, 420px);
  padding: clamp(20px, 2vw, 36px) clamp(16px, 1.6vw, 28px) clamp(14px, 1.2vw, 22px);
  border-radius: 3px 16px 14px 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), transparent 28%),
    linear-gradient(180deg, #fff6cc 0%, #f8e7a0 100%);
  color: #3d3118;
  box-shadow:
    0 16px 34px rgba(0, 0, 0, 0.28),
    0 1px 0 rgba(255, 255, 255, 0.7) inset;
  transform: rotate(-0.5deg);
}
#app-screen.home-view .home-sticky-tape {
  position: absolute;
  top: -10px;
  left: 50%;
  width: 74px;
  height: 18px;
  margin-left: -37px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}
#app-screen.home-view .home-sticky-head h3,
#app-screen.home-view .home-todo-head h3 {
  margin: 0;
  font-size: clamp(1.05rem, min(1.45cqi, 0.5cqi + 0.85rem), 1.35rem);
  letter-spacing: -0.02em;
}
#app-screen.home-view .home-sticky-head p,
#app-screen.home-view .home-todo-head p {
  margin: 4px 0 0;
  font-size: clamp(0.8rem, min(0.95cqi, 0.35cqi + 0.62rem), 0.95rem);
  line-height: 1.4;
}
#app-screen.home-view .home-sticky-head p { color: rgba(80, 58, 20, 0.72); }
#app-screen.home-view .home-sticky textarea {
  display: block;
  width: 100%;
  min-height: clamp(140px, 22cqi, 320px);
  margin-top: 12px;
  padding: 2px 2px 0;
  border: 0;
  resize: vertical;
  background-color: transparent;
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent calc(1.75em - 1px),
    rgba(120, 86, 28, 0.2) 1.75em
  );
  background-attachment: local;
  color: #3d3118;
  font: inherit;
  font-size: clamp(0.95rem, min(1.05cqi, 0.4cqi + 0.75rem), 1.1rem);
  line-height: 1.75;
  outline: none;
}
#app-screen.home-view .home-sticky textarea::placeholder { color: rgba(80, 58, 20, 0.45); }
#app-screen.home-view .home-sticky-status {
  min-height: 1.1em;
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: rgba(80, 58, 20, 0.62);
}
#app-screen.home-view .home-todo {
  min-width: 0;
  min-height: clamp(200px, 28vh, 420px);
  padding: clamp(16px, 1.6vw, 28px) clamp(14px, 1.4vw, 24px) clamp(14px, 1.2vw, 20px);
  border-radius: clamp(16px, min(1.5cqi, 0.45cqi + 14px), 22px);
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.22);
  color: #f8fafc;
  backdrop-filter: blur(10px);
}
#app-screen.home-view .home-todo-head p { color: rgba(226, 232, 240, 0.68); }
#app-screen.home-view .home-todo-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(8.5rem, 18cqi) auto;
  gap: 8px;
  margin-top: 14px;
}
#app-screen.home-view .home-todo-form input,
#app-screen.home-view .home-todo-form select {
  width: 100%;
  min-width: 0;
  height: var(--tv-control, 42px);
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #f8fafc;
  font: inherit;
  font-size: clamp(0.88rem, min(1cqi, 0.35cqi + 0.7rem), 1rem);
}
#app-screen.home-view .home-todo-assign {
  position: relative;
  min-width: 0;
}
#app-screen.home-view .home-todo-assign-native {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  pointer-events: none;
}
#app-screen.home-view .home-todo-assign-btn {
  position: relative;
  display: block;
  width: 100%;
  height: var(--tv-control, 42px);
  padding: 0 34px 0 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    #0f172a;
  color: #f8fafc;
  font: inherit;
  font-size: clamp(0.88rem, min(1cqi, 0.35cqi + 0.7rem), 1rem);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
#app-screen.home-view .home-todo-assign-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 14px;
  margin-top: 2px;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-top-color: #e2e8f0;
}
#app-screen.home-view .home-todo-assign-btn[aria-expanded="true"]::after {
  margin-top: -2px;
  border-top-color: transparent;
  border-bottom-color: #e2e8f0;
}
#app-screen.home-view .home-todo-assign-btn:focus {
  outline: 2px solid rgba(129, 140, 248, 0.8);
  outline-offset: 1px;
}
#app-screen.home-view .home-todo-assign-menu {
  position: absolute;
  z-index: 6;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 6px;
  list-style: none;
  max-height: 220px;
  overflow: auto;
  border-radius: 12px;
  background: #0b1220;
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.45);
}
#app-screen.home-view .home-todo-assign-menu[hidden] { display: none; }
#app-screen.home-view .home-todo-assign-menu.is-up {
  top: auto;
  bottom: calc(100% + 6px);
}
#app-screen.home-view .home-todo-assign-option {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #f8fafc;
  font: inherit;
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
}
#app-screen.home-view .home-todo-assign-option:hover,
#app-screen.home-view .home-todo-assign-option.is-selected {
  background: rgba(129, 140, 248, 0.22);
  color: #fff;
}
#app-screen.home-view .home-todo-form input:focus,
#app-screen.home-view .home-todo-form select:focus {
  outline: 2px solid rgba(129, 140, 248, 0.8);
  outline-offset: 1px;
}
#app-screen.home-view .home-todo-add {
  height: var(--tv-control, 42px);
  padding: 0 clamp(14px, 1.2vw, 22px);
  border: 0;
  border-radius: 12px;
  background: #eef2ff;
  color: #312e81;
  font: inherit;
  font-size: clamp(0.88rem, min(1cqi, 0.35cqi + 0.7rem), 1rem);
  font-weight: 700;
  cursor: pointer;
}
#app-screen.home-view .home-todo-add:hover { background: #fff; }
#app-screen.home-view .home-todo-lists {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
  max-height: min(420px, 46vh);
  overflow: auto;
  padding-right: 2px;
}
#app-screen.home-view .home-todo-group h4 {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.55);
}
#app-screen.home-view .home-todo-group ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#app-screen.home-view .home-todo-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: 10px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
}
#app-screen.home-view .home-todo-item.is-done { opacity: 0.62; }
#app-screen.home-view .home-todo-check {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: #818cf8;
  cursor: pointer;
}
#app-screen.home-view .home-todo-copy { min-width: 0; }
#app-screen.home-view .home-todo-title {
  display: block;
  font-size: 0.95rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
#app-screen.home-view .home-todo-item.is-done .home-todo-title {
  text-decoration: line-through;
}
#app-screen.home-view .home-todo-meta {
  display: block;
  margin-top: 3px;
  font-size: 0.75rem;
  color: rgba(226, 232, 240, 0.62);
}
#app-screen.home-view .home-todo-delete {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(226, 232, 240, 0.7);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
}
#app-screen.home-view .home-todo-delete:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
#app-screen.home-view .home-todo-empty {
  margin: 8px 0 0;
  font-size: 0.9rem;
  color: rgba(226, 232, 240, 0.62);
}
@media (max-width: 980px) {
  #app-screen.home-view .home-desk { grid-template-columns: 1fr; }
  #app-screen.home-view .home-sticky { transform: none; }
}
@media (max-width: 640px) {
  #app-screen.home-view .home-todo-form { grid-template-columns: 1fr; }
  #app-screen.home-view .home-todo-add { width: 100%; }
  #app-screen.home-view .module-grid-wrap .module-grid,
  #app-screen.home-view .module-grid { padding: 20px 22px 32px; }
  #app-screen.home-view .home-sticky,
  #app-screen.home-view .home-todo { min-height: 0; }
  #app-screen.home-view .home-sticky textarea { min-height: 140px; }
}
