:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #66737c;
  --line: #dce3e7;
  --brand-blue: #012f46;
  --brand-blue-hover: #021f2e;
  --brand-blue-soft: #e7eef2;
  --brand-red: #ed0a3a;
  --brand-red-dark: #a60729;
  --brand-red-soft: #fff0f3;
  --red: var(--brand-red);
  --blue: var(--brand-blue);
  --shadow: 0 16px 40px rgba(23, 32, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.auth-pending,
body.auth-required {
  background: var(--brand-blue);
}

body.auth-pending .shell,
body.auth-required .shell {
  display: none;
}

body.auth-required .login-screen {
  display: grid;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

button {
  min-height: 36px;
  padding: 0 13px;
  cursor: pointer;
}

button:hover {
  border-color: #aab6bd;
}

.primary {
  border-color: var(--brand-blue);
  background: var(--brand-blue);
  color: #fff;
  font-weight: 700;
}

.primary:hover {
  border-color: var(--brand-blue-hover);
  background: var(--brand-blue-hover);
}

.ghost {
  background: transparent;
}

.danger {
  color: var(--red);
}

.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  height: 100vh;
  overflow: hidden;
  padding: 24px 18px;
  background: var(--brand-blue);
  color: #fff;
}

.brand {
  display: grid;
  gap: 10px;
  align-items: start;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.brand:hover {
  border-color: transparent;
  background: transparent;
}

.brand:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.62);
  outline-offset: 6px;
}

.brand-logo {
  width: 60%;
  max-width: 170px;
  height: auto;
}

.brand strong,
.brand span {
  display: block;
}

.brand-text {
  display: grid;
  gap: 2px;
}

.brand span {
  color: #a7b4bb;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
  align-content: start;
  overflow-y: auto;
  min-height: 0;
  padding-right: 2px;
}

.nav-item {
  position: relative;
  width: 100%;
  border-radius: 8px;
  font-size: 15px;
  text-align: left;
  border: 0;
  color: #d9e2e7;
  background: transparent;
}

.nav-item:hover {
  border-color: transparent;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
  color: var(--brand-blue);
  background: #fff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.16);
}

.nav-item.active::before {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 0;
  width: 4px;
  border-radius: 0 999px 999px 0;
  background: var(--brand-red);
}

.user-widget {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 12px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.user-avatar {
  position: relative;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #2d3a42;
}

.user-avatar::before,
.user-avatar::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: #d9e2e7;
}

