:root {
  color-scheme: light;
  --ink: #152238;
  --muted: #6d7d93;
  --line: #dfe6ef;
  --panel: #ffffff;
  --canvas: #f3f6fa;
  --blue: #2f80ed;
  --blue-dark: #1f66c1;
  --orange: #f2994a;
  --green: #219653;
  --red: #d64545;
  --shadow: 0 14px 38px rgba(38, 54, 77, .10);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas); color: var(--ink); }
button, input, select { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

.app-shell { max-width: 1480px; margin: 0 auto; padding: 28px 32px 64px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.eyebrow { color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .13em; }
h1, h2 { margin: 4px 0 0; letter-spacing: -.025em; }
h1 { font-size: clamp(27px, 3vw, 40px); }
h1 span { color: var(--orange); }
.topbar p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }
.top-actions, .dialog-actions, .card-actions { display: flex; gap: 10px; align-items: center; }

.button { border: 1px solid transparent; border-radius: 9px; padding: 10px 16px; font-weight: 700; font-size: 13px; cursor: pointer; text-decoration: none; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .55; cursor: wait; transform: none; }
.button.primary { background: var(--blue); color: white; box-shadow: 0 6px 16px rgba(47, 128, 237, .22); }
.button.primary:hover { background: var(--blue-dark); }
.button.secondary { background: white; border-color: var(--line); color: var(--ink); }
.button.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.button.success { background: #e6f7ee; color: var(--green); border-color: #bfe8d0; }

.notice { border-radius: 10px; padding: 13px 16px; margin-bottom: 16px; font-size: 14px; border: 1px solid #bbd7fa; background: #edf5ff; color: #255d9c; }
.notice.success { background: #eaf8f0; color: #237044; border-color: #c5ead4; }
.notice.warning { background: #fff7e8; color: #8a5c16; border-color: #f5deb1; }
.notice.error { background: #fff0f0; color: #9d3030; border-color: #efc2c2; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stats article { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px; box-shadow: 0 3px 12px rgba(31, 51, 73, .04); }
.stats span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.stats strong { display: block; margin-top: 7px; font-size: 29px; letter-spacing: -.04em; }

.toolbar { display: flex; gap: 12px; align-items: flex-end; padding: 15px; margin-bottom: 16px; background: white; border: 1px solid var(--line); border-radius: 12px; }
.toolbar label { min-width: 210px; }
.toolbar .search-field { flex: 1; }
label > span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; margin-bottom: 6px; }
input, select { width: 100%; min-height: 40px; border: 1px solid #ced8e6; border-radius: 8px; padding: 8px 11px; background: white; color: var(--ink); outline: none; }
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47, 128, 237, .12); }

.tender-list { display: grid; gap: 12px; }
.tender-card { background: white; border: 1px solid var(--line); border-radius: 13px; padding: 20px; box-shadow: 0 4px 16px rgba(31, 51, 73, .045); }
.tender-card:hover { border-color: #c7d4e5; box-shadow: var(--shadow); }
.tender-head { display: flex; justify-content: space-between; gap: 20px; }
.tender-title { min-width: 0; }
.tender-title h2 { font-size: 18px; line-height: 1.35; margin-top: 9px; }
.tender-number { color: var(--muted); font-size: 12px; margin: 5px 0 0; }
.tender-meta, .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.badge, .tags span { padding: 4px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.badge.source { color: #a35915; background: #fff1e2; }
.badge.score { color: #2769b1; background: #eaf3ff; }
.badge.status { color: #53657d; background: #eef2f7; }
.badge.status-converted { color: #237044; background: #e7f7ee; }
.badge.status-rejected, .badge.status-closed { color: #8b5560; background: #f8ecef; }
.money { flex: 0 0 auto; font-size: 17px; font-weight: 800; white-space: nowrap; color: #263b55; }
.tender-info { display: grid; grid-template-columns: 1.25fr .6fr 1.5fr .8fr; gap: 12px; padding: 14px 0; margin-top: 14px; border-top: 1px solid #edf1f6; border-bottom: 1px solid #edf1f6; }
.info-item { min-width: 0; }
.info-item span { display: block; color: var(--muted); font-size: 10px; font-weight: 700; margin-bottom: 4px; }
.info-item strong { display: block; font-size: 12px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; }
.info-item.danger strong, .info-item.expired strong { color: var(--red); }
.info-item.warning strong { color: #b47718; }
.tags { margin-top: 12px; }
.tags span { color: #53657d; background: #f2f5f8; font-weight: 600; }
.card-actions { justify-content: flex-end; margin-top: 14px; }
.empty-state { padding: 60px 24px; text-align: center; border: 1px dashed #c8d3e1; border-radius: 13px; color: var(--muted); background: rgba(255,255,255,.55); }

dialog { width: min(760px, calc(100vw - 32px)); border: 0; border-radius: 16px; padding: 0; box-shadow: 0 24px 80px rgba(19, 35, 57, .28); }
dialog::backdrop { background: rgba(22, 34, 51, .48); backdrop-filter: blur(3px); }
dialog form { padding: 25px; }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 22px; }
.dialog-header h2 { font-size: 24px; }
.icon-button { background: #f1f4f8; border: 0; width: 34px; height: 34px; border-radius: 50%; color: var(--muted); font-size: 22px; cursor: pointer; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid small { display: block; margin-top: 6px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 9px; padding: 11px 12px; background: #f5f8fc; border-radius: 9px; }
.check input { width: 17px; min-height: 17px; }
.check span { margin: 0; font-size: 12px; color: var(--ink); }
.warning-check { background: #fff8ea; }
.dialog-actions { justify-content: flex-end; margin-top: 22px; }

.install-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #e9f3ff, #f5f7fa 55%); }
.install-card { width: min(530px, 100%); padding: 38px; text-align: center; background: white; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.install-card h1 { font-size: 30px; margin: 10px 0; }
.install-card p { color: var(--muted); line-height: 1.6; }
.install-mark { display: inline-grid; place-items: center; width: 64px; height: 64px; margin-bottom: 20px; border-radius: 17px; color: white; background: var(--blue); font-size: 22px; font-weight: 900; }
.install-mark span { color: #ffd2a9; }
.install-error { white-space: pre-wrap; text-align: left; max-height: 180px; overflow: auto; background: #fff0f0; color: #8d2e2e; padding: 12px; border-radius: 8px; font-size: 12px; }

@media (max-width: 850px) {
  .app-shell { padding: 20px 16px 48px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .stats { grid-template-columns: 1fr 1fr; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar label { min-width: 0; }
  .tender-head { flex-direction: column; }
  .tender-info { grid-template-columns: 1fr 1fr; }
  .money { order: -1; }
}

@media (max-width: 560px) {
  .stats, .form-grid, .tender-info { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .top-actions, .card-actions { width: 100%; flex-wrap: wrap; }
  .top-actions .button, .card-actions .button { flex: 1; text-align: center; }
  dialog form, .install-card { padding: 22px; }
}
