/* Дизайн-система INITASK: luxury-стиль для системи внутрішніх тендерів */

:root {
  --midnight: #0A0E27;
  --midnight-2: #0E1230;
  --navy: #151B3D;
  --navy-soft: #1B2247;
  --line: #252C52;
  --line-2: #323A66;
  --gold: #C9A961;
  --gold-light: #E8D5A3;
  --gold-dim: #9A7F45;
  --ivory: #F5F1E8;
  --farmak-blue: #0054A6;
  --white: #FFFFFF;
  --platinum: #C8C5D6;
  --fog: #8E92B0;
  --fog-dim: #5A5F84;
  --blue: #1796FC;
  --blue-light: #4DA8FF;
  --danger: #E06C6C;
  --ok: #6CC98F;
  --radius: 14px;
  --radius-sm: 9px;
  --font-head: 'Cormorant Garamond', 'Times New Roman', serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  background:
    radial-gradient(900px 600px at 85% -10%, rgba(23, 150, 252, 0.10), transparent 60%),
    radial-gradient(800px 500px at -10% 10%, rgba(120, 80, 220, 0.10), transparent 55%),
    radial-gradient(700px 600px at 100% 100%, rgba(201, 169, 97, 0.07), transparent 55%),
    var(--midnight);
  background-attachment: fixed;
  color: var(--white);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-head); font-style: italic; font-weight: 600; letter-spacing: 0.01em; }
h1 { font-size: 34px; }
h2 { font-size: 26px; }
h3 { font-size: 20px; }

a { color: var(--blue-light); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--blue-light); outline-offset: 2px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ===== Шапка ===== */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(14, 18, 48, 0.92), rgba(10, 14, 39, 0.85));
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(8px);
}
.wordmark {
  font-weight: 700; font-size: 19px; letter-spacing: 0.14em; color: var(--white);
  font-family: var(--font-body); cursor: pointer; user-select: none;
}
.wordmark .i { color: var(--blue); }
.client-chip {
  background: var(--ivory); color: var(--farmak-blue);
  font-weight: 600; font-size: 12px; letter-spacing: 0.04em;
  padding: 4px 12px; border-radius: 999px;
}
.topbar-title { color: var(--fog); font-size: 13px; }
.topbar-spacer { flex: 1; }
.nav-links { display: flex; gap: 4px; }
.nav-link {
  background: none; border: none; cursor: pointer;
  color: var(--platinum); font-family: var(--font-body); font-size: 14px;
  padding: 8px 14px; border-radius: var(--radius-sm);
}
.nav-link:hover { color: var(--white); background: var(--navy-soft); }
.nav-link.active { color: var(--white); background: var(--navy-soft); box-shadow: inset 0 -2px 0 var(--blue); }

/* Дзвіночок */
.bell-wrap { position: relative; }
.bell-btn {
  background: none; border: 1px solid var(--line-2); border-radius: 50%;
  width: 38px; height: 38px; cursor: pointer; color: var(--platinum);
  display: grid; place-items: center; font-size: 16px;
}
.bell-btn:hover { border-color: var(--gold-dim); color: var(--gold-light); }
.bell-count {
  position: absolute; top: -5px; right: -5px;
  background: var(--blue); color: #fff; border-radius: 999px;
  font-size: 10px; font-weight: 700; min-width: 17px; height: 17px;
  display: grid; place-items: center; padding: 0 4px;
}
.bell-menu {
  position: absolute; right: 0; top: 46px; width: 360px; max-width: 86vw;
  background: linear-gradient(160deg, var(--navy), var(--midnight-2));
  border: 1px solid var(--line-2); border-radius: var(--radius);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.5); z-index: 60;
  max-height: 70vh; overflow: auto;
}
.bell-item { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13px; cursor: pointer; }
.bell-item:hover { background: var(--navy-soft); }
.bell-item.unread { border-left: 3px solid var(--blue); }
.bell-item .when { color: var(--fog-dim); font-size: 11px; margin-top: 3px; }
.bell-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }

.user-chip { display: flex; align-items: center; gap: 10px; color: var(--platinum); font-size: 13px; }
.user-chip .role { color: var(--fog-dim); font-size: 11px; display: block; }

/* ===== Каркас сторінки ===== */
.page { max-width: 1280px; margin: 0 auto; padding: 30px 26px 80px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 24px; flex-wrap: wrap; }

.eyebrow {
  color: var(--gold); text-transform: uppercase; font-size: 11px;
  letter-spacing: 0.22em; font-weight: 600; display: inline-flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
}
.eyebrow::before { content: ''; width: 18px; height: 2px; background: var(--blue); }

/* ===== Картки ===== */
.card {
  background: linear-gradient(160deg, var(--navy), var(--midnight-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.card + .card { margin-top: 18px; }

/* Золоті кутові рамки на ключових картках */
.card-gold { position: relative; }
.card-gold::before, .card-gold::after {
  content: ''; position: absolute; width: 26px; height: 26px; pointer-events: none;
}
.card-gold::before {
  top: -1px; left: -1px;
  border-top: 1px solid var(--gold); border-left: 1px solid var(--gold);
  border-top-left-radius: var(--radius);
}
.card-gold::after {
  bottom: -1px; right: -1px;
  border-bottom: 1px solid var(--gold); border-right: 1px solid var(--gold);
  border-bottom-right-radius: var(--radius);
}

.hairline { border: none; border-top: 1px solid var(--line); margin: 18px 0; position: relative; }
.hairline::after {
  content: ''; position: absolute; left: 0; top: -1px; width: 90px; height: 1px;
  background: linear-gradient(90deg, var(--gold), transparent);
}

/* ===== Кнопки ===== */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  font-family: var(--font-body); font-size: 14px; font-weight: 600;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  padding: 9px 18px; cursor: pointer; transition: filter 0.15s, background 0.15s;
  color: var(--white); background: var(--navy-soft); border-color: var(--line-2);
}
.btn:hover { filter: brightness(1.15); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; filter: none; }
.btn-primary { background: linear-gradient(135deg, var(--blue), #0F7FD9); border-color: transparent; }
.btn-gold { background: linear-gradient(135deg, var(--gold), var(--gold-dim)); color: var(--midnight); border-color: transparent; }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--platinum); }
.btn-danger { background: transparent; border-color: rgba(224, 108, 108, 0.5); color: var(--danger); }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-ai { position: relative; }
.btn-ai::before { content: '✦'; color: var(--gold-light); }
.btn-primary.btn-ai::before { color: #fff; }

/* ===== Форми ===== */
label.fld { display: block; margin-bottom: 14px; }
label.fld > span { display: block; font-size: 12px; color: var(--fog); margin-bottom: 6px; letter-spacing: 0.02em; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"],
select, textarea {
  width: 100%; background: var(--midnight-2); color: var(--white);
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: 9px 12px; font-family: var(--font-body); font-size: 14px;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: none; }
textarea { resize: vertical; min-height: 90px; }
select option { background: var(--midnight-2); }
.req::after { content: ' *'; color: var(--gold); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint { font-size: 12px; color: var(--fog-dim); margin-top: 4px; }

/* ===== Таблиці ===== */
.tbl-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--line); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
.tbl thead th {
  background: var(--gold); color: var(--midnight);
  font-weight: 700; text-align: left; padding: 10px 12px; font-size: 12px;
  letter-spacing: 0.04em; white-space: nowrap;
}
.tbl tbody td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.tbl tbody tr:hover { background: rgba(27, 34, 71, 0.5); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.winner td { background: rgba(201, 169, 97, 0.10); }
tr.winner td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
.rank-1 { color: var(--gold-light); font-weight: 700; }

/* ===== Бейджі статусів ===== */
.badge {
  display: inline-block; font-size: 11px; font-weight: 600; letter-spacing: 0.05em;
  border-radius: 999px; padding: 3px 11px; border: 1px solid var(--line-2); color: var(--platinum);
  white-space: nowrap;
}
.badge.st-draft { color: var(--fog); }
.badge.st-tz_ready { color: var(--blue-light); border-color: rgba(77, 168, 255, 0.4); }
.badge.st-collecting { color: #B79CFF; border-color: rgba(183, 156, 255, 0.4); }
.badge.st-scoring { color: var(--gold-light); border-color: var(--gold-dim); }
.badge.st-committee { color: #FFB86C; border-color: rgba(255, 184, 108, 0.4); }
.badge.st-protocol { color: var(--ok); border-color: rgba(108, 201, 143, 0.4); }
.badge.st-archived { color: var(--fog-dim); }
.badge.demo { color: var(--gold-light); border-color: var(--gold-dim); }

/* ===== Сітка реєстру ===== */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.tender-card { cursor: pointer; transition: border-color 0.15s, transform 0.15s; }
.tender-card:hover { border-color: var(--gold-dim); transform: translateY(-2px); }
.tender-card h3 { font-size: 19px; margin: 8px 0 6px; }
.tender-card .meta { color: var(--fog); font-size: 12.5px; display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; align-items: center; }
.filters input, .filters select { width: auto; min-width: 150px; }

/* ===== Вкладки тендера ===== */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; }
.tab {
  background: none; border: none; cursor: pointer; color: var(--fog);
  font-family: var(--font-body); font-size: 14px; font-weight: 500;
  padding: 10px 16px; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--platinum); }
.tab.active { color: var(--white); border-bottom-color: var(--gold); }

/* ===== Модалки ===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(5, 8, 22, 0.7); z-index: 80;
  display: grid; place-items: center; padding: 20px; backdrop-filter: blur(3px);
}
.modal {
  background: linear-gradient(165deg, var(--navy), var(--midnight-2));
  border: 1px solid var(--line-2); border-radius: var(--radius);
  width: 640px; max-width: 100%; max-height: 88vh; overflow: auto;
  padding: 26px; position: relative;
}
.modal.wide { width: 900px; }
.modal-close {
  position: absolute; top: 14px; right: 14px; background: none; border: none;
  color: var(--fog); font-size: 20px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--white); }
.modal h2 { margin-bottom: 18px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; flex-wrap: wrap; }

/* ===== Тости ===== */
#toast-root { position: fixed; bottom: 24px; right: 24px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--navy); border: 1px solid var(--line-2); border-left: 3px solid var(--blue);
  border-radius: var(--radius-sm); padding: 12px 18px; font-size: 13.5px; max-width: 380px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); animation: toast-in 0.25s ease;
}
.toast.err { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== Логін ===== */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 430px; max-width: 100%; padding: 40px 36px; }
.login-card h1 { font-size: 30px; margin: 14px 0 6px; }
.login-sub { color: var(--fog); font-size: 13.5px; margin-bottom: 26px; }
.login-brand { display: flex; align-items: center; gap: 12px; }

/* ===== Markdown-прев'ю ===== */
.md-view { font-size: 14px; color: var(--platinum); line-height: 1.65; }
.md-view h1 { font-size: 24px; color: var(--white); margin: 18px 0 10px; }
.md-view h2 { font-size: 18px; color: var(--gold-light); margin: 18px 0 8px; }
.md-view h3 { font-size: 15.5px; color: var(--white); margin: 14px 0 6px; }
.md-view p { margin: 8px 0; }
.md-view ul, .md-view ol { margin: 8px 0 8px 22px; }
.md-view table { border-collapse: collapse; margin: 12px 0; width: 100%; font-size: 13px; }
.md-view th { background: var(--gold); color: var(--midnight); padding: 6px 10px; text-align: left; }
.md-view td { border: 1px solid var(--line-2); padding: 6px 10px; }
.md-view hr { border: none; border-top: 1px solid var(--line); margin: 14px 0; }
.md-view code { background: var(--midnight-2); border-radius: 4px; padding: 1px 6px; font-size: 12.5px; }

/* ===== Diff ===== */
.diff-view { font-family: ui-monospace, 'SF Mono', Consolas, monospace; font-size: 12.5px; line-height: 1.6; }
.diff-line { padding: 1px 10px; white-space: pre-wrap; word-break: break-word; }
.diff-line.add { background: rgba(108, 201, 143, 0.12); color: var(--ok); }
.diff-line.del { background: rgba(224, 108, 108, 0.10); color: var(--danger); text-decoration: line-through; }
.diff-line.same { color: var(--fog); }

/* ===== Чат ===== */
.chat-box { display: flex; flex-direction: column; gap: 12px; max-height: 460px; overflow-y: auto; padding: 6px 2px; }
.chat-msg { max-width: 82%; padding: 10px 14px; border-radius: 12px; font-size: 13.5px; }
.chat-msg.user { align-self: flex-end; background: rgba(23, 150, 252, 0.16); border: 1px solid rgba(23, 150, 252, 0.35); }
.chat-msg.assistant { align-self: flex-start; background: var(--navy-soft); border: 1px solid var(--line-2); }
.chat-msg .who { font-size: 10.5px; color: var(--fog-dim); margin-bottom: 4px; letter-spacing: 0.05em; text-transform: uppercase; }
.chat-input { display: flex; gap: 10px; margin-top: 14px; }
.chat-input input { flex: 1; }
.chat-suggest { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chip {
  background: var(--midnight-2); border: 1px solid var(--line-2); color: var(--fog);
  font-size: 12px; border-radius: 999px; padding: 4px 12px; cursor: pointer;
}
.chip:hover { color: var(--gold-light); border-color: var(--gold-dim); }

/* ===== Раунди, історія ===== */
.rounds { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.rounds .r { color: var(--fog); }
.rounds .r.last { color: var(--white); font-weight: 600; }

.kv { display: grid; grid-template-columns: 190px 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--fog); }
.kv dd { color: var(--platinum); }

.list-plain { list-style: none; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--line); }

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

.empty {
  text-align: center; color: var(--fog); padding: 46px 20px; font-size: 14px;
  border: 1px dashed var(--line-2); border-radius: var(--radius);
}

.section-title { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }

.score-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.score-cell label { display: block; font-size: 12px; color: var(--fog); margin-bottom: 4px; }

.ai-note { font-size: 12px; color: var(--fog-dim); font-style: italic; }
.ai-reason { font-size: 11.5px; color: var(--gold-light); margin-top: 3px; }

.approve-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.approve-row .ok-mark { color: var(--ok); }
.approve-row .wait-mark { color: var(--fog-dim); }

/* Друк: чистий білий документ */
.print-sheet { display: none; }
body.printing .print-sheet { display: block; background: #fff; color: #000; padding: 20px; }
body.printing #app, body.printing #modal-root, body.printing #toast-root { display: none; }
body.printing .print-sheet .md-view,
body.printing .print-sheet .md-view h1,
body.printing .print-sheet .md-view h2,
body.printing .print-sheet .md-view h3,
body.printing .print-sheet .md-view p { color: #000; }
body.printing .print-sheet .md-view th { background: #eee; color: #000; }
body.printing .print-sheet .md-view td { border-color: #999; }

@media print {
  body { background: #fff; color: #000; }
  .topbar, .tabs, .btn, .filters, .chat-input, #toast-root, .no-print { display: none !important; }
  .card { border: none; background: #fff; color: #000; }
  .md-view, .md-view h1, .md-view h2, .md-view h3, .md-view p { color: #000; }
  .md-view th { background: #eee; color: #000; }
}

/* ===== Адаптив ===== */
@media (max-width: 900px) {
  .form-row { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 8px; }
}
@media (max-width: 580px) {
  .page { padding: 18px 14px 60px; }
  .topbar { padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
  .topbar-title { display: none; }
  .grid-cards { grid-template-columns: 1fr; }
  h1 { font-size: 26px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .modal { padding: 18px; }
  .chat-msg { max-width: 95%; }
}
