/* ── Reset & Base ── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
    font-size: 15px;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
body.page-scoring .container { max-width: 100%; padding: 0 24px; }
.header {
    background: #1e293b;
    color: #fff;
    padding: 12px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}
.header h1 { font-size: 18px; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.header-right a { color: #94a3b8; }
.header-right a:hover { color: #fff; }

.main { padding: 24px 0; min-height: calc(100vh - 56px); }

/* ── Cards ── */
.card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    padding: 20px;
    margin-bottom: 16px;
}
.card h2 {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e2e8f0;
}
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 12px; }

/* ── Buttons ── */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    transition: background 0.2s;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; text-decoration: none; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: #64748b; color: #fff; }
.btn-secondary:hover { background: #475569; }
.btn-outline {
    background: transparent;
    border: 1px solid #d1d5db;
    color: #374151;
}
.btn-outline:hover { background: #f3f4f6; }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-block { display: block; width: 100%; }

/* ── Forms ── */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 14px;
    color: #475569;
}
.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
}
.form-control:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
textarea.form-control { resize: vertical; min-height: 60px; }
select.form-control { cursor: pointer; }

.form-inline { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; }
.form-inline .form-group { margin-bottom: 0; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
th, td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}
th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
    position: sticky;
    top: 0;
}
tr:hover { background: #f8fafc; }
td.num { text-align: center; }

/* ── Flash Messages ── */
.flash {
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
}
.flash-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ── Login Page ── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    padding: 20px;
}
.login-box {
    background: #fff;
    border-radius: 12px;
    padding: 40px 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-box h1 {
    text-align: center;
    font-size: 22px;
    margin-bottom: 8px;
    color: #1e293b;
}
.login-box .subtitle {
    text-align: center;
    color: #64748b;
    font-size: 14px;
    margin-bottom: 28px;
}

/* ── Score Input ── */
.score-input {
    width: 100%;
    min-width: 50px;
    padding: 10px 6px;
    text-align: center;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 16px;
    box-sizing: border-box;
}
.score-input:focus { border-color: #2563eb; outline: none; box-shadow: 0 0 0 2px rgba(37,99,235,0.2); }
.score-input.invalid { border-color: #dc2626; background: #fef2f2; }
.score-total { font-weight: 700; color: #2563eb; font-size: 18px; }
.score-rank { font-weight: 700; color: #16a34a; font-size: 18px; }

/* ── Status Badge ── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.badge-draft { background: #f1f5f9; color: #64748b; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-closed { background: #fee2e2; color: #991b1b; }
.badge-submitted { background: #dbeafe; color: #1e40af; }
.badge-pending { background: #fef3c7; color: #92400e; }

/* ── Grid ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Misc ── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: #94a3b8; }
.text-sm { font-size: 13px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.gap-8 { gap: 8px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-wrap { flex-wrap: wrap; }

.empty-state {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
}

/* ── Criteria Builder ── */
.criteria-group {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    background: #fafbfc;
}
.criteria-item {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 6px;
    padding-left: 16px;
}

/* ── Scoring Table (Judge/Audience) ── */
.scoring-container { overflow-x: auto; }
.scoring-table { width: 100%; table-layout: auto; border-collapse: collapse; }
.scoring-table th { font-size: 13px; text-align: center; padding: 10px 8px; }
.scoring-table td { text-align: center; vertical-align: middle; padding: 8px 6px; }
.scoring-table tbody tr { height: 52px; }
.scoring-table tbody tr:hover { background: #f8fafc; }
.scoring-table .num { font-size: 16px; font-weight: 600; }
.scoring-table .team-name { text-align: left; font-weight: 600; min-width: 130px; font-size: 15px; white-space: nowrap; }
.scoring-table .group-header {
    background: #e2e8f0;
    font-weight: 600;
    text-align: center;
    font-size: 14px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .header h1 { font-size: 15px; }
    .card { padding: 14px; }
    .form-inline { flex-direction: column; align-items: stretch; }
    .score-input { min-width: 44px; font-size: 15px; padding: 8px 4px; }
    .scoring-table th { font-size: 11px; padding: 6px 3px; }
    .scoring-table td { padding: 5px 3px; }
    .hide-mobile { display: none; }
    table { font-size: 13px; }
    th, td { padding: 6px 8px; }
}

@media (max-width: 480px) {
    .login-box { padding: 28px 20px; }
    .btn { padding: 8px 12px; }
}
