[hidden] {
  display: none !important;
}

:root {
  --brand: #10b981;
  --brand-dark: #059669;
  --brand-hover: #0d9467;
  --brand-light: rgba(16, 185, 129, 0.1);
  --brand-text: #065f46;

  --sidebar-bg: #0f172a;
  --sidebar-border: rgba(255, 255, 255, 0.07);
  --sidebar-width: 240px;
  --sidebar-item-hover: rgba(255, 255, 255, 0.06);
  --sidebar-item-active: rgba(16, 185, 129, 0.14);
  --sidebar-text: rgba(255, 255, 255, 0.6);
  --sidebar-text-hover: rgba(255, 255, 255, 0.9);
  --sidebar-text-active: #f0fdf4;
  --sidebar-icon: rgba(255, 255, 255, 0.35);
  --sidebar-icon-active: #10b981;

  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f5f9;
  --ink: #0f172a;
  --ink-2: #1e293b;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --danger: #ef4444;
  --danger-dark: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --warning: #f59e0b;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.18);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --t: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 220ms cubic-bezier(0.4, 0, 0.2, 1);
  --mobile-header-h: 56px;

  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #162233;
  --surface-3: #0f172a;
  --ink: #f1f5f9;
  --ink-2: #cbd5e1;
  --muted: #94a3b8;
  --muted-2: #64748b;
  --line: #334155;
  --line-2: #475569;
  --brand-text: #34d399;
  --brand-light: rgba(16, 185, 129, 0.12);
  --danger-bg: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(239, 68, 68, 0.25);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-x: hidden;
  background: var(--bg);
  scrollbar-gutter: stable;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
h3,
p {
  margin: 0;
}

/* Login */
.login-shell {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow-y: auto;
  padding: clamp(16px, 3vw, 24px);
  background: linear-gradient(160deg, #e2e8f0 0%, #f8fafc 100%);
}

[data-theme="dark"] .login-shell {
  background: linear-gradient(160deg, #0a1628 0%, #1e293b 100%);
}

.login-card {
  width: min(420px, calc(100vw - 48px));
  max-width: 100%;
  display: grid;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.login-brand,
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-brand {
  color: var(--ink);
  min-width: 0;
}

.brand-info {
  min-width: 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  background: var(--brand);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.brand-info strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.brand-info small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.sidebar .brand-info strong {
  color: #fff;
}

.sidebar .brand-info small {
  color: var(--sidebar-text);
}

.login-copy {
  display: grid;
  gap: 8px;
  margin: 2px 0 4px;
}

.login-copy h1 {
  margin: 0;
  overflow-wrap: anywhere;
  hyphens: auto;
}

.auth-links {
  margin-top: 2px;
  font-size: 13px;
}

.auth-links a {
  color: var(--brand-dark);
  font-weight: 700;
}

.auth-links a:hover {
  color: var(--brand);
}

/* App shell */
.app-shell {
  display: flex;
  min-height: 100vh;
  min-height: 100svh;
}

.sidebar {
  position: fixed;
  z-index: 200;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  overflow: hidden;
  transition: transform var(--t-slow);
}

.sidebar-brand {
  padding: 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-nav {
  display: flex;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  gap: 6px;
  padding: 12px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.nav-user {
  margin: 12px 8px 8px;
  background: rgba(255, 255, 255, 0.04);
}

.session-indicator {
  margin: 0 12px 8px;
  padding: 8px 10px;
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: var(--r-sm);
  background: rgba(16, 185, 129, 0.12);
  color: rgba(240, 253, 244, 0.95);
  font-size: 12px;
  line-height: 1.35;
}

.session-indicator strong {
  color: #fff;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--r-sm);
  background: transparent;
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  transition: background var(--t), color var(--t);
}

.nav-item:hover {
  background: var(--sidebar-item-hover);
  color: var(--sidebar-text-hover);
}

.nav-item.is-active {
  background: var(--sidebar-item-active);
  color: var(--sidebar-text-active);
  font-weight: 600;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--sidebar-icon);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: -0.04em;
  flex-shrink: 0;
  transition: color var(--t), background var(--t);
}

.nav-item:hover .nav-icon {
  color: rgba(255, 255, 255, 0.8);
}

.nav-item.is-active .nav-icon {
  background: rgba(16, 185, 129, 0.18);
  color: var(--sidebar-icon-active);
}

.sidebar-logout-form {
  margin: auto 0 0;
}

.sidebar-logout-form button {
  appearance: none;
}

.mobile-header {
  display: none;
  align-items: center;
  gap: 12px;
  height: var(--mobile-header-h);
  padding: 0 16px;
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  border-bottom: 1px solid var(--sidebar-border);
  background: var(--sidebar-bg);
}

.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  transition: background var(--t);
}

.menu-toggle span {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
}

.menu-toggle:hover {
  background: rgba(255, 255, 255, 0.14);
}

.mobile-title {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
}

.mobile-session-indicator {
  margin-left: auto;
  padding: 4px 8px;
  border: 1px solid rgba(16, 185, 129, 0.45);
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.15);
  color: #ecfdf5;
  font-size: 11px;
  line-height: 1;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
}

.sidebar-overlay.is-visible {
  display: block;
}

.workspace {
  flex: 1;
  width: calc(100% - var(--sidebar-width));
  max-width: 100%;
  min-width: 0;
  margin-left: var(--sidebar-width);
  padding: clamp(20px, 3.2vw, 40px);
}

.workspace-wide {
  max-width: none;
}

.screen.is-active {
  display: grid;
  gap: clamp(16px, 2.4vw, 24px);
  animation: screenIn var(--t-slow);
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Typography */
.page-header {
  max-width: 680px;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 8px;
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin-bottom: 10px;
  color: var(--ink);
  font-size: clamp(24px, 3vw, 30px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

h2 {
  color: var(--ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
}

h3 {
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.page-desc,
p {
  color: var(--muted);
}

.page-desc {
  font-size: 14px;
  line-height: 1.65;
}

/* Cards */
.card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: clamp(16px, 2.4vw, 20px) clamp(18px, 2.8vw, 24px);
  border-bottom: 1px solid var(--line);
}

.card-header h2 {
  margin: 0;
}

.card-header .eyebrow {
  margin-bottom: 4px;
}

.card-body {
  padding: clamp(18px, 2.8vw, 24px);
}

.admin-invite-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(18px, 3vw, 28px);
  padding: clamp(20px, 3vw, 28px);
  background:
    radial-gradient(circle at 15% 20%, rgba(16, 185, 129, 0.16), transparent 34%),
    linear-gradient(135deg, var(--surface), #f8fafc 58%, #eefcf6);
}

.admin-invite-card::after {
  content: "";
  position: absolute;
  inset: auto 22px 16px auto;
  width: 120px;
  height: 120px;
  border: 1px solid rgba(16, 185, 129, 0.18);
  border-radius: 36px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.14), rgba(37, 99, 235, 0.08));
  transform: rotate(8deg);
  pointer-events: none;
}

.admin-invite-content {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 16px;
  max-width: 760px;
}

.admin-invite-content h2 {
  font-size: clamp(20px, 2.5vw, 28px);
  letter-spacing: -0.02em;
}

.admin-invite-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.admin-invite-meta span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(16, 185, 129, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  font-size: 13px;
  box-shadow: var(--shadow-xs);
}

.admin-invite-meta strong {
  color: var(--ink);
}

.admin-invite-action {
  position: relative;
  z-index: 1;
  min-width: 190px;
  min-height: 46px;
  border-radius: 999px;
  box-shadow: 0 16px 36px rgba(16, 185, 129, 0.24);
}

.portal-modal {
  box-sizing: border-box;
  min-width: 0;
  width: min(760px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
  max-height: min(760px, calc(100dvh - 32px));
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  overflow: visible;
}

.portal-modal::backdrop {
  background:
    radial-gradient(circle at 50% 10%, rgba(16, 185, 129, 0.22), transparent 34%),
    rgba(7, 9, 26, 0.58);
  backdrop-filter: blur(8px);
}

.portal-modal[open] {
  animation: modalIn var(--t-slow);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-panel {
  box-sizing: border-box;
  width: 100%;
  max-height: min(760px, calc(100dvh - 32px));
  overflow: auto;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 34px 90px rgba(2, 6, 23, 0.3);
}

.modal-head {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: clamp(22px, 3vw, 30px);
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at 0 0, rgba(16, 185, 129, 0.18), transparent 38%),
    linear-gradient(135deg, #ffffff, #f8fafc);
}

.modal-head > div {
  min-width: 0;
  padding-right: 54px;
}

.modal-head h2 {
  margin: 0 0 8px;
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: -0.03em;
}

.modal-close {
  position: absolute;
  top: clamp(18px, 2.8vw, 26px);
  right: clamp(18px, 2.8vw, 26px);
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
  transition: background var(--t), border-color var(--t), transform var(--t);
}

.modal-close:hover {
  border-color: var(--line-2);
  background: var(--surface-3);
  transform: rotate(4deg);
}

.modal-form {
  display: grid;
  gap: 18px;
  padding: clamp(20px, 3vw, 30px);
}

.modal-option {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border: 1px solid rgba(16, 185, 129, 0.24);
  border-radius: var(--r);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08), rgba(37, 99, 235, 0.04));
  cursor: pointer;
}

.modal-option input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--brand);
}

.modal-option span {
  display: grid;
  gap: 3px;
}

.modal-option strong {
  color: var(--ink);
}

.modal-option small {
  color: var(--muted);
  font-weight: 500;
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 4px;
}

.dashboard-grid,
.choice-grid,
.two-col {
  display: grid;
  gap: 16px;
}

.dashboard-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}

.choice-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

.portal-app-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
}

.two-col {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
}

.section-block {
  display: grid;
  gap: 16px;
}

.section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
}

.dashboard-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 20px 20px;
}

