:root {
  color-scheme: light;
  --navy-950: #0b1228;
  --navy-900: #101a37;
  --navy-800: #18264a;
  --blue-600: #2457d6;
  --blue-500: #3973ee;
  --blue-100: #eaf0ff;
  --green-600: #18835d;
  --green-100: #e8f7f1;
  --slate-900: #172033;
  --slate-700: #3a465d;
  --slate-500: #69758c;
  --slate-300: #cfd6e3;
  --slate-200: #e3e8f0;
  --slate-100: #f3f6fa;
  --white: #ffffff;
  --danger: #b42318;
  --danger-bg: #fef3f2;
  --shadow: 0 24px 60px rgba(16, 26, 55, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--slate-900);
  background: var(--slate-100);
  line-height: 1.5;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(480px, 1.1fr);
}

.auth-brand {
  min-height: 100vh;
  padding: 46px clamp(34px, 6vw, 92px);
  color: var(--white);
  background:
    radial-gradient(circle at 12% 12%, rgba(57, 115, 238, 0.34), transparent 32%),
    radial-gradient(circle at 90% 78%, rgba(36, 87, 214, 0.26), transparent 34%),
    linear-gradient(145deg, var(--navy-950), var(--navy-900) 55%, #142755);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.auth-brand::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 50%;
  right: -190px;
  top: 20%;
  box-shadow: 0 0 0 70px rgba(255,255,255,0.025), 0 0 0 140px rgba(255,255,255,0.018);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--navy-900);
  text-decoration: none;
  position: relative;
  z-index: 1;
}

.brand-light { color: var(--white); }

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--blue-500), var(--blue-600));
  color: var(--white);
  display: grid;
  place-items: center;
  font-weight: 800;
  letter-spacing: -0.04em;
  box-shadow: 0 10px 26px rgba(36, 87, 214, 0.28);
}

.brand strong, .brand small { display: block; }
.brand strong { font-size: 1rem; }
.brand small { color: inherit; opacity: 0.66; font-size: 0.74rem; }

.brand-message { max-width: 610px; position: relative; z-index: 1; }
.brand-message h1 { font-size: clamp(2.25rem, 4vw, 4rem); line-height: 1.08; letter-spacing: -0.045em; margin: 14px 0 24px; }
.brand-message > p:last-child { max-width: 540px; color: rgba(255,255,255,0.72); font-size: 1.08rem; }
.brand-foot { color: rgba(255,255,255,0.48); font-size: 0.82rem; margin: 0; position: relative; z-index: 1; }

.auth-main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 42px;
  background: var(--white);
}

.auth-card { width: min(100%, 440px); }
.auth-card h2 { font-size: clamp(1.8rem, 3vw, 2.35rem); line-height: 1.2; letter-spacing: -0.035em; margin: 8px 0 10px; }
.muted { color: var(--slate-500); }
.auth-card .muted { margin: 0 0 30px; }

.eyebrow { margin: 0; color: var(--slate-500); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.13em; text-transform: uppercase; }
.eyebrow.accent { color: var(--blue-600); }

