:root {
  --red: #bf252b;
  --red-dark: #971c22;
  --red-soft: #fbedee;
  --ink: #172033;
  --text: #30394a;
  --muted: #6d7787;
  --line: #e4e8ed;
  --line-strong: #d7dce4;
  --canvas: #f6f7f9;
  --surface: #ffffff;
  --success: #26734d;
  --success-soft: #eaf6ef;
  --warning: #9a6014;
  --warning-soft: #fff6e6;
  --shadow: 0 1px 2px rgba(20, 30, 48, .04), 0 8px 24px rgba(20, 30, 48, .035);
  --radius: 10px;
  --sidebar-width: 240px;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--canvas); }
body {
  margin: 0;
  color: var(--text);
  background: var(--canvas);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-dark); text-decoration: underline; }
img { max-width: 100%; }
svg { display: block; flex: 0 0 auto; }

:focus-visible { outline: 3px solid rgba(191, 37, 43, .3); outline-offset: 2px; }
::selection { color: #fff; background: var(--red); }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  z-index: 40;
  top: 0;
  bottom: 0;
  left: 0;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.sidebar-head { padding: 25px 20px 18px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--ink); text-decoration: none; }
.brand-mark { color: var(--red); font-size: 26px; font-weight: 760; letter-spacing: -.055em; line-height: 1; }
.brand-subtitle { margin-top: 4px; color: var(--muted); font-size: 12px; }
.company-switch { padding: 14px 16px 9px; }
.company-switch select { width: 100%; background: #fff; }
.sidebar-nav { flex: 1; padding: 8px 12px 16px; overflow-y: auto; }
.nav-section { margin: 13px 8px 6px; color: #8992a0; font-size: 10px; font-weight: 750; letter-spacing: .09em; text-transform: uppercase; }
.nav-link {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 12px;
  margin: 2px 0;
  padding: 9px 10px;
  border-radius: 7px;
  color: #3e4858;
  font-weight: 560;
  text-decoration: none;
}
.nav-link:hover { color: var(--red); background: #faf7f7; text-decoration: none; }
.nav-link.active { color: var(--red); background: var(--red-soft); font-weight: 680; }
.nav-link .nav-alert { margin-left: auto; min-width: 19px; padding: 1px 6px; border-radius: 10px; color: var(--red); background: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.sidebar-footer { padding: 16px 20px 18px; border-top: 1px solid var(--line); color: #8a93a0; font-size: 11px; }

.app-main { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar {
  position: sticky;
  z-index: 25;
  top: 0;
  display: flex;
  min-height: 72px;
  align-items: center;
  gap: 16px;
  padding: 13px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(12px);
}
.mobile-toggle { display: none; }
.search-form { display: flex; max-width: 650px; flex: 1; }
.search-box { position: relative; width: 100%; }
.search-box svg { position: absolute; top: 50%; left: 13px; color: #566171; transform: translateY(-50%); pointer-events: none; }
.search-box input { width: 100%; min-height: 42px; padding-left: 43px; border-radius: 8px; background: #fff; }
.topbar-right { display: flex; min-width: 0; align-items: center; gap: 14px; margin-left: auto; }
.context { min-width: 0; max-width: 230px; text-align: right; }
.context-label { overflow: hidden; color: #778191; font-size: 11px; font-weight: 650; letter-spacing: .055em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.context-name { overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 680; text-overflow: ellipsis; white-space: nowrap; }
.user-menu { display: flex; min-width: 0; align-items: center; gap: 9px; }
.user-name { max-width: 130px; overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }
.avatar { display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center; border: 1px solid #e0e3e8; border-radius: 50%; color: #354052; background: #f1f3f5; font-size: 12px; font-weight: 750; }
.icon-button { display: inline-grid; width: 38px; height: 38px; place-items: center; padding: 0; border: 0; border-radius: 8px; color: #354052; background: transparent; }
.icon-button:hover { color: var(--red); background: var(--red-soft); }
.logout-form { margin: 0; }

.page { max-width: 1560px; margin: 0 auto; padding: 28px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-heading h1 { margin: 2px 0 5px; color: var(--ink); font-size: clamp(25px, 2.4vw, 34px); font-weight: 730; letter-spacing: -.038em; line-height: 1.16; }
.page-heading p { max-width: 700px; margin: 0; color: var(--muted); font-size: 15px; }
.page-heading-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 9px; }
.eyebrow { margin: 0 0 3px; color: var(--red); font-size: 11px; font-weight: 760; letter-spacing: .095em; text-transform: uppercase; }

.button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: #354052;
  background: #fff;
  box-shadow: 0 1px 1px rgba(20, 30, 48, .02);
  font-weight: 650;
  line-height: 1.25;
  text-decoration: none;
}
.button:hover { border-color: #bbc3ce; color: var(--ink); background: #fafbfc; text-decoration: none; }
.button-primary { border-color: var(--red); color: #fff; background: var(--red); }
.button-primary:hover { border-color: var(--red-dark); color: #fff; background: var(--red-dark); }
.button-secondary { color: var(--red); border-color: #dfaeb1; background: #fff; }
.button-secondary:hover { color: var(--red-dark); border-color: var(--red); background: var(--red-soft); }
.button-danger { border-color: #e2a7aa; color: #a22026; background: #fffafa; }
.button-danger:hover { color: #fff; border-color: #a22026; background: #a22026; }
.button-sm { min-height: 32px; padding: 6px 10px; font-size: 12px; }

.card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.card-header { display: flex; min-height: 53px; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 20px; border-bottom: 1px solid var(--line); }
.card-header h2, .card-header h3 { margin: 0; color: var(--ink); font-size: 18px; font-weight: 710; letter-spacing: -.022em; }
.card-header a { font-size: 13px; font-weight: 650; }
.card-body { padding: 20px; }
.card-body.compact { padding: 14px 20px; }
.card-footer { padding: 12px 20px; border-top: 1px solid var(--line); background: #fcfcfd; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: grid; gap: 18px; }
.stack-sm { display: grid; gap: 10px; }
.divider { height: 1px; margin: 18px 0; background: var(--line); }

.stat-card { display: flex; min-height: 106px; flex-direction: column; justify-content: space-between; padding: 19px 20px; }
.stat-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.stat-icon { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 8px; color: var(--red); background: var(--red-soft); }
.stat-value { color: var(--ink); font-size: 28px; font-weight: 750; letter-spacing: -.04em; line-height: 1; }
.stat-label { margin-top: 7px; color: var(--muted); font-size: 12px; font-weight: 650; }

.list { margin: 0; padding: 0; list-style: none; }
.list-row { display: flex; min-height: 65px; align-items: center; gap: 13px; padding: 11px 20px; border-bottom: 1px solid var(--line); }
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: #fdfdfd; }
.list-row-icon { color: var(--ink); }
.list-row-main { min-width: 0; flex: 1; }
.list-row-title { overflow: hidden; color: var(--ink); font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.list-row-meta { overflow: hidden; margin-top: 1px; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.list-row-end { display: flex; align-items: center; gap: 10px; }

.badge { display: inline-flex; min-height: 24px; align-items: center; justify-content: center; padding: 3px 8px; border: 1px solid transparent; border-radius: 999px; color: #555f6d; background: #f1f3f5; font-size: 11px; font-weight: 680; line-height: 1; white-space: nowrap; }
.badge-red { border-color: #f0d0d2; color: #a92228; background: var(--red-soft); }
.badge-green { border-color: #cde9d8; color: var(--success); background: var(--success-soft); }
.badge-neutral { border-color: #e8eaed; color: #596474; background: #f4f5f6; }

.version-banner { display: flex; align-items: center; gap: 12px; padding: 12px 15px; border: 1px solid #edd5d6; border-radius: 8px; color: #634449; background: #fffafa; }
.version-banner strong { color: #922228; }
.info-box, .error-box { padding: 13px 15px; border: 1px solid; border-radius: 8px; }
.info-box { border-color: #d8e5ef; color: #38546b; background: #f6fbff; }
.error-box { border-color: #efd0d2; color: #98242a; background: #fff9f9; }
.info-box p, .error-box p { margin: 3px 0 0; }

.integration-item { display: flex; align-items: center; gap: 11px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.integration-item:last-child { padding-bottom: 0; border-bottom: 0; }
.integration-mark { display: grid; width: 34px; height: 34px; place-items: center; border: 1px solid var(--line); border-radius: 8px; color: #596474; background: #fafbfc; }
.integration-copy { min-width: 0; flex: 1; }
.integration-copy strong { display: block; color: var(--ink); font-size: 13px; }
.integration-copy span { display: block; margin-top: 1px; color: var(--muted); font-size: 12px; }

.empty-state { display: grid; min-height: 175px; place-items: center; padding: 26px 20px; text-align: center; }
.empty-state-inner { max-width: 350px; }
.empty-state-icon { display: inline-grid; width: 42px; height: 42px; place-items: center; margin-bottom: 11px; border-radius: 50%; color: #687484; background: #f2f4f6; }
.empty-state h3 { margin: 0 0 5px; color: var(--ink); font-size: 15px; font-weight: 700; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }
.empty-state .button { margin-top: 15px; }
.muted { color: var(--muted); }

.field { display: grid; gap: 6px; }
.field > label, .label { color: #3d4757; font-size: 13px; font-weight: 680; }
.input, .textarea, .select, input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="date"], textarea, select {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  line-height: 1.35;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.textarea, textarea { min-height: 110px; resize: vertical; }
.input:focus, .textarea:focus, .select:focus, input:focus, textarea:focus, select:focus { border-color: var(--red); outline: 0; box-shadow: 0 0 0 3px rgba(191, 37, 43, .12); }
.input::placeholder, textarea::placeholder { color: #9aa2ad; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 22px; }
.checkbox { display: flex; align-items: flex-start; gap: 9px; color: #465162; cursor: pointer; }
.checkbox input { width: 17px; height: 17px; flex: 0 0 auto; margin: 2px 0 0; accent-color: var(--red); }
.checkbox label { cursor: pointer; }
.hint { margin: 0; color: var(--muted); font-size: 12px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.toolbar-group { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.tabs { display: flex; gap: 3px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tab { display: inline-flex; min-height: 40px; align-items: center; padding: 0 13px; border-bottom: 2px solid transparent; color: var(--muted); font-size: 13px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.tab:hover { color: var(--red); text-decoration: none; }
.tab.active { border-bottom-color: var(--red); color: var(--red); }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.table { width: 100%; min-width: 600px; border-collapse: collapse; text-align: left; }
.table th { padding: 11px 15px; border-bottom: 1px solid var(--line); color: #647082; background: #fafbfc; font-size: 11px; font-weight: 760; letter-spacing: .055em; text-transform: uppercase; }
.table td { padding: 13px 15px; border-bottom: 1px solid var(--line); color: #3e4858; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fcfcfd; }

.guest-body { min-height: 100vh; background: radial-gradient(circle at 8% 4%, #fdf1f1 0, rgba(253, 241, 241, 0) 31%), radial-gradient(circle at 93% 98%, #f8eeee 0, rgba(248, 238, 238, 0) 31%), #f7f8fa; }
.guest-shell { display: flex; width: 100%; min-height: 100vh; flex-direction: column; align-items: center; padding: 42px 20px 24px; }
.guest-brand { margin-bottom: 28px; }
.guest-card { width: min(100%, 480px); padding: 29px; border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: 0 14px 45px rgba(22, 32, 51, .07); }
.guest-card h1 { margin: 0 0 7px; color: var(--ink); font-size: 25px; letter-spacing: -.035em; }
.guest-card > p { margin: 0 0 24px; color: var(--muted); }
.guest-footer { margin-top: auto; padding-top: 32px; color: #858e9c; font-size: 12px; text-align: center; }
.guest-footer strong { color: #596474; }

@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .context { display: none; }
}
@media (max-width: 820px) {
  .sidebar { width: min(88vw, 310px); transform: translateX(-102%); transition: transform .2s ease; box-shadow: 8px 0 30px rgba(20, 30, 48, .12); }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; z-index: 35; inset: 0; display: none; background: rgba(21, 29, 43, .34); }
  .app-shell.sidebar-open .sidebar-backdrop { display: block; }
  .app-main { margin-left: 0; }
  .topbar { min-height: 64px; padding: 10px 16px; }
  .mobile-toggle { display: inline-grid; width: 38px; height: 38px; place-items: center; padding: 0; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff; }
  .search-form { max-width: none; }
  .user-name, .logout-form { display: none; }
  .page { padding: 22px 16px; }
  .page-heading { display: grid; gap: 15px; margin-bottom: 17px; }
  .page-heading-actions { justify-content: flex-start; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .topbar { gap: 9px; }
  .topbar-right { gap: 4px; }
  .topbar-right > .icon-button { display: none; }
  .avatar { width: 34px; height: 34px; }
  .page { padding: 18px 13px; }
  .page-heading h1 { font-size: 27px; }
  .page-heading p { font-size: 14px; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: 1fr; }
  .card-header, .card-body { padding-right: 15px; padding-left: 15px; }
  .list-row { padding-right: 15px; padding-left: 15px; }
  .list-row-end .badge { max-width: 100px; overflow: hidden; text-overflow: ellipsis; }
  .version-banner { align-items: flex-start; }
  .guest-shell { padding: 28px 14px 18px; }
  .guest-card { padding: 23px 19px; }
  .button { min-height: 40px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; } }

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

.qr-block{text-align:center;margin:20px 0}.secret-key{font:600 14px ui-monospace,monospace;overflow-wrap:anywhere;background:#f5f6f8;padding:12px;border-radius:8px}.recovery-code-list{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin:22px 0}.recovery-code-list code{font:600 13px ui-monospace,monospace;background:#f5f6f8;padding:10px;border-radius:6px}.guest-card form+form{margin-top:12px}