.dashboard-kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 0 20px 20px;
}

.kpi-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.kpi-item span {
  color: var(--muted);
  font-size: 12px;
}

.kpi-item strong {
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
}

.account-status-card {
  border-color: rgba(16, 185, 129, 0.16);
  background:
    radial-gradient(circle at 10% 0%, rgba(16, 185, 129, 0.14), transparent 36%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.92));
}

[data-theme="dark"] .account-status-card {
  background:
    radial-gradient(circle at 10% 0%, rgba(16, 185, 129, 0.14), transparent 38%),
    linear-gradient(135deg, rgba(30, 41, 59, 0.98), rgba(15, 23, 42, 0.94));
}

.account-status-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: clamp(16px, 2.4vw, 20px) clamp(18px, 2.8vw, 24px);
  border-bottom: 1px solid rgba(16, 185, 129, 0.13);
}

.account-status-head .eyebrow {
  margin-bottom: 4px;
}

.status-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(16, 185, 129, 0.24);
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.1);
  color: var(--brand-text);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-live span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.13);
}

.account-status-body {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(260px, 1.2fr);
  gap: clamp(14px, 2.4vw, 22px);
  padding: clamp(18px, 2.8vw, 24px);
}

.account-profile {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: var(--r);
  background: rgba(255, 255, 255, 0.62);
}