.user-avatar::before {
  top: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.user-avatar::after {
  bottom: 7px;
  width: 18px;
  height: 10px;
  border-radius: 10px 10px 4px 4px;
}

.user-label {
  min-width: 0;
}

.user-label strong,
.user-label span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-label strong {
  color: #fff;
  font-size: 14px;
}

.user-label span {
  color: #a7b4bb;
  font-size: 12px;
}

.user-popover {
  position: absolute;
  left: 8px;
  bottom: calc(100% - 4px);
  display: none;
  min-width: 150px;
  padding: 8px;
  border: 1px solid #31414a;
  border-radius: 8px;
  background: #223039;
  box-shadow: var(--shadow);
  z-index: 10;
}

.user-widget:hover .user-popover,
.user-widget:focus-within .user-popover {
  display: block;
}

.user-popover button {
  width: 100%;
  border-color: transparent;
  color: #fff;
  background: transparent;
  text-align: left;
}

.user-popover button:hover {
  background: #31414a;
}

.ok {
  color: #b7d2df;
}

.bad {
  color: #fca5a5;
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
}

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

select,
input {
  min-height: 36px;
  padding: 0 10px;
}

textarea {
  width: 100%;
  min-height: 72px;
  padding: 10px;
  resize: vertical;
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid rgba(1, 47, 70, 0.18);
  border-radius: 6px;
  color: var(--brand-blue);
  background: var(--brand-blue-soft);
}

.hidden {
  display: none;
}

.login-screen {
  display: none;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: var(--brand-blue);
}

.login-card {
  display: grid;
  width: min(460px, 100%);
  gap: 12px;
  padding: 28px;
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-logo {
  width: 150px;
  height: auto;
}

.login-card h1 {
  font-size: 26px;
}

.login-card p {
  margin: 0 0 8px;
}

.login-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.login-field input {
  width: 100%;
}

.password-input-wrap {
  position: relative;
  display: block;
}

.password-input-wrap input {
  padding-right: 104px;
}

.password-toggle-button {
  position: absolute;
  top: 50%;
  right: 6px;
  min-width: 86px;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: #eef3f5;
  color: var(--ink);
  font-size: 13px;
  transform: translateY(-50%);
}

.password-toggle-button:hover {
  border-color: #cad4da;
  background: #e4ecef;
}

.legal-consent {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.42;
}

.legal-consent input {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 1px 0 0;
  accent-color: var(--brand-blue);
}

.legal-consent a {
  color: var(--brand-blue);
  font-weight: 700;
  text-decoration: none;
}

.legal-consent a:hover {
  text-decoration: underline;
}

.login-device-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
  background: #fff;
}

.login-device-toggle:hover {
  border-color: #aab6bd;
}

.login-device-toggle.active {
  border-color: rgba(237, 10, 58, 0.28);
  background: var(--brand-red-soft);
  color: var(--red);
}

.login-device-switch {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #dce3e7;
  transition: background 0.16s ease;
}

.login-device-switch::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(23, 32, 38, 0.18);
  transition: transform 0.16s ease;
}

.login-device-toggle.active .login-device-switch {
  background: var(--red);
}

.login-device-toggle.active .login-device-switch::after {
  transform: translateX(18px);
}

.login-card > .primary,
.login-card button.primary {
  width: 100%;
  min-height: 42px;
}

.login-error {
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 6px;
  color: var(--red);
  background: #fff1f2;
}

.legal-page {
  min-height: 100vh;
  background: var(--bg);
}

