:root {
  color-scheme: light;
  --ink: #25252b;
  --muted: #6d7079;
  --line: #dfe1dc;
  --paper: #f6f7f2;
  --surface: #ffffff;
  --wash: #eef5f3;
  --future-dusk: #25243f;
  --future-dusk-2: #302e52;
  --teal: #007f78;
  --teal-strong: #00645f;
  --teal-soft: #e8f5f3;
  --mocha: #a47864;
  --mocha-soft: #f3ebe6;
  --gold: #d79222;
  --gold-soft: #fff3d8;
  --coral: #d75f56;
  --green: #287a52;
  --accent: var(--teal);
  --accent-strong: var(--teal-strong);
  --amber: #b87918;
  --red: #bd4a42;
  --shadow: 0 18px 42px rgba(37, 36, 63, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(37, 36, 63, 0.03), transparent 32%),
    var(--paper);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  padding: 18px 14px;
  background: var(--future-dusk);
  color: #f7f5ef;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
}

.brand-name {
  font-size: 18px;
  font-weight: 740;
}

.brand-mode {
  margin-top: 2px;
  color: #c6c4d8;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dddceb;
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  background: var(--future-dusk-2);
  color: #ffffff;
}

.nav-item.is-active {
  box-shadow: inset 3px 0 0 var(--teal);
}