[data-theme="dark"] .account-profile {
  background: rgba(15, 23, 42, 0.34);
}

.account-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), #0ea5e9);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: -0.04em;
  flex-shrink: 0;
  box-shadow: 0 14px 30px rgba(16, 185, 129, 0.2);
}

.account-profile div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.status-label,
.account-status-item small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.account-profile strong {
  color: var(--ink);
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.account-profile small {
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.account-status-list {
  display: grid;
  gap: 10px;
}

.account-status-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: rgba(255, 255, 255, 0.72);
}

[data-theme="dark"] .account-status-item {
  background: rgba(15, 23, 42, 0.28);
}

.account-status-item div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.account-status-item strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: -0.05em;
  flex-shrink: 0;
}

.status-icon.is-ok {
  background: rgba(16, 185, 129, 0.12);
  color: var(--brand-text);
}

.status-icon.is-warn {
  background: rgba(245, 158, 11, 0.13);
  color: #92400e;
}

[data-theme="dark"] .status-icon.is-warn {
  color: #fbbf24;
}

.choice-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 180px;
  padding: clamp(18px, 2.8vw, 24px);
  border: 2px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  color: var(--ink);
  transition: border-color var(--t), box-shadow var(--t), transform var(--t), background var(--t);
}

.choice-card:hover {
  border-color: var(--line-2);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.choice-card.is-active {
  border-color: var(--brand);
  background: #f0fdf4;
  box-shadow: 0 0 0 4px var(--brand-light), var(--shadow);
}

[data-theme="dark"] .choice-card.is-active {
  background: rgba(16, 185, 129, 0.08);
}

.choice-card.muted {
  opacity: 0.78;
}

.choice-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--r-sm);
  background: var(--brand-light);
  color: var(--brand);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.choice-card.is-active .choice-icon {
  background: var(--brand);
  color: #fff;
}