.legal-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.legal-topline {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.legal-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.legal-brand img {
  width: 120px;
  height: auto;
}

.legal-brand span {
  font-weight: 800;
}

.legal-back-link {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  text-decoration: none;
}

.legal-document {
  display: grid;
  gap: 20px;
  padding: clamp(22px, 3vw, 34px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.legal-document header {
  display: grid;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.legal-document h1 {
  max-width: 880px;
  margin: 0;
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1.04;
}

.legal-lead {
  max-width: 880px;
  margin: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
}

.legal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legal-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafb;
  color: var(--muted);
  font-size: 13px;
}

.legal-section {
  display: grid;
  gap: 10px;
}

.legal-section h2 {
  margin: 0;
  font-size: clamp(21px, 2.4vw, 28px);
  line-height: 1.15;
}

.legal-section h3 {
  margin: 8px 0 0;
  font-size: 18px;
}

.legal-section p {
  margin: 0;
  color: #2d3b43;
  line-height: 1.62;
}

.legal-section ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding-left: 22px;
  color: #2d3b43;
  line-height: 1.55;
}

.legal-notice {
  padding: 16px 18px;
  border: 1px solid rgba(1, 47, 70, 0.2);
  border-radius: 6px;
  background: rgba(1, 47, 70, 0.06);
  color: var(--brand-blue);
  line-height: 1.55;
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.section {
  margin-bottom: 16px;
}

.panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 17px;
}

.list {
  display: grid;
  gap: 10px;
}

.meter {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.meter:last-child {
  border-bottom: 0;
}

.results-toolbar,
.form-row,
.region-form,
.blacklist-form,
.api-keys-form,
.settings-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.content-with-tags {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 320px);
  gap: 16px;
  align-items: start;
}

.content-main {
  min-width: 0;
}

.tag-sidebar {
  position: sticky;
  top: 28px;
  max-height: calc(100vh - 56px);
  overflow: hidden;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.tag-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.tag-sidebar h2 {
  margin: 0;
  font-size: 15px;
}

.tag-sidebar-head button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 12px;
}

.query-tags {
  display: grid;
  gap: 7px;
  max-height: calc(100vh - 124px);
  overflow-y: auto;
  padding-right: 2px;
}

.query-tag {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
  width: 100%;
  min-height: 34px;
  padding: 7px 8px;
  text-align: left;
  background: #f8fafb;
}

.query-tag span {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.28;
  white-space: normal;
}

.query-tag strong {
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--muted);
  background: #edf2f5;
  font-size: 12px;
  text-align: center;
}

.dashboard-highlight {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: inherit;
  background: #f8fafb;
  text-decoration: none;
}

.dashboard-highlight:hover {
  border-color: rgba(1, 47, 70, 0.32);
}

.dashboard-highlight span {
  color: #34424b;
  line-height: 1.42;
}

.dashboard-highlight small {
  color: var(--muted);
}

.query-tag.selected {
  border-color: var(--brand-blue);
  color: #fff;
  background: var(--brand-blue);
}

.query-tag.selected strong {
  color: var(--brand-blue);
  background: var(--brand-blue-soft);
}

.empty.compact {
  padding: 14px;
  font-size: 13px;
}

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.settings-tab {
  min-height: 36px;
  border-color: var(--line);
  color: #34424b;
  background: #fff;
}

.settings-tab.active {
  border-color: var(--brand-blue);
  color: #fff;
  background: var(--brand-blue);
  font-weight: 700;
}

.settings-panel {
  display: none;
}

.settings-panel.active {
  display: block;
}

.settings-panel input,
.settings-panel select,
.settings-panel textarea {
  min-height: 46px;
  border-radius: 12px;
  border-color: #cfd9df;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(1, 47, 70, 0.03);
}

.settings-panel input:focus,
.settings-panel select:focus,
.settings-panel textarea:focus {
  border-color: var(--brand-blue);
  outline: 3px solid rgba(1, 47, 70, 0.1);
}

.settings-panel button {
  border-radius: 12px;
  font-weight: 800;
}

.settings-panel .panel {
  border-radius: 14px;
}

.section-note {
  max-width: 860px;
  margin: -4px 0 16px;
  line-height: 1.45;
}

.designer-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.2fr) auto;
  gap: 12px;
  align-items: end;
}

.limit-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr)) auto;
  gap: 12px;
  align-items: start;
}

.limit-field {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #f8fafb;
}

.limit-field span {
  font-weight: 700;
}

.limit-field small {
  color: var(--muted);
  line-height: 1.35;
}

.api-keys-form {
  align-items: end;
}

