/* ==========================================================================
   Layout: login screen, app shell (sidebar + topbar), page header, responsive
   ========================================================================== */

/* ---- Login ---- */
.login-scene {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  min-height: 100dvh;
}
.login-identity {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  padding: clamp(28px, 5vw, 64px);
  color: #fff;
  overflow: hidden;
  background: var(--grad-ink);
}
.login-identity::before,
.login-identity::after {
  content: '';
  position: absolute;
  z-index: -1;
  border-radius: 50%;
  filter: blur(60px);
  animation: drift 16s ease-in-out infinite;
}
.login-identity::before {
  width: 520px;
  height: 520px;
  inset-block-start: -140px;
  inset-inline-end: -120px;
  background: radial-gradient(circle, rgb(43 196 214 / 0.55), transparent 65%);
}
.login-identity::after {
  width: 440px;
  height: 440px;
  inset-block-end: -160px;
  inset-inline-start: -100px;
  background: radial-gradient(circle, rgb(242 154 61 / 0.38), transparent 65%);
  animation-delay: -6s;
}
.identity-core::before {
  /* concentric rings: a quiet echo of the progress ring used across the app */
  content: '';
  position: absolute;
  z-index: -1;
  width: 460px;
  height: 460px;
  inset-block-start: 50%;
  inset-inline-end: -140px;
  translate: 0 -50%;
  border-radius: 50%;
  background: repeating-radial-gradient(circle, transparent 0 46px, rgb(255 255 255 / 0.07) 47px 48px);
  mask-image: radial-gradient(circle, #000 30%, transparent 72%);
  -webkit-mask-image: radial-gradient(circle, #000 30%, transparent 72%);
}
.login-topmark {
  direction: ltr;
  display: flex;
  align-items: center;
  gap: 8px;
  font: 400 var(--fs-lg) var(--font-display);
  letter-spacing: 0.02em;
}
.login-topmark b {
  font-weight: 700;
}
.small-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--glaze-500);
  box-shadow: 0 0 0 4px rgb(242 154 61 / 0.25);
}
.identity-core {
  position: relative;
  display: grid;
  gap: 18px;
  max-width: 560px;
}
.identity-core h1 {
  font-size: clamp(2.1rem, 1.3rem + 3vw, 3.7rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
}
.intro-muted {
  max-width: 46ch;
  color: rgb(255 255 255 / 0.72);
  font-size: var(--fs-lg);
  line-height: 1.8;
}
.brand-logos {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}
.brand-logos span {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 18px 8px 8px;
  font: 600 var(--fs-sm) var(--font-display);
  letter-spacing: 0.03em;
  color: #fff;
  border: 1px solid rgb(255 255 255 / 0.2);
  border-radius: var(--r-pill);
  background: rgb(255 255 255 / 0.1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition:
    transform var(--t-base) var(--ease-out),
    background-color var(--t-base);
  animation: riseIn var(--t-slow) var(--ease-out) both;
}
.brand-logos span:nth-child(2) {
  animation-delay: 80ms;
}
.brand-logos span:nth-child(3) {
  animation-delay: 160ms;
}
.brand-logos span:hover {
  transform: translateY(-3px);
  background: rgb(255 255 255 / 0.18);
}
.brand-logos img {
  width: 40px;
  height: 40px;
  padding: 3px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
}
.login-bottom {
  color: rgb(255 255 255 / 0.5);
  font-size: var(--fs-xs);
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 500 var(--fs-sm) var(--font-display);
  color: var(--aqua-600);
}
.eyebrow::before {
  content: '';
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.eyebrow.on-dark {
  color: var(--aqua-200);
}

.login-form-wrap {
  position: relative;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 28px;
  background: var(--grad-page);
}
.lang-login {
  position: absolute;
  inset-block-start: 20px;
  inset-inline-end: 20px;
}
.login-form {
  display: grid;
  gap: 16px;
  width: min(440px, 100%);
  padding: clamp(26px, 4vw, 40px);
  border: 1px solid rgb(255 255 255 / 0.9);
  border-radius: var(--r-xl);
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  box-shadow: var(--sh-3);
  animation: riseIn 0.7s var(--ease-out) both;
}
.login-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  color: #fff;
  background: var(--grad-brand);
  box-shadow: var(--sh-brand);
}
.login-icon .ico {
  width: 26px;
  height: 26px;
  stroke-width: 2.2;
}
.login-form h2 {
  font-size: var(--fs-2xl);
  font-weight: 600;
}
.subheading {
  margin-top: -8px;
  color: var(--text-soft);
}
.login-form label {
  display: grid;
  gap: 7px;
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink-700);
}
.login-form label span {
  display: none;
}
.login-form input {
  min-height: 52px;
  font-size: var(--fs-md);
}
.auth-error,
.setup-warning {
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  line-height: 1.6;
  animation: riseIn var(--t-base) var(--ease-out) both;
}
.auth-error {
  color: var(--coral-700);
  background: var(--coral-100);
  border: 1px solid rgb(234 93 79 / 0.3);
}
.setup-warning {
  color: var(--glaze-700);
  background: var(--glaze-100);
  border: 1px solid rgb(242 154 61 / 0.4);
}
.security-foot {
  padding-top: 4px;
  text-align: center;
  color: var(--ink-400);
  font-size: var(--fs-xs);
}

/* ---- App shell ---- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100dvh;
}
.sidebar {
  position: sticky;
  inset-block-start: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100dvh;
  padding: 22px 16px 16px;
  overflow-y: auto;
  color: #fff;
  background: var(--grad-ink);
  border-inline-end: 1px solid rgb(255 255 255 / 0.06);
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 18px;
}
.side-brand strong {
  display: block;
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: 0.02em;
}
.side-brand small {
  color: rgb(255 255 255 / 0.5);
}
.logo-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  font: 700 22px var(--font-display);
  color: #fff;
  background: var(--grad-brand);
  box-shadow: var(--sh-brand);
}
.logo-mark span {
  position: absolute;
  inset-block-end: -3px;
  inset-inline-end: -3px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  font-size: 0;
  background: var(--glaze-500);
  border: 2px solid var(--ink-900);
}
.side-section-label {
  padding: 14px 12px 6px;
  color: rgb(255 255 255 / 0.42);
  font: 500 var(--fs-xs) var(--font-display);
}
.main-nav {
  display: grid;
  gap: 4px;
}
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border-radius: var(--r-md);
  color: rgb(255 255 255 / 0.74);
  text-align: start;
  font: 500 var(--fs-md) var(--font-display);
  transition:
    background-color var(--t-base) var(--ease-out),
    color var(--t-base) var(--ease-out),
    transform var(--t-base) var(--ease-out);
}
.nav-item small {
  display: block;
  margin-top: 1px;
  color: rgb(255 255 255 / 0.4);
  font-weight: 400;
}
.nav-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: rgb(255 255 255 / 0.07);
  transition:
    background-color var(--t-base),
    transform var(--t-base) var(--ease-spring);
}
.nav-icon .ico {
  width: 19px;
  height: 19px;
}
.nav-item:hover {
  color: #fff;
  background: rgb(255 255 255 / 0.08);
}
.nav-item:hover .nav-icon {
  transform: scale(1.1) rotate(-4deg);
}
.nav-item:active .nav-icon {
  transform: scale(0.92);
}
.nav-item.active {
  color: #fff;
  background: linear-gradient(135deg, rgb(255 255 255 / 0.16), rgb(255 255 255 / 0.06));
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.12);
}
.nav-item.active .nav-icon {
  background: var(--grad-brand);
  box-shadow: var(--sh-brand);
}
.nav-item.active::after {
  content: '';
  position: absolute;
  inset-inline-end: -16px;
  inset-block: 12px;
  width: 4px;
  border-radius: 4px 0 0 4px;
  background: var(--aqua-400);
}
html[dir='rtl'] .nav-item.active::after {
  border-radius: 4px 0 0 4px;
}
html[dir='ltr'] .nav-item.active::after {
  border-radius: 0 4px 4px 0;
}
.sidebar-divider {
  height: 1px;
  margin: 12px 10px 4px;
  background: rgb(255 255 255 / 0.09);
}
.brand-selector {
  display: grid;
  gap: 8px;
  padding: 2px 0 10px;
}
.side-brand-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 12px 9px 9px;
  border: 1px solid rgb(255 255 255 / 0.09);
  border-radius: var(--r-md);
  background: rgb(255 255 255 / 0.05);
  color: #fff;
  text-align: start;
  transition:
    background-color var(--t-base) var(--ease-out),
    transform var(--t-base) var(--ease-out),
    border-color var(--t-base);
}
.side-brand-option img {
  width: 38px;
  height: 38px;
  padding: 3px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
}
.side-brand-option span {
  font: 600 var(--fs-sm) var(--font-display);
}
.side-brand-option small {
  display: block;
  margin-top: 2px;
  color: rgb(255 255 255 / 0.5);
  font: 400 var(--fs-xs) var(--font-body);
}
.side-brand-option:hover {
  background: rgb(255 255 255 / 0.11);
  transform: translateX(-2px);
}
html[dir='ltr'] .side-brand-option:hover {
  transform: translateX(2px);
}
.side-brand-option.selected {
  border-color: var(--aqua-400);
  background: rgb(43 184 214 / 0.18);
}
.sidebar-bottom {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: auto;
  padding: 12px;
  border-radius: var(--r-md);
  background: rgb(255 255 255 / 0.06);
  border: 1px solid rgb(255 255 255 / 0.08);
}
.avatar,
.mini-avatar {
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  color: #fff;
  font: 600 var(--fs-md) var(--font-display);
  background: linear-gradient(135deg, var(--glaze-500), #e0752b);
}
.avatar {
  width: 40px;
  height: 40px;
}
.mini-avatar {
  width: 34px;
  height: 34px;
  font-size: var(--fs-sm);
}
.sidebar-user {
  min-width: 0;
  flex: 1;
}
.sidebar-user b {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--fs-sm);
}
.sidebar-user small {
  color: rgb(255 255 255 / 0.5);
}
.logout-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  color: rgb(255 255 255 / 0.7);
  transition:
    background-color var(--t-base),
    color var(--t-base),
    transform var(--t-base) var(--ease-spring);
}
.logout-icon:hover {
  color: #fff;
  background: rgb(234 93 79 / 0.3);
  transform: scale(1.08);
}
.logout-icon .ico {
  width: 19px;
  height: 19px;
}

/* ---- Topbar + page ---- */
.main-panel {
  min-width: 0;
}
.topbar {
  position: sticky;
  inset-block-start: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: var(--topbar-h);
  padding: 10px clamp(16px, 3vw, 36px);
  background: rgb(237 243 246 / 0.78);
  backdrop-filter: blur(18px) saturate(1.5);
  -webkit-backdrop-filter: blur(18px) saturate(1.5);
  border-bottom: 1px solid var(--line);
}
.header-lead {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.breadcrumb {
  color: var(--ink-400);
  font-size: var(--fs-xs);
}
.breadcrumb span {
  color: inherit;
}
#page-title {
  font-size: var(--fs-xl);
  font-weight: 600;
  line-height: 1.3;
}
.mobile-menu {
  display: none;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-strong);
  background: var(--glass-strong);
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: var(--r-pill);
  color: var(--mint-700);
  background: var(--mint-100);
  font: 600 var(--fs-xs) var(--font-display);
  white-space: nowrap;
}
.live-pill i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mint-500);
  animation: pulseDot 2.2s ease-in-out infinite;
}
.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 14px 4px 5px;
  border-radius: var(--r-pill);
  background: var(--glass-strong);
  border: 1px solid var(--line);
  font: 500 var(--fs-sm) var(--font-display);
}
.page-body {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding: clamp(18px, 3vw, 36px);
}
.view {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 26px;
  align-content: start;
}
.page-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.page-intro > div:first-child {
  display: grid;
  gap: 6px;
}
.sub {
  color: var(--text-soft);
  font-size: var(--fs-sm);
}
.head-actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.head-actions label {
  display: grid;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 500;
  color: var(--ink-500);
}
.head-actions select,
.head-actions input {
  min-height: 42px;
  min-width: 170px;
}
.section-heading {
  margin-block-start: 30px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.section-heading small {
  color: var(--text-soft);
}
#scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgb(6 28 39 / 0.5);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
}
#scrim.show {
  opacity: 1;
  pointer-events: auto;
}