.nav-icon,
[data-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.sidebar-status {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 10px;
  align-items: start;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: #48d2b0;
}

.status-title {
  font-size: 13px;
  font-weight: 700;
}

.status-caption {
  overflow: hidden;
  margin-top: 2px;
  color: #c6c4d8;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  min-width: 0;
  padding: 22px 28px 32px;
}

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

.topbar > * {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1.1;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.icon-button {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 680;
}

.icon-button:not(.text-button) {
  width: 38px;
  padding: 0;
}

.icon-button:hover {
  border-color: #b9bdc5;
  box-shadow: 0 4px 14px rgba(37, 36, 63, 0.09);
}

.notice {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid #b9ded8;
  border-radius: 8px;
  background: var(--teal-soft);
  color: #155d57;
  font-size: 14px;
}

.notice.is-error {
  border-color: #efc7c3;
  background: #fff0ef;
  color: var(--red);
}

.is-hidden {
  display: none !important;
}

.mode-banner {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  margin-bottom: 14px;
  padding: 11px 12px;
  border: 1px solid #b8deda;
  border-radius: 8px;
  background: var(--teal-soft);
  color: #195a55;
  font-size: 13px;
  line-height: 1.4;
}

.mode-banner strong,
.mode-banner span:last-child {
  display: block;
}

.mode-banner strong {
  color: #123f3c;
}

.workflow {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.workflow-step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  appearance: none;
  background: #ffffff;
  color: var(--muted);
  text-align: left;
}

.workflow-step:not(:disabled):hover {
  border-color: #b7d9d4;
  background: #f8fcfb;
}

.workflow-step:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.workflow-step span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #eff1ee;
  color: #555862;
  font-size: 12px;
  font-weight: 760;
}

.workflow-step strong {
  overflow: hidden;
  min-width: 0;
  font-size: 12px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-step.is-done {
  border-color: #c7e3dd;
  color: #225f59;
}

.workflow-step.is-done span {
  background: var(--teal-soft);
  color: var(--teal-strong);
}

.workflow-step.is-current {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 127, 120, 0.1);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

.main-view,
.confirm-panel {
  min-width: 0;
}

.section-band {
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid rgba(37, 36, 63, 0.12);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-band.is-flat {
  box-shadow: none;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}

.section-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.section-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field.span-2 {
  grid-column: 1 / -1;
}

.span-2 {
  grid-column: 1 / -1;
}

.field label {
  color: #3f3f48;
  font-size: 13px;
  font-weight: 650;
}

.required-star {
  color: var(--red);
  font-weight: 800;
}

.field input,
.field select,
.field textarea,
.table-input,
.table-select,
.chat-input {
  width: 100%;
  min-width: 0;
  border: 1px solid #cfd3ce;
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
}

.field input,
.field select,
.table-input,
.table-select,
.chat-input {
  height: 38px;
  padding: 8px 10px;
}

.field textarea {
  min-height: 78px;
  resize: vertical;
  padding: 9px 10px;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.table-input:focus,
.table-select:focus,
.chat-input:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(0, 127, 120, 0.16);
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--red);
  outline-color: rgba(189, 74, 66, 0.14);
}

.field-error {
  color: var(--red);
  font-size: 12px;
  line-height: 1.3;
}

.field-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.rules-panel {
  display: grid;
  gap: 12px;
  padding: 13px;
  border: 1px solid #c7e3dd;
  border-radius: 8px;
  background: #f4fbfa;
}

.rules-panel h3,
.rules-panel p {
  margin: 0;
}

.rules-panel h3 {
  font-size: 15px;
}

.rules-panel p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.operator-brief,
.semantic-operator-panel {
  display: grid;
  min-width: 0;
  max-width: 100%;
  gap: 12px;
  padding: 13px;
  border: 1px solid #d9d7e8;
  border-radius: 8px;
  background: #fbfbff;
}

.operator-brief {
  grid-template-columns: minmax(0, 1.2fr) minmax(220px, 320px);
  align-items: end;
}

.operator-brief h3,
.operator-brief p,
.semantic-operator-panel h3,
.semantic-operator-panel p {
  margin: 0;
}

.operator-brief h3,
.semantic-operator-panel h3 {
  font-size: 15px;
}

.operator-brief p,
.semantic-operator-panel p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.operator-cheatsheet {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  gap: 7px;
  grid-column: 1 / -1;
}

.operator-cheatsheet span {
  min-width: 0;
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid #d9d7e8;
  border-radius: 999px;
  background: #ffffff;
  color: #4b4a56;
  font-size: 11px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  white-space: normal;
}

.operator-cheatsheet b {
  color: var(--ink);
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.connection-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.connection-summary > div {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid #c7e3dd;
  border-radius: 8px;
  background: #f4fbfa;
}

.connection-summary strong {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  color: #173f3b;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.setup-account {
  border-color: #b9ded8;
}

.account-select-row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(360px, 1fr);
  gap: 14px;
  align-items: stretch;
  max-width: 100%;
}

.account-select-row .field {
  gap: 6px;
  align-content: start;
}

.account-select-row .field > span,
.account-list-title {
  color: #3f3f48;
  font-size: 13px;
  font-weight: 650;
}

.account-card,
.oauth-connect {
  min-width: 0;
  padding: 10px 11px;
  border: 1px solid #c7e3dd;
  border-radius: 8px;
  background: #f4fbfa;
}

.account-card {
  display: flex;
  min-height: 62px;
  flex-direction: column;
  justify-content: center;
}

.account-access-card {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-width: 0;
  min-height: 62px;
  padding: 10px 11px;
  border: 1px solid #c7e3dd;
  border-radius: 8px;
  background: #f4fbfa;
}

.account-access-card.is-warn {
  border-color: #ecd49e;
  background: #fffaf0;
}

.account-access-card.is-risk {
  border-color: #e6b4ae;
  background: #fff6f5;
}

.account-access-card strong,
.account-access-card small {
  display: block;
  min-width: 0;
}

.account-access-card strong {
  color: #173f3b;
  font-size: 14px;
  line-height: 1.25;
}

.account-access-card small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.account-status-summary {
  width: 100%;
  max-width: 100%;
  min-height: 0;
  align-items: center;
  flex-direction: row;
  justify-content: flex-start;
  gap: 10px;
  padding: 8px 12px;
}

.account-status-summary > div {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 10px;
}

.account-status-summary strong {
  overflow: hidden;
  font-size: 14px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-status-summary small {
  display: inline;
  flex: 0 0 auto;
  margin-top: 0;
  white-space: normal;
}

.account-status-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #34c78a;
}

.account-status-dot.ok {
  background: #34c78a;
}

.account-status-dot.warn {
  background: var(--gold);
}

.account-status-dot.risk {
  background: var(--red);
}

.account-card strong,
.oauth-connect strong {
  display: block;
  color: #173f3b;
}

.account-card small,
.oauth-connect span,
.oauth-connect small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.account-empty {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 14px;
  border: 1px dashed #b9bdc5;
  border-radius: 8px;
  background: #f8f9f4;
  color: var(--muted);
}

.account-empty strong {
  color: var(--ink);
}

.account-list {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.account-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 54px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
}

.account-row:hover,
.account-row.is-active {
  border-color: #b7d9d4;
  background: #f8fcfb;
}

.account-row.is-active {
  box-shadow: inset 3px 0 0 var(--teal);
}

.account-row strong,
.account-row small {
  display: block;
}

.account-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.oauth-connect {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.admin-oauth-setup {
  border: 1px dashed #d8c690;
  border-radius: 8px;
  background: #fffdf7;
}

.admin-oauth-setup summary {
  cursor: pointer;
  padding: 12px 14px;
  color: #74531a;
  font-weight: 800;
}

.admin-oauth-setup .instruction-box {
  margin: 0 12px 12px;
}

.compact-button {
  min-height: 38px;
  white-space: nowrap;
}

.instruction-box {
  display: grid;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid #ecd49e;
  border-radius: 8px;
  background: #fff9ea;
  color: #4a3b1c;
  font-size: 13px;
  line-height: 1.45;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.instruction-box.is-highlighted {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(215, 146, 34, 0.16);
}

.instruction-box strong {
  color: #30230f;
}

.instruction-box ol,
.instruction-box p {
  margin: 0;
}

.instruction-box ol {
  display: grid;
  gap: 5px;
  padding-left: 20px;
}

.instruction-box code {
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.72);
  color: #5c4210;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.instruction-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.instruction-links a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 9px;
  border: 1px solid #e6c27b;
  border-radius: 999px;
  color: #6e470e;
  text-decoration: none;
  font-weight: 700;
}

.instruction-links a:hover {
  background: #fff3d8;
}

.dev-fallback {
  min-width: 0;
  padding: 10px 12px;
  border: 1px dashed #c9d2cf;
  border-radius: 8px;
  background: #fbfcfa;
}

.dev-fallback summary {
  cursor: pointer;
  color: #4c5660;
  font-size: 13px;
  font-weight: 650;
  list-style-position: inside;
}

.dev-fallback-body {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.auth-section {
  border-color: #d9d7e8;
}

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

.auth-card {
  display: flex;
  min-width: 0;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.auth-person {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.auth-person > span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--teal-soft);
  color: var(--teal-strong);
}

.auth-card strong,
.auth-card small {
  display: block;
}

.auth-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-card small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.telegram-card {
  background: #f8fcfb;
}

.telegram-login-mount {
  display: flex;
  justify-content: flex-end;
  min-width: 210px;
}

.auth-check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green-strong);
  font-weight: 800;
  white-space: nowrap;
}

.auth-check svg {
  width: 18px;
  height: 18px;
}

.auth-next-step {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--teal-line);
  border-radius: 8px;
  background: var(--teal-soft);
  color: var(--teal-strong);
  line-height: 1.35;
}

.risk-text {
  color: var(--red) !important;
}

.switch-row {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #3e4148;
  font-size: 13px;
  font-weight: 680;
}

.switch-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--teal);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
}

