/* Оформление платформенного кабинета.
 *
 * Палитра совпадает с локальным приложением, но стили самостоятельные:
 * платформа не импортирует `app.*` и не зависит от его статики.
 */

:root {
  --bg: #f3f1ec;
  --surface: #fffdf9;
  --ink: #1e2a32;
  --muted: #65727b;
  --line: #ddd8ce;
  --accent: #1f6f5c;
  --accent-soft: #dff0ea;
  --warn: #9a6b14;
  --fail: #a23b32;
  --shadow: 0 10px 30px rgba(30, 42, 50, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  line-height: 1.55;
}

a {
  color: var(--accent);
}

.wrap {
  width: min(1080px, calc(100% - 40px));
  margin: 0 auto;
}

/* --- шапка --- */

.topbar {
  background: #173a34;
  color: #f5f2ea;
  padding: 18px 0;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: #e8c96a;
  color: #173a34;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.brand p {
  margin: 2px 0 0;
  color: #b9cdc6;
  font-size: 13px;
}

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

.who {
  color: #d9e5e0;
  font-size: 14px;
}

.topbar-actions form {
  margin: 0;
}

.ghost-link {
  font: inherit;
  font-size: 14px;
  color: #e8c96a;
  background: transparent;
  border: 1px solid rgba(232, 201, 106, 0.45);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
}

.ghost-link:hover {
  background: rgba(232, 201, 106, 0.12);
}

main {
  padding: 34px 0 18px;
  min-height: calc(100vh - 210px);
}

/* --- общие блоки --- */

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: clamp(24px, 3vw, 32px);
  letter-spacing: -0.02em;
}

.panel h3 {
  margin: 0 0 12px;
  font-size: 17px;
}

.lead {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15.5px;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12.5px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 22px;
}

/* --- формы --- */

.auth-shell {
  display: flex;
  justify-content: center;
  padding-top: 12px;
}

