@font-face {
  font-family: "Ranscale Display";
  src: url("/fonts/UniversLTCYR-67BoldCond.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Ranscale Label";
  src: url("/fonts/UniversLTCYR-57Condensed.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #e9edf3;
  --surface: #fff;
  --surface-2: #f1f4f8;
  --line: #dce2ea;
  --ink: #1c1b18;
  --secondary: #45433e;
  --muted: #686760;
  --ink-card: #23262e;
  --accent: #2563eb;
  --accent-dark: #1b4fbf;
  --accent-soft: #e4edfd;
  --yellow: #ffc833;
  --green: #1e7a3e;
  --green-bg: #e6f4ec;
  --amber: #806000;
  --amber-bg: #fcf3da;
  --red: #a81e13;
  --red-bg: #fbe7e5;
  --blue: #1b4fbf;
  --blue-bg: #e4edfd;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(28, 27, 24, .05), 0 6px 18px rgba(28, 27, 24, .07);
  --shadow-lg: 0 18px 50px rgba(28, 27, 24, .22);
  --page-width: 1360px;
  --page-gutter: 20px;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
h1, h2, h3, p { margin: 0; }
a { color: var(--accent-dark); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
svg { flex: none; vertical-align: middle; }
input, textarea { accent-color: var(--accent); }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  white-space: nowrap;
  clip-path: inset(50%);
}
.skip-link {
  position: fixed;
  z-index: 20;
  top: 8px;
  left: 12px;
  transform: translateY(-150%);
  padding: 8px 12px;
  border-radius: 7px;
  background: var(--surface);
}
.skip-link:focus { transform: translateY(0); }
.initial-loading { padding: 18px; color: var(--muted); }
.muted, .help { color: var(--muted); }
.help { font-size: 13px; }
.numeric { font-variant-numeric: tabular-nums; }
.data-table th.right, .data-table td.right, .right { text-align: right; }
.stack { display: grid; gap: 13px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.app-layout { min-height: 100dvh; padding-bottom: 44px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 6;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 93%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
}
.topbar-inner, .app-footer-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: var(--page-width);
  margin: auto;
  padding-inline: var(--page-gutter);
}
.topbar-inner { min-height: 48px; padding-block: 6px; flex-wrap: wrap; }
.brand-link { display: inline-flex; color: var(--ink); text-decoration: none; }
.brand {
  display: inline-flex;
  align-items: center;
  gap: .22em;
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  white-space: nowrap;
  text-transform: uppercase;
}
.brand img { display: block; width: .85em; height: .73em; flex: none; }
.brand strong {
  font-family: "Ranscale Display", "Helvetica Neue Condensed", Impact, sans-serif;
  font-weight: 700;
}
.brand span {
  margin-left: .1em;
  font-family: "Ranscale Label", "Helvetica Neue Condensed", Arial, sans-serif;
  font-weight: 400;
}
.topnav {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 1px;
  width: fit-content;
  padding: 2px;
  border-radius: 999px;
  background: var(--surface-2);
}
.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 27px;
  padding: 3px 10px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 650;
  white-space: nowrap;
  text-decoration: none;
}
.nav-item[aria-current="page"] { color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.nav-item:hover:not([aria-current="page"]) { color: var(--accent-dark); }
.nav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding-inline: 4px;
  border-radius: 999px;
  background: var(--line);
  color: var(--secondary);
  font-size: 11px;
}
.topbar-user { display: flex; align-items: center; gap: 8px; margin-left: auto; min-width: 0; }
.topbar-role, .account-menu summary {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 31px;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 650;
}
.topbar-role { max-width: 280px; overflow-wrap: anywhere; color: var(--secondary); background: var(--surface-2); }
.account-menu { position: relative; min-width: 0; }
.account-menu summary {
  list-style: none;
  cursor: pointer;
  background: var(--ink-card);
  color: #fff;
}
.account-menu summary span { max-width: min(185px, 28vw); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary:hover { background: #363941; }
.account-menu[open] summary svg { transform: rotate(180deg); }
.account-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  display: grid;
  justify-items: start;
  gap: 8px;
  width: max-content;
  min-width: max(100%, 190px);
  max-width: calc(100vw - 28px);
  padding: 10px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow-wrap: anywhere;
  font-size: 13px;
}

.content {
  display: grid;
  align-content: start;
  gap: 14px;
  width: min(100%, var(--page-width));
  min-width: 0;
  margin-inline: auto;
  padding: 27px var(--page-gutter) 38px;
}
.content:focus, .auth:focus { outline: none; }
.content > .button { justify-self: start; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.page-head h1, .company-head h1 {
  color: var(--accent);
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.3px;
  overflow-wrap: anywhere;
}
.page-head p { margin-top: 4px; color: var(--secondary); font-size: 14px; }
.panel {
  min-width: 0;
  padding: 15px 18px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  margin-bottom: 12px;
}
.panel-head h2 { font-size: 16px; line-height: 1.25; font-weight: 700; }
.panel-head p { margin-top: 3px; color: var(--muted); font-size: 13px; }
.panel-body { padding-top: 4px; }
.empty { display: grid; justify-items: center; gap: 5px; padding: 25px 12px; text-align: center; }
.empty strong { line-height: 1.25; font-size: 15px; }
.empty p { max-width: 355px; color: var(--muted); font-size: 13px; }
.empty-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: 4px;
  border-radius: 12px;
  color: var(--accent);
  background: var(--surface-2);
}

.table-wrap {
  max-width: 100%;
  max-height: min(70vh, 680px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; color: var(--ink); font-size: 13px; }
.data-table th, .data-table td { padding: 9px 12px; text-align: left; vertical-align: middle; }
.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--accent);
  padding-block: 10px;
  font-size: 12px;
  line-height: 1.35;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
.data-table th:first-child { border-radius: 12px 0 0 12px; }
.data-table th:last-child { border-radius: 0 12px 12px 0; }
.data-table td { border-top: 1px solid var(--line); }
.data-table tbody tr:first-child td { border-top: 0; }
.data-table tbody tr:focus-within td, .data-table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 70%, var(--surface)); }
.data-table .right { width: 1%; }
.cell-subtitle { display: block; margin-top: 2px; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.entity-link, .person-cell { display: flex; align-items: center; gap: 9px; }
.entity-link { width: fit-content; color: var(--ink); font-size: 14px; text-decoration: none; }
.entity-link:hover, .entity-link:focus-visible { color: var(--accent); text-decoration: underline; }
.company-row { cursor: pointer; }
.company-arrow { display: inline-flex; padding-inline: 6px; color: var(--muted); }
.company-row:hover .company-arrow { color: var(--accent); }
.entity-link strong, .person-cell strong { overflow-wrap: anywhere; }
.avatar, .entity-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: var(--blue);
  background: var(--blue-bg);
  font-size: 11.5px;
  font-weight: 650;
}
.entity-icon { border-radius: 7px; background: var(--surface-2); }
.search { position: relative; display: flex; align-items: center; color: var(--muted); }
.search > svg { position: absolute; left: 10px; pointer-events: none; }
.search input {
  min-height: 34px;
  width: min(205px, 100%);
  padding: 5px 9px 5px 33px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: var(--surface);
  font-size: 13px;
}
.search input::placeholder { color: var(--muted); }
.badges { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--secondary);
  font-weight: 600;
  font-size: 11.5px;
  line-height: 1.45;
}
.badge.is-success { background: var(--green-bg); color: var(--green); }
.badge.is-warning { background: var(--amber-bg); color: var(--amber); }
.badge.is-danger { background: var(--red-bg); color: var(--red); }
.badge.is-info { background: var(--blue-bg); color: var(--blue); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: fit-content;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}
.back-link:hover { color: var(--accent); text-decoration: underline; }
.company-top { display: grid; gap: 6px; }
.company-head { display: flex; align-items: center; gap: 9px; }
.company-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: var(--accent);
  background: var(--surface-2);
}
.company-icon svg { width: 19px; height: 19px; }
.tabs { display: flex; align-items: stretch; gap: 2px; overflow: auto; border-bottom: 1px solid var(--line); }
.tabs a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  padding: 6px 12px;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}
.tabs a:hover { color: var(--ink); }
.tabs a:focus-visible { outline-offset: -2px; }
.tabs a[aria-current="page"] { border-color: var(--ink); color: var(--ink); }
.company-section { min-width: 0; }
.agent-list { margin: 0; padding: 0; list-style: none; }
.agent-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 82px minmax(124px, 180px) 122px;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.agent-name, .agent-permissions dd, .agent-dialog-text { overflow-wrap: anywhere; }
.agent-status { justify-self: start; }
.agent-activity { display: grid; font-size: 13px; }
.agent-row .button { justify-self: end; }
.agent-permissions {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 12px;
  margin: 0 0 14px;
  font-size: 13px;
}
.agent-permissions dt { font-weight: 650; }
.agent-permissions dd { margin: 0; color: var(--secondary); }
.agent-connection { max-width: 550px; gap: 8px; }