.api-status {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.api-status div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.api-status span {
  color: var(--muted);
  font-size: 13px;
}

.api-status strong {
  font-size: 15px;
}

.secret-field {
  display: grid;
  min-width: min(100%, 300px);
  gap: 6px;
}

.secret-field span {
  color: var(--muted);
  font-size: 13px;
}

.user-settings-toolbar {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.user-directory-copy {
  margin: 0;
}

.user-directory-copy h2 {
  margin: 0 0 8px;
}

.user-directory-scroll {
  overflow-x: auto;
}

.user-directory-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  table-layout: fixed;
}

.user-directory-table th,
.user-directory-table td {
  padding: 12px 10px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

.user-directory-table th {
  color: var(--muted);
  font-weight: 800;
}

.user-directory-table th:nth-child(1),
.user-directory-table td:nth-child(1) {
  width: 16%;
}

.user-directory-table th:nth-child(2),
.user-directory-table td:nth-child(2) {
  width: 12%;
}

.user-directory-table th:nth-child(3),
.user-directory-table td:nth-child(3) {
  width: 16%;
}

.user-directory-table th:nth-child(4),
.user-directory-table td:nth-child(4) {
  width: 18%;
}

.user-directory-table th:nth-child(5),
.user-directory-table td:nth-child(5) {
  width: 24%;
}

.user-directory-table th:nth-child(6),
.user-directory-table td:nth-child(6) {
  width: 14%;
}

.user-name-stack {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.user-name-stack strong {
  color: var(--brand-blue);
  font-size: 15px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.user-subcopy {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.user-badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--brand-blue-soft);
  color: var(--brand-blue);
  font-size: 12px;
  line-height: 1.2;
}

.user-badge.is-role {
  background: var(--brand-red-soft);
  color: var(--brand-red-dark);
}

.user-badge.is-client {
  background: var(--brand-blue-soft);
  color: var(--brand-blue);
}

.user-badge.is-access {
  background: #f3f6f8;
  color: #34424b;
}

.user-badge.is-neutral {
  background: #edf2f5;
  color: var(--muted);
}

.user-row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: nowrap;
}

.user-row-actions button {
  min-height: 38px;
}

.user-delete-btn {
  width: 38px;
  min-width: 38px;
  padding: 0;
  border-color: rgba(237, 10, 58, 0.28);
  color: var(--brand-red);
  background: #fff;
  font-size: 20px;
  line-height: 1;
}

.user-delete-btn:hover {
  border-color: var(--brand-red);
  background: var(--brand-red-soft);
}

.user-editor-card[hidden] {
  display: none;
}

.user-editor-head {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
}

.user-editor-head h2 {
  margin: 0 0 8px;
}

.user-editor-head p {
  max-width: 900px;
}

.user-editor-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.field input {
  width: 100%;
}

.user-flag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
}

.user-access-section {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.user-access-section h3 {
  margin: 0 0 8px;
  font-size: 22px;
}

.user-access-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.client-product-button {
  min-height: 42px;
  font-weight: 800;
}

.client-product-button.active,
.client-product-button[aria-pressed="true"] {
  border-color: var(--brand-red);
  color: #fff;
  background: var(--brand-red);
}

.user-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.state-toggle {
  min-height: 42px;
  border-color: rgba(1, 47, 70, 0.16);
  color: var(--brand-blue);
  background: #fff;
}

.state-toggle.enabled,
.state-toggle[aria-pressed="true"] {
  border-color: var(--brand-red);
  color: #fff;
  background: var(--brand-red);
}

.role-card {
  display: grid;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, #fff, #f8fafb);
}

.role-card-fields {
  display: grid;
  grid-template-columns: minmax(180px, 0.8fr) minmax(260px, 1.4fr);
  gap: 12px;
}

.role-card-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.role-limit-title {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.role-limit-title strong {
  color: var(--brand-blue);
  font-size: 16px;
}

.role-limit-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr)) auto;
  gap: 12px;
  align-items: end;
}

.result-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--brand-blue);
  border-radius: 8px;
  background: var(--panel);
}

.result-card.low {
  border-left-color: var(--muted);
}

.result-card.medium {
  border-left-color: var(--brand-red-dark);
}

.result-card.high {
  border-left-color: var(--brand-blue);
}

.result-card.trash {
  border-left-color: var(--red);
  opacity: 0.78;
}

.result-card.ai-filtered {
  border-left-color: var(--red);
  background: #fffafa;
}

.ai-pill {
  color: var(--brand-red-dark);
  background: var(--brand-red-soft);
}

.ai-filter-note {
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: var(--brand-red-dark);
  background: var(--brand-red-soft);
}

.result-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.result-summary-button {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  width: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.result-summary-button:hover,
.result-summary-button:focus-visible {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  transform: none;
}

.result-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--brand-blue);
  background: #edf4f7;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}

.result-summary-copy {
  min-width: 0;
}

.result-card h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.result-card a {
  color: var(--blue);
  text-decoration: none;
}

.meta,
.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.result-details {
  margin-top: 14px;
}

.result-details[hidden] {
  display: none;
}

.brief {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
}

.brief strong,
.brief span {
  display: block;
}