.auth-card {
  width: min(560px, 100%);
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

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

.field b {
  color: var(--fail);
}

.field input,
.field select {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 11px;
  min-height: 40px;
}

.field input:focus,
.field select:focus {
  outline: 2px solid rgba(31, 111, 92, 0.35);
  outline-offset: 1px;
  border-color: var(--accent);
}

/* --- KS-AUTH-06: видимость пароля --- */

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

.password-wrap input {
  width: 100%;
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.password-toggle:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.password-toggle[aria-pressed="true"] {
  color: var(--accent);
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 16px;
  font-size: 13.5px;
  color: var(--muted);
}

.check-row input {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  display: inline-block;
  font: inherit;
  font-size: 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 9px 16px;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  border-color: var(--accent);
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.btn.primary:hover {
  background: #1a5d4d;
}

.btn.small {
  font-size: 12.5px;
  padding: 5px 10px;
}

.form-error {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 9px;
  background: #f6dedb;
  border: 1px solid #e5b7b1;
  color: var(--fail);
  font-size: 13.5px;
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
  font-size: 13.5px;
}

/* --- сообщения --- */

.notice {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #faf8f3;
  font-size: 14px;
}

.notice h3 {
  margin: 0 0 8px;
  font-size: 15.5px;
}

.notice p {
  margin: 0;
}

.notice p + p {
  margin-top: 8px;
}

.notice.warn {
  border-color: #e2cfa0;
  background: #fdf6e4;
  color: #6d4f10;
}

.notice.warn h3 {
  color: var(--warn);
}

.notice.compact {
  margin-top: 12px;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 13.5px;
}

.pill {
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill.pending {
  background: #eee9df;
  color: var(--warn);
}

.pill.ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill.fail {
  background: #f6dedb;
  color: var(--fail);
}

/* --- кабинет --- */

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

.page-head h2 {
  margin: 0;
  font-size: clamp(26px, 3.5vw, 36px);
  letter-spacing: -0.02em;
}

.page-head .lead {
  margin-top: 4px;
}

.company-list {
  display: grid;
  gap: 16px;
}

.company-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.company-head h3 {
  margin: 0 0 2px;
  font-size: 18px;
}

.company-head .hint {
  margin: 0;
}

.company-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 20px;
  margin: 16px 0 0;
}

.company-facts div {
  min-width: 0;
}

.company-facts dt {
  margin: 0;
  color: var(--muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.company-facts dd {
  margin: 2px 0 0;
  font-size: 14px;
}

.company-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.inline-form {
  margin: 0;
}

/* --- администрирование платформы --- */

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

.admin-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
}

.admin-stat span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.admin-stat strong {
  font-size: 26px;
}

.table-scroll {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th {
  text-align: left;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.admin-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table form {
  margin: 0;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.empty {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.empty-state {
  text-align: left;
}

.next-step {
  margin-top: 20px;
}

.steps {
  margin: 14px 0 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 14px;
}

.steps li + li {
  margin-top: 6px;
}

.connect-code {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: #faf8f3;
}

.connect-code code {
  flex: 1 1 320px;
  min-width: 0;
  font-size: 13px;
  overflow-wrap: anywhere;
  user-select: all;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.footer {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  justify-content: space-between;
  padding: 18px 0 28px;
  color: var(--muted);
  font-size: 12.5px;
}

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

  .field.span-2 {
    grid-column: auto;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }
}

/* --- KS-COMPANY-01: подсказки реквизитов в форме создания компании ---
 *
 * Разметку списка создаёт общий `hintdata.js` узла: стили повторяют
 * оформление локального приложения, но остаются в платформенном CSS.
 */

.suggest-box {
  position: relative;
  display: block;
}

.suggest-box input {
  width: 100%;
}

.suggest-list {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.suggest-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-left: 3px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink);
}

.suggest-item.active,
.suggest-item:hover {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.suggest-item.active .suggest-title {
  color: var(--accent);
}

.suggest-title {
  font-size: 13.5px;
  font-weight: 600;
}

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

.suggest-status {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--warn);
}

.suggest-empty {
  padding: 8px 10px;
  font-size: 12.5px;
  color: var(--muted);
}

.suggest-empty.suggest-loading {
  color: var(--accent);
}

#party-card {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #faf8f3;
  font-size: 13px;
  color: var(--ink);
}

/* KS-COMPANY-01: реквизиты в форме создания компании и на её карточке. */

.requisites-box {
  margin: 18px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #faf8f3;
}

.requisites-box legend {
  padding: 0 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.requisites-box .field-grid {
  margin-top: 10px;
}

#party-draft {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

#party-draft h4 {
  margin: 0 0 10px;
  font-size: 14px;
  color: var(--ink);
}

/* --- KS-COMPANY-03: компактная карточка и выбор хранилища ---
 *
 * Подробные реквизиты и форма правки живут в <details>: в свёрнутом
 * состоянии видна только компактная карточка, раскрытие — отдельным
 * действием. Нереализованные хранилища показываются без кнопок.
 */

.company-card .company-facts {
  margin-top: 14px;
}

details.panel > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15.5px;
  list-style: none;
}

details.panel > summary::-webkit-details-marker {
  display: none;
}

details.panel > summary::before {
  content: "▸";
  display: inline-block;
  width: 18px;
  color: var(--accent);
}

details.panel[open] > summary::before {
  content: "▾";
}

details.panel[open] > summary {
  margin-bottom: 12px;
}

.storage-options {
  display: grid;
  gap: 12px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.storage-option {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #faf8f3;
}

.storage-option.unavailable {
  background: #fffdf9;
}

.storage-option.unavailable strong {
  color: var(--muted);
}

.storage-option-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px 14px;
}

.storage-option-head strong {
  font-size: 14.5px;
}

.storage-option .hint {
  margin-top: 6px;
}

.storage-connect {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}

.storage-connect h4 {
  margin: 0 0 8px;
  font-size: 15px;
}

.storage-connect .company-facts {
  margin-top: 10px;
}
