@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@300;400;600;700&display=swap');

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

body {
    font-family: 'Titillium Web', Helvetica, Arial, sans-serif;
    background: #eef2f7;
    color: #1d2d44;
    font-size: 16px;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---- Header ---- */
.site-header {
    background: #1a3a5c;
    padding: 14px 30px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,.25);
}
.site-header img { height: 46px; }
.site-header .site-title { color: #cde0f5; font-size: 1.15rem; font-weight: 300; letter-spacing: .5px; }
.site-header .header-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
    color: #a8c4e0;
    font-size: .9rem;
}
.site-header .header-right a { color: #a8c4e0; text-decoration: none; }
.site-header .header-right a:hover { color: #fff; }

/* ---- Container / Cards ---- */
.container { max-width: 860px; margin: 38px auto; padding: 0 20px; }
.container-wide { max-width: 1100px; margin: 30px auto; padding: 0 20px; }

.card {
    background: #fff;
    border-radius: 10px;
    padding: 32px;
    box-shadow: 0 2px 10px rgba(0,0,0,.08);
    margin-bottom: 24px;
}
.card h2 {
    color: #1a3a5c;
    font-size: 1.25rem;
    font-weight: 700;
    border-bottom: 2px solid #478ac9;
    padding-bottom: 10px;
    margin-bottom: 22px;
}
.card h3 { color: #1a3a5c; margin-bottom: 10px; font-size: 1.05rem; }

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    padding: 9px 22px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: .9rem;
    font-weight: 700;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: .8px;
    transition: filter .15s, opacity .15s;
    line-height: 1.4;
    white-space: nowrap;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { filter: brightness(.95); }
.btn-primary   { background: #478ac9; color: #fff; }
.btn-success   { background: #27ae60; color: #fff; }
.btn-danger    { background: #c0392b; color: #fff; }
.btn-warning   { background: #e67e22; color: #fff; }
.btn-secondary { background: #7f8c8d; color: #fff; }
.btn-outline   { background: transparent; color: #478ac9; border: 2px solid #478ac9; }
.btn-sm  { padding: 5px 14px; font-size: .8rem; }
.btn-xs  { padding: 3px 10px; font-size: .75rem; }

/* ---- Forms ---- */
.form-group { margin-bottom: 18px; }
.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: .9rem;
    color: #1a3a5c;
}
.form-group input[type=text],
.form-group input[type=password],
.form-group input[type=email],
.form-group input[type=number],
.form-group input[type=file],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid #c5d3e0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 1rem;
    color: #1d2d44;
    background: #fafcfe;
    transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #478ac9;
    box-shadow: 0 0 0 3px rgba(71,138,201,.18);
    background: #fff;
}
.form-group textarea { resize: vertical; min-height: 90px; }
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }
.form-group input[type=file] { padding: 7px 10px; cursor: pointer; }
.form-hint { font-size: .8rem; color: #7f8c8d; margin-top: 4px; }

/* ---- Search box ---- */
.search-wrap { position: relative; margin-bottom: 16px; }
.search-wrap input {
    width: 100%;
    padding: 9px 13px 9px 38px;
    border: 1px solid #c5d3e0;
    border-radius: 6px;
    font-family: inherit;
    font-size: .95rem;
    background: #fafcfe;
    transition: border-color .2s;
}
.search-wrap input:focus { outline: none; border-color: #478ac9; }
.search-wrap::before {
    content: '🔍';
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: .9rem;
    pointer-events: none;
}

/* ---- Alerts ---- */
.alert {
    padding: 12px 18px;
    border-radius: 7px;
    margin-bottom: 18px;
    font-weight: 600;
    font-size: .95rem;
}
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th {
    background: #1a3a5c;
    color: #fff;
    padding: 11px 14px;
    text-align: left;
    font-weight: 600;
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}
td { padding: 11px 14px; border-bottom: 1px solid #e8eef5; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f4f8fc; }
tr.hidden-row { display: none; }
.td-actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; }

/* ---- Progress bar ---- */
.pbar-wrap { background: #e8eef5; border-radius: 5px; height: 18px; overflow: hidden; min-width: 120px; }
.pbar-fill  { height: 100%; border-radius: 5px; transition: width .4s ease; }

/* ---- Participation bar ---- */
.part-bar-wrap { background: #e8eef5; border-radius: 8px; height: 10px; overflow: hidden; flex: 1; }
.part-bar-fill  { height: 100%; background: #478ac9; border-radius: 8px; transition: width .4s ease; }

/* ---- Chart ---- */
.chart-container { position: relative; max-height: 220px; max-width: 220px; margin: 0 auto; }
.chart-wrap { display: flex; align-items: center; gap: 30px; flex-wrap: wrap; }
.chart-wrap .chart-container { flex-shrink: 0; }
.chart-wrap .chart-table { flex: 1; min-width: 260px; }

/* ---- Quorum badge ---- */
.quorum-ok  { display:inline-flex;align-items:center;gap:6px;background:#d4edda;color:#155724;border:1px solid #c3e6cb;padding:6px 14px;border-radius:20px;font-weight:700;font-size:.88rem; }
.quorum-fail{ display:inline-flex;align-items:center;gap:6px;background:#f8d7da;color:#721c24;border:1px solid #f5c6cb;padding:6px 14px;border-radius:20px;font-weight:700;font-size:.88rem; }
.quorum-none{ display:inline-flex;align-items:center;gap:6px;background:#f0f0f0;color:#666;padding:6px 14px;border-radius:20px;font-size:.88rem; }

/* ---- Ballot option (voting) ---- */
.option-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 2px solid #d8e4f0;
    border-radius: 7px;
    cursor: pointer;
    margin-bottom: 8px;
    transition: border-color .15s, background .15s;
    font-size: 1rem;
}
.option-label:hover { border-color: #478ac9; background: #f0f6ff; }
.option-label input[type=radio]    { width: 18px; height: 18px; accent-color: #478ac9; flex-shrink: 0; }
.option-label input[type=checkbox] { width: 18px; height: 18px; accent-color: #478ac9; flex-shrink: 0; }
.option-label.checked { border-color: #478ac9; background: #eaf2fc; }

/* ---- Answer image (single / multi / list) ---- */
.answer-img { width: 44px; height: 44px; object-fit: contain; border-radius: 5px; flex-shrink: 0; }

/* ---- Multi-preference counter ---- */
.vote-instruction { font-size: .9rem; color: #5a6a7e; margin-bottom: 10px; }
.multi-counter {
    display: inline-block; font-size: .85rem; font-weight: 700;
    background: #f4f8fc; border: 1px solid #d8e4f0; border-radius: 6px;
    padding: 5px 14px; margin-bottom: 10px; color: #1a3a5c;
}
.multi-counter.full { color: #c0392b; border-color: #f5c6cb; background: #fff0f0; }

/* ---- List voting grid ---- */
.list-vote-grid { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 16px; }
.list-card {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border: 2px solid #d8e4f0; border-radius: 10px; padding: 18px 22px;
    cursor: pointer; transition: border-color .15s, background .15s, box-shadow .15s;
    min-width: 130px; max-width: 200px; text-align: center;
    user-select: none;
}
.list-card:hover { border-color: #478ac9; background: #f0f6ff; }
.list-card.selected { border-color: #1a3a5c; background: #eaf2fc; box-shadow: 0 0 0 3px rgba(71,138,201,.25); }
.list-card input[type=radio] { display: none; }
.list-card-img { width: 90px; height: 90px; object-fit: contain; margin-bottom: 10px; }
.list-card-label { font-weight: 700; font-size: .95rem; color: #1a3a5c; }

/* ---- Ballot type badge (scrutiny / admin) ---- */
.badge-type-single { background:#e8f0fe; color:#1a3a5c; }
.badge-type-multi  { background:#fff3cd; color:#856404; }
.badge-type-list   { background:#d4edda; color:#155724; }

/* ---- Ballot card (vote page) ---- */
.ballot-card { border: 2px solid #dce8f5; border-radius: 10px; padding: 24px; margin-bottom: 20px; background: #fafdff; }
.ballot-card.voted  { border-color: #27ae60; background: #f0faf4; }
.ballot-card.closed { opacity: .7; }
.ballot-card .ballot-meta { font-size: .85rem; color: #7f8c8d; margin-bottom: 16px; }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 3px 11px;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .3px;
    vertical-align: middle;
}
.badge-open    { background: #d4edda; color: #155724; }
.badge-closed  { background: #f8d7da; color: #721c24; }
.badge-voted   { background: #d1ecf1; color: #0c5460; }
.badge-private { background: #fff3cd; color: #856404; }
.badge-group   { background: #e8f0fe; color: #1a3a5c; }

/* ---- Group color dot ---- */
.group-dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    flex-shrink: 0;
}

/* ---- Login box ---- */
.login-box {
    max-width: 420px;
    margin: 70px auto 40px;
    background: #fff;
    border-radius: 12px;
    padding: 40px 36px;
    box-shadow: 0 4px 20px rgba(0,0,0,.1);
    text-align: center;
}
.login-box img { height: 60px; margin-bottom: 18px; }
.login-box h1 { font-size: 1.3rem; color: #1a3a5c; margin-bottom: 8px; }
.login-box p  { color: #5a6a7e; font-size: .92rem; margin-bottom: 28px; }
.login-box .form-group { text-align: left; }

/* ---- SVG icon helpers ---- */
.icon { display: inline-flex; align-items: center; gap: 4px; }
.icon svg { vertical-align: middle; flex-shrink: 0; }

/* ---- Admin layout ---- */
.admin-wrap { display: flex; flex: 1; min-height: 0; }
.admin-sidebar {
    width: 215px;
    background: #1a3a5c;
    flex-shrink: 0;
    padding-top: 10px;
}
.admin-sidebar .nav-section {
    padding: 10px 18px 4px;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #5a7a9c;
    font-weight: 700;
}
.admin-sidebar a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: #a8c4e0;
    text-decoration: none;
    font-weight: 600;
    font-size: .92rem;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}
.admin-sidebar a:hover  { background: rgba(71,138,201,.2); color: #fff; }
.admin-sidebar a.active { background: rgba(71,138,201,.3); color: #fff; border-left-color: #478ac9; }
.admin-sidebar a .icon  { font-size: 1.1rem; opacity: .8; }

.admin-main { flex: 1; padding: 30px 36px; overflow-x: auto; }
.admin-main h1 { font-size: 1.45rem; color: #1a3a5c; margin-bottom: 6px; }
.admin-main .page-sub { color: #5a6a7e; font-size: .93rem; margin-bottom: 24px; }

/* ---- Stat cards ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px 22px;
    box-shadow: 0 2px 8px rgba(0,0,0,.07);
    border-left: 4px solid #478ac9;
}
.stat-card.green  { border-left-color: #27ae60; }
.stat-card.orange { border-left-color: #e67e22; }
.stat-card.red    { border-left-color: #c0392b; }
.stat-card.purple { border-left-color: #8e44ad; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: #1a3a5c; line-height: 1; }
.stat-card .stat-label { font-size: .82rem; color: #7f8c8d; margin-top: 5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

/* ---- Scrutiny result card ---- */
.scrutiny-card { background:#fff; border-radius:10px; padding:28px; box-shadow:0 2px 10px rgba(0,0,0,.08); margin-bottom:24px; }
.scrutiny-card h2 { font-size:1.15rem;color:#1a3a5c;margin-bottom:4px; }
.scrutiny-meta { display:flex;gap:20px;flex-wrap:wrap;padding:12px 0;border-top:1px solid #e8eef5;border-bottom:1px solid #e8eef5;margin:12px 0; }
.scrutiny-stat { text-align:center; }
.scrutiny-stat .sv { font-size:1.5rem;font-weight:700;color:#1a3a5c; }
.scrutiny-stat .sl { font-size:.75rem;color:#7f8c8d;text-transform:uppercase;font-weight:700; }

/* ---- Audit log ---- */
.audit-log { background:#1a3a5c;color:#a8c4e0;border-radius:8px;padding:16px;font-size:.8rem;font-family:monospace;max-height:320px;overflow-y:auto;line-height:1.7; }
.audit-log .al-action { color:#7de8a8; }
.audit-log .al-detail  { color:#cde0f5; }

/* ---- Commission strip (vote page) ---- */
.commission-strip {
    background: linear-gradient(90deg, #1a3a5c 0%, #2c5282 100%);
    color: #cde0f5;
    border-radius: 6px 6px 0 0;
    padding: 9px 16px;
    font-size: .83rem;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: -20px -20px 12px -20px;
}
.commission-strip-label {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    font-size: .72rem;
    opacity: .7;
    white-space: nowrap;
}
.commission-member {
    display: flex;
    align-items: center;
    gap: 6px;
}
.commission-role {
    font-size: .78rem;
    opacity: .75;
    font-style: italic;
    margin-left: 2px;
}
.commission-role::before { content: "("; }
.commission-role::after  { content: ")"; }

/* ---- Observation feature ---- */
.obs-row {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e8eef5;
}
.btn-obs {
    background: none;
    border: none;
    color: #7f8c8d;
    font-size: .8rem;
    cursor: pointer;
    padding: 4px 0;
    font-family: inherit;
    text-decoration: underline;
    text-decoration-style: dotted;
}
.btn-obs:hover { color: #478ac9; }
.obs-form {
    margin-top: 12px;
    padding: 16px;
    background: #f8fbff;
    border-radius: 8px;
    border: 1px solid #c5d3e0;
}
.obs-form textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #c5d3e0;
    border-radius: 6px;
    font-family: inherit;
    font-size: .9rem;
    resize: vertical;
    color: #1d2d44;
    background: #fff;
}
.obs-form textarea:focus { outline: none; border-color: #478ac9; box-shadow: 0 0 0 3px rgba(71,138,201,.1); }

/* ---- Stat cards color variants ---- */
.stat-card.red   { background: #fdf2f2; border-left-color: #c0392b; }
.stat-card.red .stat-value { color: #c0392b; }

/* ---- Verbal print overrides ---- */
@media print {
    .verbal-page { border: none !important; box-shadow: none !important; }
}

/* ---- Divider ---- */
.divider { border: none; border-top: 2px solid #e8eef5; margin: 24px 0; }

/* ---- Footer ---- */
.site-footer { text-align:center;padding:16px;font-size:.82rem;color:#a8c4e0;background:#1a3a5c;margin-top:0; }

/* ---- Responsive ---- */
@media (max-width: 700px) {
    .admin-wrap { flex-direction: column; }
    .admin-sidebar { width: 100%; padding-top: 0; display: flex; flex-wrap: wrap; }
    .admin-sidebar a { padding: 10px 14px; }
    .admin-main { padding: 20px 16px; }
    .wz-wrap { margin: -20px -16px 24px -16px; }
    .wz-header { padding: 8px 16px; }
    .wz-sub { display: none; }
    .form-row { flex-direction: column; gap: 0; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .toggle-grid { grid-template-columns: 1fr !important; }
    .container { padding: 0 12px; }
    .card { padding: 20px; }
    .login-box { margin: 30px auto; padding: 28px 20px; }
    .chart-wrap { flex-direction: column; }
}

/* ---- Print styles ---- */
@media print {
    body { background: #fff; font-size: 12pt; }
    .site-header, .admin-sidebar, .btn, .no-print,
    .site-footer, .admin-main h1 + .page-sub { display: none !important; }
    .admin-wrap { display: block; }
    .admin-main { padding: 0; }
    .scrutiny-card, .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
    .pbar-wrap { border: 1px solid #ccc; }
    .pbar-fill { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
    .chart-container { max-height: 160px; max-width: 160px; }
    a { text-decoration: none; color: inherit; }
    .print-header { display: block !important; }
}
.print-header { display: none; }