.choice-kicker {
  display: inline-block;
  margin-top: 4px;
  color: var(--brand-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.choice-card h2 {
  font-size: 17px;
}

.choice-card p {
  flex: 1;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

/* Forms */
.form-stack,
.grid-form,
.mini-form {
  display: grid;
  gap: 14px;
}

.grid-form {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  align-items: end;
}

.grid-form .form-wide {
  grid-column: 1 / -1;
}

.mini-form {
  margin-top: 10px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

input,
select {
  min-width: 0;
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  outline: 0;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}

input:hover,
select:hover {
  border-color: var(--muted-2);
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

input::placeholder {
  color: var(--muted-2);
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check input {
  width: auto;
  height: auto;
}

.password-hint,
.muted-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* Tabs */
.settings-card {
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab-button {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 2px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}

.tab-button:hover,
.tab-button.is-active {
  color: var(--ink);
}

.tab-button.is-active {
  border-bottom-color: var(--brand);
}

.settings-panel {
  display: none;
}

.settings-panel.is-active {
  display: block;
}

.settings-security-grid {
  padding: 0;
  gap: 0;
}

.settings-security-grid > section + section {
  border-left: 1px solid var(--line);
}

/* Buttons */
.btn,
.btn-primary,
.btn-secondary,
.table-actions button,
details button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  max-width: 100%;
  white-space: normal;
  text-align: center;
  transition: background var(--t), box-shadow var(--t), transform var(--t), color var(--t), border-color var(--t);
}

.btn-primary,
.btn.btn-primary {
  background: var(--brand);
  color: #fff;
}

.btn-primary:hover,
.btn.btn-primary:hover {
  background: var(--brand-dark);
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.4);
  transform: translateY(-1px);
}

.btn-secondary,
.btn.btn-secondary,
.table-actions button,
details button {
  border: 1px solid var(--line);
  background: var(--surface-3);
  color: var(--ink-2);
}

.btn-secondary:hover,
.btn.btn-secondary:hover,
.table-actions button:hover,
details button:hover {
  border-color: var(--line-2);
  background: var(--line);
}

.btn-danger,
.btn.btn-danger {
  border: 1px solid var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

.btn-danger:hover,
.btn.btn-danger:hover {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.btn-lg {
  min-height: 46px;
  padding: 10px 22px;
  font-size: 15px;
}

.full {
  width: 100%;
  margin-top: 16px;
}

/* Alerts and status */
.alert {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-2);
}

.alert-success {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.1);
  color: var(--brand-text);
}

.alert-error {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-dark);
}

.alert-info {
  border-color: rgba(59, 130, 246, 0.25);
  background: rgba(59, 130, 246, 0.1);
  color: #1d4ed8;
}

[data-theme="dark"] .alert-info {
  color: #93c5fd;
}

.pill {
  display: inline-flex;
  align-items: center;
  margin-right: 6px;
  padding: 3px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.pill.ok {
  border-color: #a7f3d0;
  background: #ecfdf5;
  color: #065f46;
}

.pill.warn {
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
}

.pill.danger {
  border-color: #fca5a5;
  background: #fee2e2;
  color: #991b1b;
}

[data-theme="dark"] .pill.ok {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
}

[data-theme="dark"] .pill.warn {
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.14);
  color: #fbbf24;
}

[data-theme="dark"] .pill.danger {
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: min(760px, calc(100vw - 32px));
  border-collapse: collapse;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td small {
  display: block;
  margin-top: 2px;
  color: var(--muted-2);
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-actions form {
  margin: 0;
}

details {
  width: 100%;
}

summary {
  margin: 8px 0;
  color: var(--brand-dark);
  cursor: pointer;
  font-weight: 700;
}

.danger-zone {
  margin-top: 8px;
}

/* MFA */
.qr-card {
  display: grid;
  place-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  text-align: center;
}

.qr-card img {
  width: 220px;
  height: 220px;
  padding: 8px;
  border-radius: var(--r-sm);
  background: #fff;
}

code {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-3);
  color: var(--brand-text);
  font-weight: 700;
}

.backup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.backup-grid code {
  display: block;
  padding: 10px;
  text-align: center;
  letter-spacing: 0.08em;
}

/* Finance */
.finance-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 18px;
  padding: clamp(18px, 2.8vw, 24px);
  background:
    radial-gradient(circle at 14% 0%, rgba(16, 185, 129, 0.14), transparent 34%),
    var(--surface);
}

.finance-hero .dashboard-kpis {
  padding: 0;
}

.finance-kpis {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.finance-onboarding .card {
  min-height: 100%;
}

.finance-mini-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.company-code-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px dashed rgba(16, 185, 129, 0.45);
  border-radius: var(--r);
  background: var(--brand-light);
}

.company-code-value {
  color: var(--brand-text);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.16em;
  line-height: 1;
}

.company-code-expire {
  color: var(--muted);
  font-size: 13px;
}

input:disabled,
select:disabled {
  border-color: var(--line);
  background: var(--surface-3);
  color: var(--muted);
  cursor: not-allowed;
}

@media (max-width: 1080px) {
  .portal-app-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .finance-hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 860px) {
  .mobile-header {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .workspace {
    width: 100%;
    margin-left: 0;
    padding: calc(var(--mobile-header-h) + 24px) 18px 48px;
  }

  .dashboard-grid,
  .choice-grid,
  .portal-app-grid,
  .two-col,
  .finance-mini-grid,
  .grid-form {
    grid-template-columns: 1fr;
  }

  .settings-security-grid > section + section {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .section-title {
    display: block;
  }
}

@media (max-height: 760px) and (min-width: 861px) {
  .workspace {
    padding-block: 20px;
  }

  .screen.is-active {
    gap: 16px;
  }

  .sidebar-brand {
    padding-block: 14px;
  }

  .nav-user {
    margin-top: 8px;
  }

  .nav-item {
    min-height: 36px;
  }

  .session-indicator {
    padding-block: 7px;
  }

  .choice-card {
    min-height: 150px;
  }
}

@media (max-width: 560px) {
  .login-shell {
    place-items: start center;
    padding: calc(env(safe-area-inset-top, 0px) + 18px) 14px calc(env(safe-area-inset-bottom, 0px) + 18px);
  }

  .login-card,
  .card-body,
  .choice-card {
    padding: 18px;
  }

  .login-card {
    width: 100%;
    gap: 14px;
    border-radius: 18px;
  }

  .login-brand {
    gap: 10px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
  }

  .brand-info strong {
    font-size: 14px;
  }

  .brand-info small {
    font-size: 11px;
  }

  .card-header {
    padding: 18px 20px;
  }

  h1 {
    font-size: clamp(24px, 7vw, 28px);
    line-height: 1.08;
  }

  .login-copy p {
    font-size: 14px;
    line-height: 1.55;
  }

  input,
  select {
    height: 44px;
    border-radius: 12px;
  }

  .btn-lg {
    width: 100%;
    min-height: 46px;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .dashboard-actions,
  .table-actions {
    flex-direction: column;
  }

  .dashboard-actions .btn,
  .table-actions button,
  .table-actions form {
    width: 100%;
  }

  .backup-grid {
    grid-template-columns: 1fr;
  }
}

/* Mobile hardening across App-Portal and server-rendered app views */
.screen,
.card,
.card-body,
.admin-invite-card,
.admin-invite-content,
.modal-panel,
.modal-form,
.table-wrap,
.form-stack,
.grid-form,
.choice-grid,
.dashboard-grid,
.two-col,
.finance-hero,
.settings-panel {
  min-width: 0;
}

.card,
.choice-card,
.kpi-item,
.alert,
.company-code-card {
  overflow-wrap: anywhere;
}

@media (max-width: 860px) {
  .mobile-header {
    height: calc(var(--mobile-header-h) + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: max(14px, env(safe-area-inset-right, 0px));
    padding-left: max(14px, env(safe-area-inset-left, 0px));
  }

  .mobile-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-session-indicator {
    flex-shrink: 0;
  }

  .sidebar {
    width: min(320px, calc(100vw - 42px));
    box-shadow: var(--shadow-lg);
  }

  .sidebar-brand {
    padding-top: calc(20px + env(safe-area-inset-top, 0px));
  }

  .workspace {
    min-height: 100dvh;
    padding-top: calc(var(--mobile-header-h) + env(safe-area-inset-top, 0px) + 18px);
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    padding-bottom: calc(36px + env(safe-area-inset-bottom, 0px));
    padding-left: max(16px, env(safe-area-inset-left, 0px));
  }

  .page-header {
    max-width: none;
  }

  .choice-card {
    min-height: auto;
  }

  .admin-invite-card {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-invite-action {
    width: fit-content;
  }

  .dashboard-actions,
  .table-actions {
    align-items: stretch;
  }

  .dashboard-kpis,
  .finance-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .account-status-body {
    grid-template-columns: 1fr;
  }

  .account-status-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .tabs {
    gap: 14px;
    padding-inline: 16px;
    scroll-snap-type: x proximity;
  }

  .tab-button {
    scroll-snap-align: start;
  }
}

@media (max-width: 680px) {
  .table-card {
    overflow: visible;
  }

  .table-wrap {
    overflow: visible;
  }

  .table-card table {
    min-width: 0;
    border-collapse: separate;
  }

  .table-card thead {
    display: none;
  }

  .table-card tbody {
    display: grid;
    gap: 12px;
    padding: 12px;
  }

  .table-card tr {
    display: grid;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
  }

  .table-card td {
    display: grid;
    grid-template-columns: minmax(92px, 0.42fr) minmax(0, 1fr);
    gap: 10px;
    align-items: start;
    padding: 0;
    border: 0;
  }

  .table-card td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .table-card td:not([data-label])::before {
    content: none;
  }

  .table-card td[data-label="Aktionen"] {
    grid-template-columns: 1fr;
  }

  .table-actions,
  .table-actions form,
  .table-actions details,
  .table-actions button,
  .mini-form,
  .danger-zone {
    width: 100%;
  }

  .table-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .mini-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  html {
    scrollbar-gutter: auto;
  }

  .workspace {
    padding-right: max(12px, env(safe-area-inset-right, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
  }

  .mobile-header {
    gap: 10px;
  }

  .dashboard-kpis,
  .finance-kpis,
  .finance-mini-grid,
  .account-status-list {
    grid-template-columns: 1fr;
  }

  .account-status-head {
    align-items: flex-start;
    flex-direction: column;
    padding: 18px;
  }

  .account-status-body {
    padding: 18px;
  }

  .account-profile {
    align-items: flex-start;
  }

  .dashboard-actions {
    padding: 0 16px 16px;
  }

  .dashboard-actions .btn,
  .form-stack .btn,
  .grid-form .btn,
  .admin-invite-action,
  .modal-actions .btn {
    width: 100%;
  }

  .portal-modal {
    width: min(760px, calc(100vw - 20px));
    max-width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
  }

  .modal-panel {
    max-height: calc(100dvh - 20px);
    border-radius: 22px;
  }

  .modal-head {
    align-items: flex-start;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .tabs {
    margin-inline: -2px;
    padding-inline: 14px;
  }

  .table-card tbody {
    padding: 10px;
  }

  .table-card tr {
    padding: 12px;
  }

  .table-card td {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .qr-card {
    padding: 14px;
  }

  .qr-card img {
    width: min(220px, calc(100vw - 84px));
    height: auto;
  }

  .company-code-value {
    font-size: 20px;
    letter-spacing: 0.1em;
  }

  input,
  select {
    font-size: 16px;
  }
}

@media (max-width: 380px) {
  .mobile-session-indicator {
    display: none;
  }

  .login-card,
  .card-body,
  .choice-card {
    padding: 16px;
  }

  .card-header {
    padding: 16px;
  }
}
