/* App shell — Paramatik-calibre layout */

.app-root {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  background: var(--bg-0);
  color: var(--text-1);
}

.app-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse 80% 45% at 50% -8%, var(--brand-glow), transparent 55%);
  opacity: 0.45;
}
[data-theme="dark"] .app-glow { opacity: 0.35; }

.app-shell {
  position: relative;
  z-index: 1;
  max-width: var(--shell-max);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 1024px) {
  .app-shell--auth {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "sidebar header"
      "sidebar main";
  }
}

/* Sidebar (desktop) */
.app-sidebar {
  display: none;
}
@media (min-width: 1024px) {
  .app-sidebar {
    display: flex;
    flex-direction: column;
    grid-area: sidebar;
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    width: var(--sidebar-w);
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    padding: 1.25rem 1rem;
    overflow-y: auto;
  }
}

.app-sidebar__brand { margin-bottom: 1.25rem; padding: 0 0.5rem; }

.app-sidebar__user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  margin-bottom: 1.25rem;
  border-radius: calc(var(--card-radius) - 4px);
  background: var(--bg-2);
  border: 1px solid var(--border-subtle);
}
.app-sidebar__avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: var(--brand);
  color: var(--on-brand);
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}
.app-sidebar__user-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-0);
  line-height: 1.2;
}
.app-sidebar__user-role {
  font-size: 0.75rem;
  color: var(--text-3);
}

.app-nav-group { margin-bottom: 1.25rem; }
.app-nav-group__title {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-4);
  padding: 0 0.75rem;
  margin: 0 0 0.35rem;
}
.app-nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  margin: 0.125rem 0;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-2);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background var(--duration) var(--ease), color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}
.app-nav-link:hover {
  background: var(--bg-2);
  color: var(--text-0);
}
.app-nav-link.active {
  background: var(--brand-dim);
  color: var(--brand-hover);
  border-color: var(--brand-border);
  box-shadow: inset 3px 0 0 var(--brand);
}
.app-nav-link--danger { color: var(--red); margin-top: auto; }
.app-nav-link--danger:hover { background: var(--red-dim); }

.app-sidebar__footer {
  margin-top: auto;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem var(--page-pad);
  padding-top: calc(0.75rem + env(safe-area-inset-top, 0));
  background: var(--glass);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  min-width: 0;
}
@media (min-width: 1024px) {
  .app-header { grid-area: header; }
  .app-header__menu { display: none; }
}

.app-header__left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.app-header__menu {
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-1);
  cursor: pointer;
  display: grid;
  place-items: center;
  color: var(--text-1);
  flex-shrink: 0;
}
.app-header__title {
  font-family: var(--display);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-0);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-header__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* Main */
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
@media (min-width: 1024px) {
  .app-main { grid-area: main; }
}

.app-main--guest {
  align-items: center;
  justify-content: center;
  padding: var(--page-pad);
}

.app-content {
  flex: 1;
  width: 100%;
  max-width: 100%;
  padding: var(--page-pad);
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0) + var(--page-pad));
}
@media (min-width: 1024px) {
  .app-content {
    padding-bottom: var(--page-pad);
    max-width: min(100%, 56rem);
  }
  .app-content--wide { max-width: min(100%, 80rem); }
}

/* Mobile drawer */
.app-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 60;
  animation: app-fade-in var(--duration) var(--ease);
}
.app-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(88vw, var(--sidebar-w));
  background: var(--bg-1);
  z-index: 70;
  padding: 1rem;
  overflow-y: auto;
  box-shadow: 8px 0 32px rgba(0, 0, 0, 0.12);
  animation: app-slide-in var(--duration) var(--ease);
}
@keyframes app-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes app-slide-in { from { transform: translateX(-100%); } to { transform: translateX(0); } }

/* Bottom nav */
.app-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  min-height: 56px;
  padding-bottom: env(safe-area-inset-bottom, 0);
  background: var(--glass);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
}
@media (min-width: 1024px) {
  .app-bottom-nav { display: none; }
}

.app-bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  padding: 0.5rem 0.25rem;
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--text-3);
  text-decoration: none;
  border: none;
  background: none;
  min-height: 56px;
  transition: color var(--duration) var(--ease);
}
.app-bottom-nav__item.active { color: var(--brand); }
.app-bottom-nav__item svg {
  width: 1.25rem;
  height: 1.25rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-1);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color var(--duration), background var(--duration);
}
.theme-toggle:hover { border-color: var(--brand-border); }
.theme-toggle svg {
  width: 1rem;
  height: 1rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

/* Brand logo */
.brand-logo-link { display: inline-block; color: inherit; text-decoration: none; }
.brand-logo {
  display: inline-flex;
  align-items: baseline;
  gap: 0.44em;
  color: var(--text-0);
  font-family: var(--display);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}
.tenant-brand-logo__name {
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.tenant-brand-logo__clinic {
  color: #0f766e;
  font-weight: 700;
}
.lucide--nav { flex-shrink: 0; opacity: 0.85; }
.app-nav-link.active .lucide--nav { opacity: 1; }
.brand-logo--hero { font-size: clamp(1.5rem, 3.2vw, 2.25rem); }
.brand-logo--sidebar { font-size: 1.15rem; }
.brand-logo--nav { font-size: 1.05rem; }
.brand-logo--sm { font-size: 0.95rem; }

/* Guest login */
.app-guest-card {
  width: 100%;
  max-width: 420px;
  padding: var(--card-pad);
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-md);
}

.auth-login {
  width: min(100%, 1040px);
  min-height: min(760px, calc(100svh - 40px));
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 440px);
  align-items: stretch;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  background: var(--bg-1);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
}