.button, .icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--secondary);
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
}
.button { width: fit-content; min-height: 34px; padding: 6px 12px; font-size: 13px; }
.button.primary { color: #fff; background: var(--accent); }
.button.primary:hover { background: var(--accent-dark); }
.button.secondary { color: var(--secondary); background: var(--surface-2); }
.button.secondary:hover { background: var(--line); }
.button.quiet { color: var(--accent-dark); }
.button.quiet:hover { background: var(--accent-soft); }
.button.danger { color: var(--red); border-color: #edbbc5; background: var(--red-bg); }
.button.danger:hover { background: #f9d9d5; }
.icon-button { flex: none; width: 32px; min-height: 32px; color: var(--muted); }
.icon-button:hover { color: var(--accent); background: var(--surface-2); }

.dialog {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(520px, 100%);
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--surface);
  color: var(--ink);
  box-shadow: -12px 0 36px rgba(28, 27, 24, .18);
}
.dialog::backdrop { background: rgba(28, 27, 24, .42); }
.dialog-form { display: flex; flex-direction: column; min-height: 100%; }
.dialog-head, .dialog-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; }
.dialog-head { justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 21px; line-height: 1.3; letter-spacing: -.2px; overflow-wrap: anywhere; }
.dialog-body { align-content: start; padding: 16px 18px; }
.dialog-foot { justify-content: flex-end; margin-top: auto; border-top: 1px solid var(--line); background: var(--surface-2); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.span-all { grid-column: 1 / -1; }
.field { display: grid; gap: 5px; min-width: 0; }
.field > span:first-child { font-size: 13px; font-weight: 650; }
.field input:not([type=checkbox], [type=radio]), .field textarea, .field select, .input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
}
.field input::placeholder, .field textarea::placeholder { color: var(--muted); }
.field input[readonly] { background: var(--surface-2); }
.field textarea { resize: vertical; }
.role-field { min-width: 0; margin: 0; padding: 0; border: 0; }
.role-field legend { margin-bottom: 6px; padding: 0; font-size: 13px; font-weight: 650; }
.role-options { display: flex; flex-wrap: wrap; gap: 6px; }
.role-option {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--secondary);
  font-size: 13px;
  cursor: pointer;
}
.role-option > input { width: 16px; height: 16px; margin: 0; }
.role-option:has(:checked) { border-color: #bed1f8; background: var(--accent-soft); color: var(--accent-dark); }
.role-field .help { margin-top: 7px; }
.form-error { padding: 8px 10px; border: 1px solid #edbbc5; border-radius: 8px; color: var(--red); background: var(--red-bg); font-size: 13px; }
.dialog .form-error { margin: 0 18px 12px; }
.notice-container { position: fixed; z-index: 9; right: 16px; bottom: 50px; width: max-content; max-width: calc(100vw - 32px); }
.notice {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 390px;
  padding: 4px 6px 4px 11px;
  border: 1px solid #b3e3c8;
  border-radius: 9px;
  background: var(--green-bg);
  color: var(--green);
  box-shadow: var(--shadow);
  font-size: 13px;
}
.notice-error { color: var(--red); border-color: #edbbc5; background: var(--red-bg); }
.notice .icon-button { margin-left: auto; color: inherit; }

.app-footer {
  position: fixed;
  z-index: 4;
  inset: auto 0 0;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(9px);
}
.app-footer-inner { gap: 6px; min-height: 40px; color: var(--muted); font-size: 12.5px; }
.app-footer .icon-button { width: 24px; }

.auth-layout { display: grid; grid-template-columns: 1fr 1fr; min-height: 100dvh; }
.auth-art {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  margin: 16px;
  border-radius: 28px;
  background: radial-gradient(120% 90% at 18% 88%, #2563eb 0%, transparent 52%),
    linear-gradient(165deg, #1c1b18 0%, #23262e 48%, #1e3a8a 100%);
}
.auth-mark { position: absolute; top: 22px; left: 22px; }
.auth-flight { width: min(82%, 560px); }
.auth-main { display: grid; place-items: center; min-width: 0; padding: 46px 28px; }
.auth-content { display: grid; justify-items: center; width: min(440px, 100%); text-align: center; }
.auth-brand .brand { font-size: clamp(34px, 4vw, 44px); }
.auth-content h1 { margin-top: 14px; font-size: 23px; line-height: 1.2; }
.auth-content > p { margin-top: 10px; color: var(--secondary); font-size: 17px; line-height: 1.45; }
.auth-form { width: 100%; margin-top: 22px; gap: 10px; }
.auth-form .field > span:first-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.auth-form .field input {
  min-height: 48px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: var(--ink-card);
}
.auth-form .field input::placeholder { color: #c8c6bf; }
.auth-form .button { width: 100%; min-height: 48px; margin-top: 4px; font-size: 15px; font-weight: 600; }
.auth-content .back-link { margin-top: 24px; }
.local-login { display: grid; justify-items: center; gap: 10px; width: 100%; margin-top: 48px; }
.local-login-label { display: flex; align-items: center; gap: 6px; color: var(--secondary); font-size: 14px; }
.local-login-label strong { font-weight: 500; }
.local-login-icon { display: none; }
.local-login .actions { justify-content: center; gap: 7px; }
.local-login .button { min-height: 36px; color: var(--ink); border-color: #d1d9e5; background: transparent; }
.local-login .button:hover { color: var(--accent); border-color: var(--accent); }

@media (max-width: 860px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}
@media (max-width: 730px) {
  :root { --page-gutter: 13px; }
  .topbar-inner { gap: 5px 8px; }
  .brand { font-size: 20px; }
  .topnav { order: 3; flex-wrap: nowrap; max-width: 100%; overflow: auto; }
  .nav-item { font-size: 12px; min-height: 30px; padding-inline: 8px; }
  .topbar-role { display: none; }
  .content { padding-top: 18px; }
  .panel { padding: 11px 12px; }
  .panel-head { margin-bottom: 9px; }
  .data-table th, .data-table td { padding-inline: 8px; }
  .tabs a { padding-inline: 8px; font-size: 12.5px; }
  .tabs a svg { width: 14px; height: 14px; }
}
@media (max-width: 460px) {
  .auth-main { padding: 24px 18px; }
  .auth-content > p { font-size: 15px; }
  .local-login { margin-top: 32px; }
  .dialog-head, .dialog-foot { padding-inline: 13px; }
  .dialog-body { padding-inline: 13px; }
  .dialog .form-error { margin-inline: 13px; }
  .agent-row { grid-template-columns: minmax(0, 1fr) max-content; gap: 8px; }
  .agent-status { justify-self: end; }
  .agent-permissions { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  .agent-permissions dd + dt { margin-top: 5px; }
}