/* ---- Responsive ---- */
@media (max-width: 1100px) {
  .live-pill {
    display: none;
  }
}
@media (max-width: 960px) {
  .login-scene {
    grid-template-columns: 1fr;
  }
  .login-identity {
    gap: 24px;
    padding: 28px 24px 34px;
  }
  .identity-core h1 br {
    display: none;
  }
  .login-bottom {
    display: none;
  }
  .login-form-wrap {
    padding: 24px 16px 40px;
    margin-top: -24px;
  }
  .lang-login {
    inset-block-start: -8px;
  }
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(320px, 86vw);
    transform: translateX(var(--slide-out));
    visibility: hidden;
    transition: transform var(--t-slow) var(--ease-out), visibility 0s linear var(--t-slow);
    box-shadow: none;
  }
  .sidebar.open {
    transform: none;
    visibility: visible;
    transition: transform var(--t-slow) var(--ease-out), visibility 0s;
    box-shadow: var(--sh-3);
  }
  .mobile-menu {
    display: grid;
  }
  .header-user span {
    display: none;
  }
  .header-user {
    padding: 4px;
  }
}
@media (max-width: 560px) {
  .topbar {
    padding-inline: 12px;
  }
  .breadcrumb {
    display: none;
  }
  .head-actions {
    width: 100%;
  }
  .head-actions > * {
    flex: 1 1 140px;
    min-width: 0;
  }
  .page-intro,
  .page-intro > * {
    min-width: 0;
    max-width: 100%;
  }
  .head-actions select,
  .head-actions input {
    min-width: 0;
    width: 100%;
  }
  #toast {
    inset-inline: 12px;
    inset-block-end: 12px;
    max-width: none;
  }
}