.auth-login__brand {
  display: flex;
  align-items: stretch;
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(8, 47, 73, 0.96), rgba(15, 23, 42, 0.98) 58%, rgba(20, 83, 45, 0.95)),
    #0f172a;
  color: #f8fafc;
}

.auth-login__brand-inner {
  width: 100%;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: clamp(26px, 4vw, 44px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background:
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.055) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 72px);
}

.auth-login__logo .brand-logo {
  color: #ffffff;
}

.auth-login__logo .tenant-brand-logo__clinic {
  color: #99f6e4;
}

.auth-login__eyebrow {
  margin: 0 0 12px;
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(204, 251, 241, 0.92);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.auth-login h1 {
  max-width: 11ch;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.4rem, 5vw, 4.8rem);
  line-height: 0.96;
  font-weight: 700;
  color: #ffffff;
}

.auth-login__lead {
  max-width: 30rem;
  margin: 22px 0 0;
  font-size: clamp(1rem, 1.7vw, 1.2rem);
  line-height: 1.55;
  color: rgba(226, 232, 240, 0.82);
}

.auth-login__preview {
  display: grid;
  gap: 10px;
  max-width: 420px;
}

.auth-login__preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 54px;
  padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.075);
}

.auth-login__preview-row span {
  font-weight: 600;
  color: rgba(248, 250, 252, 0.88);
}

.auth-login__preview-row strong {
  color: #99f6e4;
  font-weight: 700;
}

.auth-login__card {
  max-width: none;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: clamp(34px, 5vw, 64px);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

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

.auth-login__mobile-brand .brand-logo {
  justify-content: center;
}

.auth-login__mobile-brand p {
  margin: 14px 0 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-2);
}

.auth-login__form {
  width: 100%;
  max-width: 420px;
  gap: 1.15rem;
}

.auth-login__form .ui-label {
  margin-bottom: 0.55rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-1);
}

.auth-login__input {
  width: 100%;
  height: 58px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  background: #ffffff;
  color: var(--text-0);
  font-size: 1.04rem;
  font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.04), 0 1px 2px rgba(15, 23, 42, 0.04);
}

.auth-login__input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.16);
}

.auth-login__submit {
  width: 100%;
  height: 60px;
  margin-top: 0.8rem;
  border-radius: 10px;
  background: #0f766e;
  color: #ffffff;
  font-size: 1.04rem;
  font-weight: 800;
  box-shadow: 0 14px 28px rgba(15, 118, 110, 0.22);
}

.auth-login__submit:hover:not(:disabled) {
  filter: none;
  background: #115e59;
}

.auth-login__submit:disabled {
  cursor: wait;
  opacity: 0.72;
}

.auth-login__register {
  margin-top: 0.9rem;
  color: #0f766e;
  font-size: 0.98rem;
  font-weight: 700;
}

.auth-login__register:hover {
  color: #115e59;
}

@media (max-width: 820px) {
  .app-main--guest {
    align-items: flex-start;
    justify-content: flex-start;
    min-height: 100svh;
    padding: max(18px, env(safe-area-inset-top, 0px)) 16px max(24px, env(safe-area-inset-bottom, 0px));
    background:
      linear-gradient(180deg, rgba(204, 251, 241, 0.55), rgba(244, 244, 245, 0) 42%),
      var(--bg-0);
  }

  .auth-login {
    display: block;
    min-height: auto;
    border-radius: var(--card-radius);
    box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
  }

  .auth-login__brand {
    display: none;
  }

  .auth-login__card {
    min-height: auto;
    padding: 34px 26px 32px;
    border-radius: var(--card-radius);
  }

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

  .auth-login__mobile-brand .brand-logo {
    margin: 0 auto;
  }

  .auth-login__mobile-brand p {
    font-size: 0.98rem;
  }

  .auth-login__input,
  .auth-login__submit {
    height: 56px;
  }
}

@media (min-width: 821px) {
  .auth-login__mobile-brand {
    display: none;
  }
}

/* Pilot dashboard — premium stats */
.app-page-header {
  margin-bottom: var(--section-gap);
}
.app-page-header h1 {
  font-family: var(--display);
  font-size: clamp(1.25rem, 3vw, 1.5rem);
  font-weight: 600;
  color: var(--text-0);
  margin: 0 0 0.35rem;
}
.app-page-header p {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-3);
}

.app-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.75rem;
  margin-bottom: var(--section-gap);
}
.app-stat-card {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  transition: border-color var(--duration), box-shadow var(--duration), transform var(--duration);
}
.app-stat-card:hover {
  border-color: var(--brand-border);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.app-stat-card__label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 0.35rem;
}
.app-stat-card__value {
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-0);
}

.app-hero-revenue {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: var(--card-pad);
  margin-bottom: var(--section-gap);
  box-shadow: var(--shadow);
}
.app-hero-revenue__label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}
.app-hero-revenue__value {
  font-family: var(--display);
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 600;
  color: var(--text-0);
  margin: 0.35rem 0 1rem;
}

.app-quick-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: var(--section-gap);
}
.app-quick-pill {
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-1);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-1);
  text-decoration: none;
  transition: border-color var(--duration), background var(--duration);
}
.app-quick-pill:hover {
  border-color: var(--brand-border);
  background: var(--brand-dim);
  color: var(--brand-hover);
}

/* Focus */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