form { display: grid; gap: 10px; }
label { margin-top: 10px; color: var(--slate-700); font-size: 0.84rem; font-weight: 700; }
input {
  width: 100%;
  height: 50px;
  border: 1px solid var(--slate-300);
  border-radius: 11px;
  background: var(--white);
  color: var(--slate-900);
  padding: 0 14px;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
input:focus { border-color: var(--blue-500); box-shadow: 0 0 0 4px rgba(57,115,238,0.12); }

.password-field { position: relative; }
.password-field input { padding-right: 82px; }
.password-toggle { position: absolute; right: 8px; top: 7px; height: 36px; padding: 0 9px; border: 0; background: transparent; color: var(--blue-600); font-size: 0.78rem; font-weight: 700; cursor: pointer; }

.button {
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0 18px;
  font-weight: 750;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: 0.62; cursor: wait; }
.button.primary { background: var(--blue-600); color: var(--white); box-shadow: 0 10px 25px rgba(36,87,214,0.2); }
.button.primary:hover:not(:disabled) { background: #1d4fc8; }
.button.secondary { background: var(--white); color: var(--slate-700); border-color: var(--slate-300); }
.button.full { width: 100%; margin-top: 18px; }

.help-text, .field-hint { color: var(--slate-500); font-size: 0.78rem; }
.help-text { margin: 22px 0 0; text-align: center; }
.field-hint { margin: -4px 0 2px; }

.message { margin-top: 20px; border-radius: 10px; padding: 12px 14px; font-size: 0.86rem; }
.message.error { color: var(--danger); background: var(--danger-bg); border: 1px solid #fecdca; }
.message.success { color: #067647; background: #ecfdf3; border: 1px solid #abefc6; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 256px 1fr; }
.sidebar {
  min-height: 100vh;
  position: sticky;
  top: 0;
  background: var(--white);
  border-right: 1px solid var(--slate-200);
  padding: 28px 22px 20px;
  display: flex;
  flex-direction: column;
  z-index: 10;
}
.main-nav { display: grid; gap: 6px; margin-top: 44px; }
.nav-item { min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 12px; border-radius: 9px; text-decoration: none; color: var(--slate-700); font-size: 0.9rem; font-weight: 650; }
.nav-item.active { background: var(--blue-100); color: var(--blue-600); }
.nav-item.disabled { color: var(--slate-500); cursor: default; }
.nav-item span { font-size: 0.59rem; font-weight: 750; color: var(--slate-500); }
.sidebar-account { margin-top: auto; padding: 18px 4px 0; border-top: 1px solid var(--slate-200); display: flex; align-items: center; gap: 11px; min-width: 0; }
.sidebar-account strong, .sidebar-account small { display: block; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-account strong { font-size: 0.84rem; }
.sidebar-account small { color: var(--slate-500); font-size: 0.68rem; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; background: var(--navy-900); color: white; font-weight: 800; }

.app-main { min-width: 0; }
.topbar { height: 76px; padding: 0 clamp(24px, 4vw, 54px); background: rgba(255,255,255,0.92); border-bottom: 1px solid var(--slate-200); display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 5; backdrop-filter: blur(12px); }
.topbar > div { flex: 1; }
.topbar-label { display: block; color: var(--slate-500); font-size: 0.67rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.08em; }
.topbar strong { font-size: 0.9rem; }
.menu-button { display: none; min-height: 40px; border-radius: 8px; border: 1px solid var(--slate-300); background: var(--white); color: var(--slate-700); padding: 0 12px; font-weight: 700; }

.dashboard { width: min(1220px, 100%); margin: 0 auto; padding: clamp(28px, 4vw, 54px); }
.welcome-panel { border-radius: 20px; padding: clamp(26px, 4vw, 46px); background: linear-gradient(135deg, var(--navy-950), #162b5e); color: white; display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; box-shadow: var(--shadow); }
.welcome-panel h1 { margin: 8px 0 10px; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.12; letter-spacing: -0.04em; }
.welcome-panel > div:first-child > p:last-child { max-width: 680px; margin: 0; color: rgba(255,255,255,0.7); }
.connection-status { flex: 0 0 auto; border: 1px solid rgba(255,255,255,0.14); border-radius: 999px; padding: 9px 13px; color: rgba(255,255,255,0.78); font-size: 0.76rem; }
.connection-status span { width: 8px; height: 8px; display: inline-block; border-radius: 50%; background: #43d39e; box-shadow: 0 0 0 4px rgba(67,211,158,0.14); margin-right: 7px; }

.section-heading { margin: 44px 0 18px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.section-heading h2 { margin: 4px 0 0; font-size: 1.55rem; letter-spacing: -0.025em; }
.section-heading > p { margin: 0; font-size: 0.84rem; }
.organization-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.organization-card { min-height: 124px; border: 1px solid var(--slate-200); border-radius: 14px; background: var(--white); padding: 18px; text-align: left; display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 13px; color: var(--slate-900); cursor: pointer; box-shadow: 0 8px 22px rgba(16,26,55,0.04); transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease; }
.organization-card:hover:not(:disabled) { transform: translateY(-2px); border-color: #a8bbef; box-shadow: 0 14px 34px rgba(16,26,55,0.08); }
.organization-card.selected { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(57,115,238,0.09); }
.organization-card:disabled { opacity: 0.65; cursor: wait; }
.organization-initial { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--blue-100); color: var(--blue-600); font-size: 0.8rem; font-weight: 850; }
.organization-copy { min-width: 0; }
.organization-copy strong, .organization-copy small { display: block; }
.organization-copy strong { font-size: 0.95rem; }
.organization-copy small { color: var(--slate-500); font-size: 0.72rem; margin-top: 4px; line-height: 1.35; }
.organization-action { color: var(--blue-600); font-size: 0.72rem; font-weight: 800; }
.empty-state { grid-column: 1 / -1; margin: 0; background: white; border: 1px dashed var(--slate-300); border-radius: 12px; padding: 24px; color: var(--slate-500); }

.status-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 30px; }
.status-card { background: rgba(255,255,255,0.72); border: 1px solid var(--slate-200); border-radius: 14px; padding: 18px; }
.status-card strong { display: block; margin: 6px 0; font-size: 0.9rem; }
.status-card p { margin: 0; color: var(--slate-500); font-size: 0.74rem; }
.status-label { color: var(--green-600); background: var(--green-100); border-radius: 999px; padding: 4px 8px; font-size: 0.62rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; }

@media (max-width: 980px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-brand { min-height: 360px; padding: 32px; }
  .brand-message h1 { font-size: 2.35rem; }
  .brand-foot { display: none; }
  .auth-main { min-height: auto; padding: 48px 24px; }
  .organization-grid { grid-template-columns: 1fr 1fr; }
  .status-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { width: 272px; position: fixed; inset: 0 auto 0 0; transform: translateX(-105%); transition: transform 180ms ease; box-shadow: 20px 0 50px rgba(16,26,55,0.18); }
  .sidebar.open { transform: translateX(0); }
  .menu-button { display: inline-flex; align-items: center; }
  .topbar { padding: 0 18px; }
  .topbar .button { padding: 0 12px; }
  .dashboard { padding: 24px 18px 42px; }
  .welcome-panel { align-items: flex-start; flex-direction: column; }
  .organization-grid { grid-template-columns: 1fr; }
  .organization-card { min-height: 112px; }
}

@media (max-width: 520px) {
  .auth-brand { min-height: 320px; }
  .brand-message h1 { font-size: 1.95rem; }
  .brand-message > p:last-child { font-size: 0.94rem; }
  .auth-main { padding: 38px 20px; }
  .topbar-label { display: none; }
  .topbar strong { display: block; max-width: 125px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