.button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 720;
}

.button:hover {
  background: var(--accent-strong);
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.button.secondary:hover {
  border-color: #b7bbc3;
  background: #f7f8f3;
}

.button.danger {
  background: var(--red);
}

.button.danger:hover {
  background: #8d2c27;
}

.button.warning {
  background: var(--gold);
}

.button.warning:hover {
  background: #a86c15;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(0, 127, 120, 0.22);
  outline-offset: 2px;
}

.loader {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.button.secondary .loader {
  border-color: rgba(0, 127, 120, 0.22);
  border-top-color: var(--teal);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

.connection-kpis {
  margin-top: 14px;
}

.kpi {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.kpi-label {
  color: var(--muted);
  font-size: 12px;
}

.kpi-value {
  overflow-wrap: anywhere;
  margin-top: 4px;
  font-size: 22px;
  font-weight: 780;
  line-height: 1.14;
}

.kpi-change {
  margin-top: 2px;
  color: var(--green);
  font-size: 12px;
}

.summary {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--teal-soft);
}

.summary p {
  margin: 0;
  line-height: 1.45;
}

.risk-list,
.tag-list,
.audit-list,
.op-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid #b8deda;
  border-radius: 999px;
  background: #f4fbfa;
  color: #265f5a;
  font-size: 12px;
}

.risk-item,
.audit-item,
.op-item {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-size: 13px;
  line-height: 1.35;
}

.risk-item {
  border-color: #efcf94;
  background: var(--gold-soft);
  color: #79500f;
}

.data-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  position: relative;
  scrollbar-color: var(--teal) #edf0eb;
}

.data-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table th,
.data-table td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: #f4f5f0;
  color: #454550;
  font-size: 12px;
  font-weight: 760;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
  box-shadow: none;
}

