:root {
    color-scheme: light;
    --surface-canvas: #f3f6fa;
    --surface-card: #fff;
    --surface-subtle: #f8fafc;
    --border: #dfe5ec;
    --border-strong: #cbd5e1;
    --text-strong: #17263b;
    --text: #29394f;
    --text-muted: #68778b;
    --primary: #1769c5;
    --primary-hover: #1058a9;
    --focus: #4b9bea;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background: var(--surface-canvas);
    font-synthesis: none;
    text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--surface-canvas); }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--surface-canvas); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

:focus-visible {
    outline: 3px solid rgba(75, 155, 234, .38);
    outline-offset: 2px;
}

h1 {
    margin: 0 0 8px;
    color: var(--text-strong);
    font-size: clamp(1.65rem, 2.8vw, 2.15rem);
    font-weight: 760;
    letter-spacing: -.038em;
    line-height: 1.14;
}

h2 { margin: 0 0 14px; color: var(--text-strong); font-size: 1.08rem; font-weight: 720; letter-spacing: -.018em; }
h3 { color: var(--text-strong); }
p { line-height: 1.58; }
a { color: var(--primary); text-underline-offset: 2px; }
.muted { color: var(--text-muted); }

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

.page-header p { max-width: 760px; margin: 5px 0 0; color: var(--text-muted); font-size: .91rem; }

.button {
    appearance: none;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid var(--border-strong);
    border-radius: 9px;
    padding: 8px 14px;
    color: #34445a;
    background: #fff;
    box-shadow: 0 1px 2px rgba(16, 34, 56, .04);
    font-size: .86rem;
    font-weight: 680;
    text-decoration: none;
    cursor: pointer;
    transition: background .14s ease, border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}

.button:hover { border-color: #b6c3d2; background: #f8fafc; box-shadow: 0 2px 5px rgba(16, 34, 56, .07); }
.button:active { transform: translateY(1px); }
.button.primary { border-color: var(--primary); color: #fff; background: linear-gradient(180deg, #2076d3, var(--primary)); box-shadow: 0 5px 12px rgba(23, 105, 197, .18); }
.button.primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); }
.button.danger { border-color: #efbbb6; color: #ad281e; background: #fffafa; }
.button.small { min-height: 32px; padding: 5px 10px; font-size: .77rem; }
.button.full { width: 100%; }
.button:disabled { opacity: .52; cursor: not-allowed; transform: none; }

.card {
    min-width: 0;
    padding: 21px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface-card);
    box-shadow: 0 2px 5px rgba(15, 36, 62, .035), 0 12px 32px rgba(15, 36, 62, .025);
}

.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(205px, 1fr)); gap: 16px; margin-bottom: 22px; }
.card-grid .card { position: relative; overflow: hidden; }
.card-grid .card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: linear-gradient(#4d9bea, #2372c8); opacity: .8; }
.metric { margin-top: 9px; color: var(--text-strong); font-size: 2rem; font-weight: 780; letter-spacing: -.045em; line-height: 1; }
.metric-label { color: var(--text-muted); font-size: .79rem; font-weight: 590; }

.table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 11px; background: #fff; }
.card > .table-wrap { margin: 0 -4px -4px; }
.tender-list-summary,
.table-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; color: var(--text-muted); font-size: .82rem; }
.tender-list-summary { margin: 0 2px 10px; }
.table-pagination { margin-top: 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid #e8edf3; text-align: left; vertical-align: top; }
th { color: #647386; background: #f7f9fc; font-size: .7rem; font-weight: 760; letter-spacing: .055em; text-transform: uppercase; white-space: nowrap; }
td { color: #35455a; font-size: .84rem; line-height: 1.45; }
tbody tr { transition: background .12s ease; }
tbody tr:hover { background: #fafcff; }
tr:last-child td { border-bottom: 0; }

.badge { display: inline-flex; align-items: center; min-height: 22px; border-radius: 999px; padding: 3px 8px; color: #536174; background: #eef2f6; font-size: .7rem; font-weight: 720; white-space: nowrap; }
.badge.success { color: #087249; background: #e9f9f1; }
.badge.warning { color: #a7510b; background: #fff4df; }
.badge.danger { color: #b12820; background: #fdeceb; }
.badge.info { color: #175fb0; background: #eaf4ff; }

.alert { margin: 14px 0; padding: 13px 15px; border: 1px solid #b9dcfa; border-radius: 10px; color: #24537e; background: #eef7ff; line-height: 1.48; }
.alert.success { border-color: #a9e5c6; color: #176343; background: #ecfaf3; }
.alert.danger { border-color: #f0bbb7; color: #922a22; background: #fdf0ef; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px 22px; }
.form-field { min-width: 0; display: grid; gap: 7px; }
.form-field.full { grid-column: 1 / -1; }
label { color: #3b4b60; font-size: .8rem; font-weight: 680; }
input, textarea, select { width: 100%; min-height: 40px; border: 1px solid var(--border-strong); border-radius: 9px; padding: 9px 11px; color: var(--text-strong); background: #fff; transition: border-color .14s ease, box-shadow .14s ease; }
input:hover, textarea:hover, select:hover { border-color: #aebdcd; }
input:focus, textarea:focus, select:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px rgba(75, 155, 234, .14); }
textarea { min-height: 112px; resize: vertical; }
input[type="checkbox"] { width: 17px; min-height: 17px; accent-color: var(--primary); }
.checkbox-row { display: flex; align-items: center; gap: 9px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid #edf0f4; }
.validation-message { color: #b12820; font-size: .77rem; }
.empty { padding: 38px 20px; color: var(--text-muted); text-align: center; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; }
.two-column { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; align-items: start; }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 0, #dceeff, transparent 34%), linear-gradient(150deg, #f7f9fc, #edf3f9); }
.login-card { width: min(100%, 420px); padding: 36px; border: 1px solid var(--border); border-radius: 18px; background: #fff; box-shadow: 0 24px 65px rgba(16, 39, 69, .13); }
.login-card form { display: grid; gap: 9px; margin-top: 25px; }
.login-card .brand-mark { width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: 20px; border-radius: 14px; color: #fff; background: linear-gradient(145deg, #2879e5, #0d5ec5); box-shadow: 0 10px 24px rgba(13, 94, 197, .24); font-size: .88rem; font-weight: 850; }
.source-list { display: grid; gap: 13px; }
.source-list > div { padding-bottom: 13px; border-bottom: 1px solid #edf0f4; }
.source-list > div:last-child { padding-bottom: 0; border-bottom: 0; }
.source-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; }
.code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .8rem; word-break: break-word; }

@media (max-width: 800px) {
    .form-grid,
    .two-column { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; gap: 15px; }
    .page-header .button { width: 100%; }
    .source-card { grid-template-columns: 1fr; }
    .table-wrap table { min-width: 680px; }
}

@media (max-width: 520px) {
    .card { padding: 17px; border-radius: 12px; }
    .card-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .card-grid .card { padding: 15px; }
    .metric { font-size: 1.65rem; }
    .metric-label { font-size: .71rem; }
    th, td { padding: 10px 11px; }
    .login-card { padding: 27px 23px; }
}

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

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