.brief strong {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.brief span {
  line-height: 1.4;
}

.evidence {
  margin-top: 14px;
}

.evidence strong {
  display: block;
  margin-bottom: 6px;
}

.evidence ul {
  margin: 0;
  padding-left: 20px;
  color: #34424b;
}

.evidence li {
  margin: 5px 0;
  line-height: 1.45;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  color: #34424b;
  background: #edf2f5;
  font-size: 12px;
}

.result-controls {
  display: grid;
  grid-template-columns: 190px 1fr auto;
  gap: 10px;
  align-items: start;
  margin-top: 12px;
}

.query-row {
  display: grid;
  grid-template-columns: 48px minmax(220px, 2fr) minmax(140px, 1fr) minmax(120px, 1fr) minmax(120px, 1fr) minmax(110px, 0.8fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.password-cell {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) auto;
  gap: 6px;
}

.password-cell button {
  padding: 0 10px;
}

.matrix-wrap {
  width: 100%;
  overflow-x: auto;
}

.permission-matrix {
  width: 100%;
  min-width: 720px;
  border-collapse: separate;
  border-spacing: 0 8px;
}

.permission-matrix th,
.permission-matrix td {
  padding: 10px 8px;
  text-align: left;
  vertical-align: middle;
}

.permission-matrix th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.matrix-button {
  min-width: 86px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  color: var(--brand-blue);
  background: #f3f6f8;
}

.matrix-button.enabled {
  border-color: var(--brand-red);
  color: #fff;
  background: var(--brand-red);
}

.switch {
  position: relative;
  display: inline-flex;
  width: 42px;
  height: 24px;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #b9c4ca;
}

.switch span::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 3px;
  left: 3px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.16s ease;
}

.switch input:checked + span {
  background: var(--brand-blue);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.empty {
  padding: 26px;
  border: 1px dashed #b9c4ca;
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .stats,
  .grid,
  .content-with-tags,
  .limit-form,
  .api-status {
    grid-template-columns: 1fr;
  }

  .tag-sidebar {
    position: static;
    max-height: none;
  }

  .query-tags {
    max-height: 260px;
  }

  .topbar,
  .actions,
  .result-head,
  .result-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .query-row {
    grid-template-columns: 1fr;
  }

  .designer-form,
  .role-card-fields,
  .role-limit-fields {
    grid-template-columns: 1fr;
  }

  .brief {
    grid-template-columns: 1fr;
  }
}

/* Soft product UI refresh inspired by the production console. */
:root {
  --bg: #eef4f7;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-strong: #ffffff;
  --ink: #163040;
  --muted: #62727d;
  --line: rgba(1, 47, 70, 0.12);
  --soft-line: rgba(1, 47, 70, 0.08);
  --field-border: #c1d2e2;
  --surface-tint: rgba(255, 255, 255, 0.72);
  --shadow: 0 22px 60px rgba(1, 47, 70, 0.08);
  --shadow-soft: 0 12px 34px rgba(1, 47, 70, 0.06);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 14px;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  color: var(--ink);
  background: linear-gradient(180deg, #fffdfd 0%, #f5f8fb 48%, #eef4f7 100%);
  font-family: "Avenir Next", Inter, "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.42;
}

button,
select,
input,
textarea {
  border-color: var(--field-border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  transition:
    border-color 0.16s ease,
    background-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

button,
select,
input {
  min-height: 40px;
}

textarea {
  min-height: 86px;
}

button {
  padding: 0 16px;
  font-weight: 700;
}

button:hover {
  border-color: rgba(1, 47, 70, 0.28);
  background: #ffffff;
}

button:focus-visible,
select:focus,
input:focus,
textarea:focus {
  border-color: rgba(1, 47, 70, 0.52);
  outline: 4px solid rgba(1, 47, 70, 0.08);
  box-shadow: 0 0 0 1px rgba(1, 47, 70, 0.04);
}

.primary {
  border-color: var(--brand-blue);
  border-radius: 12px;
  background: var(--brand-blue);
  box-shadow: 0 14px 26px rgba(1, 47, 70, 0.16);
}

.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(1, 47, 70, 0.18);
}

.ghost {
  color: var(--brand-blue);
  background: rgba(255, 255, 255, 0.66);
}

.danger {
  color: var(--brand-red);
}

.shell {
  grid-template-columns: 276px minmax(0, 1fr);
}

.sidebar {
  gap: 26px;
  padding: 22px 18px;
  background: linear-gradient(180deg, #012f46 0%, #073a52 100%);
  box-shadow: 18px 0 48px rgba(1, 47, 70, 0.14);
}

.brand {
  gap: 12px;
  text-decoration: none;
}

.brand,
.brand:hover,
.brand:focus-visible {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  transform: none;
}

.brand-logo {
  width: 64%;
}

.brand-text strong {
  color: #ffffff;
  font-size: 14px;
  line-height: 1.18;
}

.nav {
  gap: 10px;
}

.nav-item {
  min-height: 42px;
  padding: 8px 14px;
  border-radius: 14px;
  color: rgba(255, 255, 255, 0.84);
  font-weight: 650;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
}

.nav-item.active {
  color: var(--brand-blue);
  background: #ffffff;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.18);
}

.nav-item.active::before {
  top: 10px;
  bottom: 10px;
  left: 0;
  width: 4px;
}

.user-widget {
  margin-top: auto;
  padding: 14px 8px 0;
  border-top-color: rgba(255, 255, 255, 0.16);
}

.user-avatar {
  background: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.user-popover {
  border-radius: 16px;
  background: #ffffff;
  border-color: var(--line);
  box-shadow: 0 24px 56px rgba(1, 47, 70, 0.18);
}

.user-popover button {
  color: var(--ink);
  border-radius: 12px;
}

.user-popover button:hover {
  color: #ffffff;
  background: var(--brand-blue);
}

.main {
  padding: 30px clamp(24px, 3vw, 38px) 48px;
}

.topbar {
  align-items: center;
  margin-bottom: 24px;
}

h1 {
  color: var(--ink);
  font-size: 30px;
  letter-spacing: 0;
}

p {
  color: var(--muted);
}

.actions select {
  min-width: 230px;
}

.actions .primary {
  white-space: nowrap;
}

.panel,
.stat,
.tag-sidebar,
.result-card,
.query-row,
.role-card,
.login-card,
.legal-document,
.dashboard-highlight,
.api-status div,
.limit-field,
.user-editor-card {
  border-color: var(--line);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.panel,
.login-card,
.legal-document {
  border-radius: var(--radius-xl);
}

.panel {
  padding: 24px;
}

.section {
  margin-bottom: 20px;
}

.panel h2 {
  margin-bottom: 16px;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.16;
}

.stats {
  gap: 14px;
  margin-bottom: 22px;
}

.stat {
  min-height: 104px;
  padding: 18px 20px;
  border-radius: 18px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.stat strong {
  margin-top: 10px;
  color: var(--ink);
  font-size: 30px;
  line-height: 1;
}

.grid {
  gap: 18px;
}

.meter {
  padding: 10px 0;
  border-bottom-color: var(--soft-line);
}

.meter strong {
  color: var(--brand-blue);
}

.results-toolbar,
.form-row,
.blacklist-form,
.api-keys-form,
.settings-form {
  gap: 12px;
  margin-bottom: 18px;
}

.results-toolbar input,
.results-toolbar select,
.form-row input,
.form-row select,
.blacklist-form input,
.region-form input,
.settings-form input,
.settings-form select,
.settings-form textarea,
.api-keys-form input,
.api-keys-form select {
  min-height: 44px;
}

.settings-tabs {
  gap: 10px;
}

.settings-tab {
  min-height: 40px;
  border-radius: 12px;
  color: var(--brand-blue);
  background: rgba(255, 255, 255, 0.72);
}

.settings-tab.active {
  border-color: rgba(237, 10, 58, 0.45);
  color: #ffffff;
  background: linear-gradient(135deg, var(--brand-red), #f24e70);
}

.settings-panel input,
.settings-panel select,
.settings-panel textarea {
  min-height: 44px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
}

.settings-panel button {
  border-radius: 14px;
}

.settings-panel .panel {
  border-radius: var(--radius-xl);
}

.designer-form,
.limit-form,
.role-card-fields,
.role-limit-fields,
.user-editor-grid {
  gap: 14px;
}

.limit-field {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.66);
}

.api-status {
  gap: 12px;
}

.api-status div {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.66);
}

.secret-field span,
.field,
.limit-field small {
  color: var(--muted);
}

.content-with-tags {
  gap: 18px;
}

.tag-sidebar {
  top: 30px;
  padding: 18px;
  border-radius: var(--radius-lg);
}

.tag-sidebar h2 {
  font-size: 17px;
}

.query-tags {
  gap: 8px;
}

.query-tag {
  min-height: 40px;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.76);
}

.query-tag:hover {
  border-color: rgba(1, 47, 70, 0.26);
}

.query-tag strong {
  background: #edf4f7;
}

.query-tag.selected {
  border-color: rgba(237, 10, 58, 0.45);
  color: #ffffff;
  background: var(--brand-blue);
}

.dashboard-highlight {
  gap: 7px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.result-card {
  padding: 20px;
  border-left-width: 6px;
  border-radius: var(--radius-lg);
}

.result-card.collapsed {
  padding: 16px 18px;
}

.result-card h3 {
  font-size: 19px;
}

.result-head {
  gap: 16px;
  align-items: flex-start;
}

.result-summary-button {
  border-radius: 18px;
}

.result-summary-button h3 {
  color: var(--ink);
}

.result-summary-button p {
  margin-top: 5px;
  color: #536775;
  line-height: 1.36;
}

.result-summary-button:hover h3 {
  color: var(--brand-blue);
}

.result-toggle-icon {
  border-color: rgba(1, 47, 70, 0.12);
  background: rgba(237, 244, 247, 0.9);
  transition:
    color 0.16s ease,
    background-color 0.16s ease,
    transform 0.16s ease;
}

.result-card.expanded .result-toggle-icon {
  color: #ffffff;
  background: var(--brand-blue);
  transform: rotate(180deg);
}

.result-card.collapsed .meta {
  margin-left: 42px;
}

.result-card.collapsed .result-head > .pill {
  flex: 0 0 auto;
}

.brief {
  gap: 12px;
  padding: 14px;
  border-color: var(--soft-line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.66);
}

.pill,
.user-badge {
  min-height: 25px;
  padding: 4px 9px;
  border-radius: 999px;
  color: #1f3953;
  background: #edf4f7;
}

.result-controls {
  gap: 12px;
  margin-top: 16px;
}

.result-controls select,
.result-controls textarea {
  border-radius: 14px;
}

.query-row {
  grid-template-columns: 50px minmax(220px, 1.4fr) minmax(150px, 0.9fr) minmax(130px, 0.8fr) minmax(108px, auto);
  gap: 10px;
  padding: 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
}

.query-row > :nth-child(1) {
  grid-column: 1;
  grid-row: 1 / span 2;
}

.query-row > :nth-child(2) {
  grid-column: 2;
  grid-row: 1;
}

.query-row > :nth-child(3) {
  grid-column: 3;
  grid-row: 1;
}

.query-row > :nth-child(4) {
  grid-column: 4;
  grid-row: 1;
}

.query-row > :nth-child(5) {
  grid-column: 2;
  grid-row: 2;
}

.query-row > :nth-child(6) {
  grid-column: 3 / span 2;
  grid-row: 2;
}

.query-row > :nth-child(7) {
  grid-column: 5;
  grid-row: 1;
}

.query-row > :nth-child(8) {
  grid-column: 5;
  grid-row: 2;
}

.region-form {
  display: grid;
  grid-template-columns: minmax(220px, 1.3fr) minmax(120px, 0.45fr) minmax(220px, 1fr) auto;
}

.region-list {
  display: grid;
  gap: 10px;
}

.region-row {
  display: grid;
  grid-template-columns: 50px minmax(220px, 1.2fr) minmax(110px, 0.42fr) minmax(220px, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-soft);
}

.region-row input {
  min-height: 42px;
  border-radius: 12px;
}

.region-row button[data-action="save-region"] {
  color: #ffffff;
  border-color: var(--brand-blue);
  background: var(--brand-blue);
}

.region-row button[data-action="delete-region"] {
  border-color: rgba(237, 10, 58, 0.2);
  color: var(--brand-red);
  background: #ffffff;
}

.region-row button[data-action="delete-region"]:hover {
  border-color: rgba(237, 10, 58, 0.48);
  background: var(--brand-red-soft);
}

.query-row input,
.query-row select {
  min-height: 42px;
  border-radius: 12px;
}

.query-row button[data-action="save"] {
  color: #ffffff;
  border-color: var(--brand-blue);
  background: var(--brand-blue);
}

.query-row button[data-action="delete"],
.user-delete-btn {
  border-color: rgba(237, 10, 58, 0.2);
  color: var(--brand-red);
  background: #ffffff;
}

.query-row button[data-action="delete"]:hover,
.user-delete-btn:hover {
  border-color: rgba(237, 10, 58, 0.48);
  background: var(--brand-red-soft);
}

.switch {
  width: 44px;
  height: 26px;
}

.switch span {
  width: 44px;
  height: 26px;
  border: 1px solid rgba(1, 47, 70, 0.08);
  background: #c9d5dc;
}

.switch span::after {
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  box-shadow: 0 3px 10px rgba(1, 47, 70, 0.18);
}

.switch input:checked + span {
  background: var(--brand-blue);
}

.switch input:checked + span::after {
  transform: translateX(18px);
}

.user-directory-table {
  border-collapse: separate;
  border-spacing: 0 10px;
}

.user-directory-table th,
.user-directory-table td {
  border-top: 0;
}

.user-directory-table tbody tr {
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 24px rgba(1, 47, 70, 0.05);
}

.user-directory-table tbody td:first-child {
  border-radius: 16px 0 0 16px;
}

.user-directory-table tbody td:last-child {
  border-radius: 0 16px 16px 0;
}

.role-card {
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.74);
}

.matrix-button,
.state-toggle,
.client-product-button {
  border-radius: 999px;
}

.matrix-button.enabled,
.state-toggle.enabled,
.state-toggle[aria-pressed="true"],
.client-product-button.active,
.client-product-button[aria-pressed="true"] {
  border-color: rgba(237, 10, 58, 0.45);
  background: linear-gradient(135deg, var(--brand-red), #f24e70);
}

.empty {
  border-color: rgba(1, 47, 70, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.44);
}

.notice {
  border-radius: 18px;
  border-color: rgba(1, 47, 70, 0.12);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: var(--shadow-soft);
}

.login-screen {
  background: linear-gradient(180deg, #012f46 0%, #073a52 100%);
}

.login-card {
  width: min(480px, 100%);
  gap: 14px;
  padding: 30px;
}

.login-logo {
  width: 158px;
}

.login-field input,
.password-input-wrap input {
  min-height: 44px;
  border-radius: 14px;
}

.password-toggle-button {
  border-radius: 10px;
}

.legal-consent,
.login-device-toggle {
  border-radius: 14px;
  background: rgba(245, 248, 251, 0.84);
}

.login-card > .primary,
.login-card button.primary {
  min-height: 46px;
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 22px 16px 36px;
  }

  .sidebar {
    height: auto;
    min-height: 0;
    border-radius: 0 0 24px 24px;
  }

  .query-row,
  .region-form,
  .region-row,
  .result-controls,
  .designer-form,
  .role-card-fields,
  .role-limit-fields {
    grid-template-columns: 1fr;
  }
}