.data-table td {
  font-size: 13px;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.table-input {
  height: 34px;
  padding: 6px 8px;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-select {
  height: 34px;
  padding: 5px 8px;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#planTable {
  min-width: 1080px;
}

#planTable th:nth-child(1),
#planTable td:nth-child(1) {
  width: 250px;
  position: sticky;
  left: 0;
  z-index: 2;
  box-shadow: 8px 0 14px rgba(37, 36, 63, 0.06);
}

#planTable th:nth-child(1) {
  z-index: 3;
  background: #f4f5f0;
}

#planTable td:nth-child(1) {
  background: #ffffff;
}

#planTable th:nth-child(2),
#planTable td:nth-child(2) {
  width: 118px;
}

#planTable th:nth-child(3),
#planTable td:nth-child(3) {
  width: 190px;
}

#planTable th:nth-child(4),
#planTable td:nth-child(4) {
  width: 170px;
}

#planTable th:nth-child(5),
#planTable td:nth-child(5) {
  width: 290px;
}

#planTable th:nth-child(6),
#planTable td:nth-child(6) {
  width: 58px;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}

.mini-button:hover {
  border-color: var(--red);
  color: var(--red);
}

.status-pill {
  display: inline-flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eff1ee;
  color: #3e4148;
  font-size: 12px;
  font-weight: 680;
}

.section-header .status-pill {
  align-self: flex-start;
}

.status-pill.ok {
  background: #eaf7ef;
  color: var(--green);
}

.status-pill.warn {
  background: var(--gold-soft);
  color: #80520f;
}

.status-pill.risk {
  background: #fff0ef;
  color: var(--red);
}

.table-hint,
.budget-note,
.decision-note {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.approval-next-step {
  display: flex;
  gap: 7px;
  align-items: start;
  margin-bottom: 10px;
  padding: 9px 10px;
  border: 1px solid #c7e3dd;
  border-radius: 8px;
  background: #f4fbfa;
  color: #275f5a;
  font-size: 12px;
  line-height: 1.4;
}

.approval-next-step strong {
  flex: 0 0 auto;
  color: #17423e;
}

.budget-note {
  margin: 10px 0 0;
}

.decision-note {
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid #c7e3dd;
  border-radius: 8px;
  background: #f4fbfa;
  color: #275f5a;
}

.confirm-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
}

.confirm-empty,
.confirm-box {
  padding: 16px;
  border: 1px solid rgba(37, 36, 63, 0.12);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.confirm-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.confirm-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
  margin-bottom: 12px;
}

.confirm-title h2 {
  margin: 0;
  font-size: 17px;
}

.confirm-summary {
  margin: 0 0 12px;
  color: #34343b;
  font-size: 13px;
  line-height: 1.45;
}

.op-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.op-summary {
  color: var(--ink);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.cluster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.cluster {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  min-width: 0;
}

.cluster-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 6px;
}

.cluster-head h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.cluster-head span {
  flex: 0 0 auto;
  color: var(--teal-strong);
  font-size: 12px;
  font-weight: 800;
}

.cluster p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.cluster ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.cluster-more {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.cluster-more summary {
  cursor: pointer;
  color: var(--teal-strong);
  font-weight: 700;
}

.cluster-more ul {
  margin-top: 6px;
}

.semantic-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 12px;
}

.semantic-metrics span {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 4px 9px;
  border: 1px solid #c7e3dd;
  border-radius: 999px;
  background: #f4fbfa;
  color: #17423e;
  font-size: 12px;
  font-weight: 760;
}

.semantic-operator-panel {
  margin: 12px 0;
}

.semantic-operator-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
}

.semantic-default-mode {
  display: grid;
  flex: 0 0 230px;
  gap: 5px;
  color: #3f3f48;
  font-size: 12px;
  font-weight: 700;
}

.semantic-default-mode select,
.semantic-operator-row select {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 6px 9px;
  border: 1px solid #cfd3ce;
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
}

.semantic-operator-list {
  display: grid;
  gap: 8px;
}

.semantic-operator-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 10px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid rgba(37, 36, 63, 0.1);
  border-radius: 8px;
  background: #ffffff;
}

.semantic-operator-row strong,
.semantic-operator-row small {
  display: block;
  min-width: 0;
}

.semantic-operator-row strong {
  color: var(--ink);
  font-size: 13px;
}

