﻿:root {
  --paper: #f6f9fc;
  --paper-2: #edf2f7;
  --card: #ffffff;
  --ink: #07111f;
  --ink-2: #142338;
  --ink-3: #607087;
  --line: rgba(7, 17, 31, 0.10);
  --line-strong: rgba(7, 17, 31, 0.20);
  --forest: #0a1728;
  --forest-2: #11243b;
  --forest-3: #1a3452;
  --on-forest: #ffffff;
  --on-forest-2: #94a3b8;
  --signal: #1e63ff;
  --signal-hover: #1652e0;
  --signal-ink: #1e63ff;
  --tg-wall: #cfdbe6;
  --tg-in: #ffffff;
  --tg-out: #e3f7d0;
  --tg-link: #2a7ab8;

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  --display: "Bricolage Grotesque", "Geist", system-ui, sans-serif;
  --body: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --wrap: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
  --radius: 14px;
  --shadow: 0 1px 2px rgba(7, 17, 31, 0.06), 0 12px 32px -12px rgba(7, 17, 31, 0.20);
  --shadow-lg: 0 2px 4px rgba(7, 17, 31, 0.06), 0 32px 64px -24px rgba(7, 17, 31, 0.34);
  --cyan: #16c7d9;
  --cyan-300: #67e8f9;
  --ok: #15803d;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 17px/1.6 var(--body);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--signal); color: #fff; }
:focus-visible { outline: 2px solid var(--signal-ink); outline-offset: 3px; border-radius: 6px; }
img, svg { display: block; max-width: 100%; }
a { color: inherit; text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.025em; line-height: 1.04; margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.wrap { width: min(100% - 2 * var(--gutter), var(--wrap)); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -60px; background: var(--ink); color: var(--paper); padding: 10px 14px; border-radius: 8px; z-index: 50; }
.skip:focus { top: 12px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 48px; padding: 0 22px;
  border-radius: 999px; border: 0;
  font: 600 16px/1 var(--body); text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform 160ms var(--ease-out), background-color 200ms ease, box-shadow 200ms ease;
}
.btn:active { transform: scale(0.97); }
.btn-go { background: var(--signal); color: #fff; box-shadow: 0 10px 24px -8px rgba(30, 99, 255, 0.55); }
.btn-ink { background: var(--ink); color: var(--paper); }
.btn-ghost { background: transparent; color: inherit; box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn svg { width: 18px; height: 18px; transition: transform 200ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .btn-go:hover { background: var(--signal-hover); }
  .btn-ink:hover { background: var(--forest-3); }
  .btn-ghost:hover { box-shadow: inset 0 0 0 1px var(--ink); }
  .btn:hover svg { transform: translateX(3px); }
}

button { font: inherit; color: inherit; }
.btn { justify-content: center; text-align: center; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 14px; gap: 8px; }
.btn-sm svg { width: 16px; height: 16px; }
.btn-block { display: flex; width: 100%; }
.btn-soft { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-strong); }
.btn-danger { background: #c4320a; color: #fff; }
.btn-danger-soft { background: #fff1ed; color: #a2321c; box-shadow: inset 0 0 0 1px #f7c9bd; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
@media (hover: hover) and (pointer: fine) {
  .btn-soft:hover { box-shadow: inset 0 0 0 1px var(--ink); }
  .btn-danger:hover { background: #a82a07; }
  .btn-danger-soft:hover { background: #ffe4dc; }
  .btn:not(.has-arrow):hover svg { transform: none; }
  .btn.has-arrow:hover svg { transform: translateX(3px); }
}
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.actions.end { justify-content: flex-end; }
@media (max-width: 560px) {
  .actions.stack { flex-direction: column; align-items: stretch; }
  .actions.stack > .btn { width: 100%; }
}

/* ---------- Brand ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 18px; letter-spacing: -0.02em; white-space: nowrap; color: inherit; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--signal); display: grid; place-items: center; flex: none; }
.brand-mark svg { width: 18px; height: 18px; }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > span, .label { font-size: 14px; font-weight: 600; color: var(--ink-2); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.field em { font-style: normal; font-weight: 500; font-size: 12px; color: var(--ink-3); }
.field small, .hint { font-size: 13px; color: var(--ink-3); line-height: 1.45; }
.input, .select, .textarea {
  width: 100%; min-width: 0; min-height: 46px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line-strong); background: var(--card);
  font: 400 16px/1.4 var(--body); color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.textarea { padding: 12px 14px; min-height: 120px; resize: vertical; line-height: 1.5; }
.select { appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23607087' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; text-overflow: ellipsis; }
.input::placeholder, .textarea::placeholder { color: #8796aa; }
.input:hover, .select:hover, .textarea:hover { border-color: rgba(7,17,31,0.32); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--signal); box-shadow: 0 0 0 4px rgba(30, 99, 255, 0.14); }
.input[readonly] { background: var(--paper); }
.affix { display: flex; align-items: stretch; min-width: 0; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--card); transition: border-color 160ms ease, box-shadow 160ms ease; }
.affix:focus-within { border-color: var(--signal); box-shadow: 0 0 0 4px rgba(30, 99, 255, 0.14); }
.affix .input { border: 0; box-shadow: none !important; background: transparent; }
.affix > span { display: grid; place-items: center; padding: 0 12px; color: var(--ink-3); font-size: 15px; font-weight: 500; white-space: nowrap; }
.affix > span:first-child { border-right: 1px solid var(--line); }
.affix > span:last-child:not(:first-child) { border-left: 1px solid var(--line); }
.affix > button { appearance: none; border: 0; background: none; padding: 0 12px; color: var(--ink-3); cursor: pointer; display: grid; place-items: center; }
.affix > button svg { width: 20px; height: 20px; }
.affix > button:hover { color: var(--ink); }
.check { display: grid; grid-template-columns: 20px 1fr; gap: 10px; align-items: start; font-size: 15px; color: var(--ink-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--signal); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- Badges / alerts ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; line-height: 1; padding: 6px 10px; border-radius: 999px; white-space: nowrap; background: var(--paper-2); color: var(--ink-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.badge.plain::before { display: none; }
.badge.ok { background: #e7f7ed; color: var(--ok); }
.badge.warn { background: #fff3d6; color: #8a5a00; }
.badge.danger { background: #ffe2dc; color: #a2321c; }
.badge.info { background: #e6eeff; color: var(--signal); }
.alert { display: grid; grid-template-columns: 22px 1fr; gap: 12px; padding: 14px 16px; border-radius: 12px; background: #e6eeff; color: var(--ink-2); font-size: 15px; }
.alert svg { width: 20px; height: 20px; color: var(--signal); margin-top: 1px; }
.alert strong { color: var(--ink); }
.alert.warn { background: #fff6e0; } .alert.warn svg { color: #b07400; }
.alert.danger { background: #fff1ed; } .alert.danger svg { color: #c4320a; }
.alert.ok { background: #eaf8ef; } .alert.ok svg { color: var(--ok); }

/* ---------- Toast ---------- */
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 80; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 15px; box-shadow: var(--shadow-lg); transition: opacity 200ms ease, transform 300ms var(--ease-out); max-width: calc(100% - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Dialog ---------- */
dialog.modal { width: min(560px, calc(100% - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 18px; background: var(--card); color: var(--ink); box-shadow: var(--shadow-lg); overflow: hidden; }
dialog.modal::backdrop { background: rgba(7, 17, 31, 0.55); backdrop-filter: blur(3px); }
dialog.modal[open] { animation: modal-in 260ms var(--ease-out); }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.modal-inner { display: flex; flex-direction: column; max-height: calc(100dvh - 32px); }
.modal-head { display: flex; justify-content: space-between; gap: 16px; padding: 22px 24px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { font-size: 22px; }
.modal-head p { margin-top: 6px; font-size: 15px; color: var(--ink-3); }
.modal-body { padding: 20px 24px; display: grid; gap: 16px; overflow-y: auto; }
.modal-foot { padding: 16px 24px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.icon-btn { appearance: none; border: 0; background: transparent; width: 40px; height: 40px; flex: none; border-radius: 10px; display: grid; place-items: center; color: var(--ink-2); cursor: pointer; transition: background-color 160ms ease; }
.icon-btn:hover { background: var(--paper-2); }
.icon-btn svg { width: 20px; height: 20px; }
@media (max-width: 560px) {
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
  .modal-head, .modal-body, .modal-foot { padding-left: 18px; padding-right: 18px; }
}

/* ---------- Responsive tables → cards ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--ink-3); padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.r, .table th.r { text-align: right; }
.table .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.table .who strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table .who small { display: block; color: var(--ink-3); font-size: 13px; }
.ini { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; font: 600 12px/1 var(--body); background: var(--paper-2); color: var(--ink-2); }
@media (max-width: 720px) {
  .table.cards thead { display: none; }
  .table.cards, .table.cards tbody, .table.cards tr, .table.cards td { display: block; width: 100%; }
  .table.cards tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
  .table.cards tr:last-child { border-bottom: 0; }
  .table.cards td { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 6px 0; border: 0; text-align: right; }
  .table.cards td::before { content: attr(data-label); font-size: 13px; color: var(--ink-3); text-align: left; flex: none; }
  .table.cards td:first-child { padding-bottom: 10px; }
  .table.cards td:first-child::before { display: none; }
  .table.cards td.r { text-align: right; }
}

/* ---------- Mockup ribbon ---------- */
.ribbon { border: 1px solid rgba(255,255,255,0.14); position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; gap: 8px; align-items: center; background: var(--ink); color: var(--paper); font-size: 13px; padding: 6px 6px 6px 14px; border-radius: 999px; box-shadow: var(--shadow-lg); }
.ribbon a { background: var(--signal); color: #fff; text-decoration: none; font-weight: 600; padding: 6px 12px; border-radius: 999px; white-space: nowrap; }
.ribbon a.alt { background: transparent; color: #cbd5e1; padding: 6px 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

[hidden] { display: none !important; }
.table .num, .table td.r { white-space: nowrap; }

.badge.wrap { white-space: normal; line-height: 1.35; }
