:root {
    --primary: #1d4ed8;
    --primary-dark: #1e3a8a;
    --secondary: #64748b;
    --danger: #dc2626;
    --ok-bg: #dcfce7;
    --ok-text: #166534;
    --err-bg: #fee2e2;
    --err-text: #991b1b;
    --bg: #f4f6f9;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.topbar {
    background: var(--primary-dark);
    color: white;
}
.topbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}
.brand {
    color: white;
    font-weight: 700;
    font-size: 18px;
    text-decoration: none;
}
.topnav {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.topnav a {
    color: #dbeafe;
    text-decoration: none;
    font-size: 14px;
}
.topnav a:hover { color: white; text-decoration: underline; }
.user-chip {
    background: rgba(255,255,255,0.15);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 13px;
}

.page {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 20px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 20px;
}
.card h1 { margin-top: 0; font-size: 24px; }
.card h2 { font-size: 18px; margin-top: 0; }
.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.hero { text-align: center; padding: 40px 24px; }
.hero .lead { font-size: 18px; color: var(--muted); }

.auth-page { display: flex; justify-content: center; }
.auth-card { max-width: 420px; width: 100%; }

label {
    display: block;
    margin-bottom: 14px;
    font-weight: 600;
    font-size: 14px;
}
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
    display: block;
    width: 100%;
    margin-top: 6px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    font-weight: normal;
}
input[type=file] { margin-top: 6px; }
textarea { resize: vertical; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 640px) {
    .row-2, .row-4 { grid-template-columns: 1fr; }
}

.row-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
}
.row-form select, .row-form input { width: auto; margin-top: 0; }

.btn {
    display: inline-block;
    border: none;
    border-radius: 6px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    color: white;
    background: var(--secondary);
}
.btn-primary { background: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: var(--danger); }
.btn-xs { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

.cta-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

.flash {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 14px;
}
.flash-ok { background: var(--ok-bg); color: var(--ok-text); }
.flash-err { background: var(--err-bg); color: var(--err-text); }

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}
.badge-draft { background: #fef3c7; color: #92400e; }
.badge-locked { background: #dcfce7; color: #166534; }
.badge-award { background: #dbeafe; color: #1e40af; }

.chip-ok { color: #166534; font-weight: 700; margin-right: 8px; }

.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 14px;
}
.results-table th, .results-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: middle;
}
.results-table thead th {
    background: #f8fafc;
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--muted);
}
.results-table tfoot td { border-top: 2px solid var(--border); border-bottom: none; }
.text-right { text-align: right; }

.w-60 { width: 60px !important; }
.w-100 { width: 100px !important; }
.w-160 { width: 160px !important; }

.inline-form { display: inline-block; margin: 0; }

.calc-preview {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 10px 14px;
    margin: 10px 0;
    display: flex;
    gap: 24px;
    font-size: 14px;
    font-weight: 600;
}

.file-list { list-style: none; padding: 0; }
.file-list li {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.upload-form { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.upload-form input[type=file] { flex: 1; min-width: 200px; }

.detail-list { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; margin: 14px 0; }
.detail-list dt { color: var(--muted); font-weight: 600; }
.detail-list dd { margin: 0; }

.stats-row { display: flex; gap: 30px; margin-top: 16px; flex-wrap: wrap; }
.stat { text-align: center; }
.stat-num { display: block; font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--muted); }

.muted { color: var(--muted); }

.footer {
    text-align: center;
    padding: 24px 20px;
    color: var(--muted);
    font-size: 13px;
}
.footer a { color: var(--muted); }