.semantic-operator-row small {
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.insight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.insight-card {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 8px;
  padding: 12px;
  border: 1px solid #d8d9df;
  border-radius: 8px;
  background: #ffffff;
}

.insight-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.mini-label {
  width: fit-content;
  min-height: 24px;
  padding: 4px 8px;
  border: 1px solid #c7e3dd;
  border-radius: 999px;
  background: #f4fbfa;
  color: #275f5a;
  font-size: 11px;
  font-weight: 800;
}

.rule-list {
  display: grid;
  gap: 8px;
}

.rule-item {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid #d8d9df;
  border-radius: 8px;
  background: #ffffff;
}

.rule-item strong,
.rule-item span,
.rule-item em {
  display: block;
}

.rule-item strong {
  color: #173f3b;
  font-size: 13px;
}

.rule-item span,
.rule-item em {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.rule-item em {
  color: #275f5a;
  font-style: normal;
  font-weight: 700;
}

.safe-item {
  border-color: #c7e3dd;
  background: #f4fbfa;
  color: #275f5a;
}

.audience-section {
  margin-top: 16px;
}

.audience-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.audience-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid #c7e3dd;
  border-radius: 8px;
  background: #f4fbfa;
}

.audience-card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.chat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(36px, 1fr));
  gap: 10px;
  align-items: end;
  height: 230px;
  padding: 16px 12px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.bar-cell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  height: 100%;
  text-align: center;
}

.bar-track {
  display: flex;
  align-items: end;
  justify-content: center;
  min-height: 0;
}

.bar {
  width: 68%;
  min-height: 8px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #47c7b0, var(--teal));
}

.period-select {
  height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

.bar-label {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  display: grid;
  gap: 6px;
  padding: 24px;
  border: 1px dashed #b9bdc5;
  border-radius: 8px;
  background: #f8f9f4;
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.settings-grid-single {
  grid-template-columns: minmax(0, 980px);
}

.note-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: #3f3f48;
  font-size: 13px;
  line-height: 1.4;
}

@media (max-width: 1440px) {
  .content-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .confirm-panel {
    position: static;
  }
}

@media (max-width: 820px) {
  html,
  body {
    overflow-x: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .content-grid,
  .main-view,
  .confirm-panel,
  .section-band,
  .operator-brief,
  .semantic-operator-panel,
  .semantic-operator-list,
  .semantic-operator-row,
  .cluster,
  .insight-card,
  .audience-card,
  .account-access-card,
  .account-card,
  .account-empty {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .sidebar {
    min-height: auto;
    padding: 12px;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-status {
    margin-top: 0;
  }

  .workspace {
    padding: 16px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  .topbar,
  .section-header {
    align-items: stretch;
    flex-direction: column;
  }

  .form-grid,
  .split,
  .settings-grid,
  .cluster-grid,
  .kpi-grid,
  .connection-summary,
  .account-select-row,
  .auth-grid,
  .rules-grid,
  .insight-grid,
  .audience-grid,
  .workflow {
    grid-template-columns: 1fr;
  }

  .operator-brief,
  .semantic-operator-row {
    grid-template-columns: 1fr;
  }

  .semantic-operator-head,
  .approval-next-step {
    flex-direction: column;
  }

  .semantic-default-mode {
    flex-basis: auto;
    width: 100%;
  }

  .oauth-connect,
  .auth-card,
  .account-access-card,
  .account-row {
    align-items: stretch;
    flex-direction: column;
  }

  .account-access-card {
    grid-template-columns: 10px minmax(0, 1fr);
  }

  .account-access-card .compact-button {
    grid-column: 1 / -1;
    justify-self: stretch;
  }

  .telegram-login-mount {
    justify-content: flex-start;
    min-width: 0;
  }

  .workflow-step strong {
    white-space: normal;
  }

  .topbar p,
  .section-subtitle,
  .mode-banner,
  .summary,
  .approval-next-step,
  .instruction-box {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .topbar p {
    white-space: normal;
  }
}

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

  .workspace {
    padding: 14px 12px 24px;
  }

  .topbar h1 {
    font-size: 23px;
  }

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

  .top-actions,
  .toolbar {
    width: 100%;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .button,
  .text-button,
  .icon-button.text-button {
    width: 100%;
  }

  .section-band {
    padding: 14px;
  }

  .semantic-operator-row small {
    white-space: normal;
  }
}
