* { box-sizing: border-box; }

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, Helvetica, sans-serif;
    background: #eef2f7;
    color: #1f2937;
    line-height: 1.45;
}

.shell {
    max-width: 1560px;
    margin: 0 auto;
    padding: 24px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 24px;
}

.topbar h1 {
    margin: 0 0 6px;
    font-size: 28px;
}

.topbar p {
    margin: 0;
    color: #6b7280;
}

.topnav {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}

.topnav a {
    text-decoration: none;
    color: #1d4ed8;
    font-weight: 700;
}

.card {
    background: #ffffff;
    border-radius: 16px;
    padding: 22px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.06);
    margin-bottom: 20px;
}

.narrow {
    max-width: 460px;
    margin: 64px auto;
}

.grid.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.stat h3 {
    margin: 0 0 8px;
    color: #6b7280;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 34px;
    font-weight: 700;
}

.stack {
    display: grid;
    gap: 14px;
}

.stack-lg {
    display: grid;
    gap: 20px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 18px;
}

.page-header h2 {
    margin: 0 0 6px;
    font-size: 30px;
}

.page-header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.sep {
    margin: 0 8px;
    color: #9ca3af;
}

label {
    display: grid;
    gap: 6px;
    font-weight: 700;
    font-size: 14px;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    color: #111827;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.readonly-input {
    background: #f8fafc;
    color: #334155;
    font-weight: 700;
}

button {
    background: #2563eb;
    color: #fff;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    padding: 11px 16px;
    font-weight: 700;
}

button:hover {
    background: #1d4ed8;
}

.button-link {
    display: inline-block;
    padding: 11px 14px;
    border-radius: 10px;
    text-decoration: none;
    background: #e5e7eb;
    color: #111827;
    font-weight: 700;
}

.button-link:hover {
    background: #dbe0e7;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 11px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    vertical-align: top;
}

th {
    background: #f8fafc;
    width: 32%;
}

.flash {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-weight: 700;
}

.flash-success {
    background: #dcfce7;
    color: #166534;
}

.flash-error {
    background: #fee2e2;
    color: #991b1b;
}

small,
.help-text,
.muted {
    color: #6b7280;
}

.form-grid,
.filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-grid .span-2 {
    grid-column: span 2;
}

.action-row,
.filter-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.warning-box {
    padding: 14px 16px;
    background: #fff7ed;
    color: #9a3412;
    border: 1px solid #fed7aa;
    border-radius: 12px;
}

.info-box {
    margin-top: 14px;
    padding: 14px 16px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
    border-radius: 12px;
}

.section-heading {
    margin-bottom: 14px;
}

.section-heading h3 {
    margin: 0 0 4px;
}

.piece-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.piece-card {
    background: #f8fafc;
    border: 1px solid #dbe4ee;
    border-radius: 14px;
    padding: 14px;
    gap: 8px;
}

.piece-label {
    font-size: 16px;
    font-weight: 700;
}

.piece-meta {
    font-size: 12px;
    color: #64748b;
}

.score-piece-block {
    border: 1px solid #dbe4ee;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 16px;
    background: #f8fafc;
}

.score-piece-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.score-piece-header h4 {
    margin: 0;
    font-size: 20px;
}

.piece-total-badge {
    font-size: 14px;
    color: #475569;
    background: #e2e8f0;
    padding: 8px 12px;
    border-radius: 999px;
}

.score-grid {
    display: grid;
    gap: 12px;
}

.score-row {
    display: grid;
    grid-template-columns: 1fr 220px;
    gap: 16px;
    align-items: center;
}

.score-row label {
    margin: 0;
}

.score-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.score-input {
    width: 110px;
    text-align: right;
}

.score-max {
    color: #64748b;
    font-weight: 700;
    min-width: 48px;
}

.section-head-inline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-muted {
    background: #e5e7eb;
    color: #374151;
}

.text-success {
    color: #166534;
}

.listen-cell {
    min-width: 340px;
}

.audio-player {
    display: block;
    width: 240px;
    min-width: 240px;
    max-width: 240px;
    height: 38px;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
}

.checkbox-block {
    display: grid;
    gap: 8px;
}

.checkbox-inline-compact {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}

.checkbox-inline-compact input[type="checkbox"] {
    transform: scale(1.05);
    width: auto;
    min-height: 0;
    padding: 0;
}

.button-small {
    padding: 10px 14px;
    min-width: 66px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.table-action {
    display: inline-block;
    margin-bottom: 6px;
    color: #1d4ed8;
    text-decoration: none;
    font-weight: 600;
}

.table-action:hover {
    text-decoration: underline;
}

.venues-admin-table {
    width: 100%;
    min-width: 1120px;
    border-collapse: collapse;
}

.venues-admin-table th,
.venues-admin-table td {
    vertical-align: middle;
    padding: 12px 10px;
}

.venues-admin-table th {
    white-space: nowrap;
    width: auto;
}

.venues-admin-table input,
.venues-admin-table select {
    width: 100%;
    padding: 10px 12px;
    min-height: 42px;
}

.venues-admin-table button {
    white-space: nowrap;
}

.venues-admin-table .col-venue-id {
    width: 90px;
    white-space: nowrap;
}

.venues-admin-table .col-venue-name {
    min-width: 220px;
}

.venues-admin-table .col-venue-code {
    min-width: 190px;
}

.venues-admin-table .col-division {
    width: 120px;
}

.venues-admin-table .col-scheme {
    width: 90px;
}

.venues-admin-table .col-active {
    width: 120px;
    white-space: nowrap;
}

.venues-admin-table .col-finalised {
    min-width: 120px;
}

.venues-admin-table .col-save {
    width: 90px;
    text-align: right;
}

.recordings-table {
    width: 100%;
    min-width: 1100px;
    table-layout: fixed;
}

.recordings-table th,
.recordings-table td {
    vertical-align: top;
}

.recordings-table .col-created {
    width: 150px;
    white-space: nowrap;
}

.recordings-table .col-venue {
    width: 130px;
}

.recordings-table .col-order {
    width: 60px;
    white-space: nowrap;
}

.recordings-table .col-school {
    width: 150px;
}

.recordings-table .col-filename {
    width: 360px;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.recordings-table .col-length {
    width: 70px;
    white-space: nowrap;
}

.recordings-table .col-listen {
    width: 280px;
}

.recordings-table .col-links {
    width: 90px;
    white-space: nowrap;
}

.recordings-table small,
.recordings-table-clean small,
.venues-admin-table small {
    display: inline-block;
    margin-top: 4px;
    line-height: 1.45;
    color: #6b7280;
}

.recordings-table-clean {
    width: 100%;
    min-width: 1120px;
    table-layout: fixed;
}

.recordings-table-clean th,
.recordings-table-clean td {
    vertical-align: top;
    padding: 14px 10px;
}

.recordings-table-clean th {
    width: auto;
}

.recordings-table-clean .col-created {
    width: 140px;
    white-space: nowrap;
}

.recordings-table-clean .col-venue {
    width: 140px;
}

.recordings-table-clean .col-order {
    width: 55px;
    white-space: nowrap;
}

.recordings-table-clean .col-school {
    width: 140px;
}

.recordings-table-clean .col-filename {
    width: 260px;
    word-break: break-word;
    overflow-wrap: anywhere;
    line-height: 1.45;
}

.recordings-table-clean .col-length {
    width: 70px;
    white-space: nowrap;
}

.recordings-table-clean .col-listen {
    width: 250px;
}

.recordings-table-clean .col-links {
    width: 90px;
    white-space: nowrap;
}

@media (max-width: 1200px) {
    .recordings-table {
        min-width: 1050px;
    }

    .venues-admin-table,
    .recordings-table-clean {
        min-width: 1100px;
    }
}

@media (max-width: 800px) {
    .shell {
        padding: 16px;
    }

    .topbar,
    .page-header {
        flex-direction: column;
        align-items: stretch;
    }

    .form-grid,
    .filter-grid,
    .score-row {
        grid-template-columns: 1fr;
    }

    .form-grid .span-2 {
        grid-column: span 1;
    }

    .score-input-wrap {
        justify-content: flex-start;
    }
}

/* =========================================================
   Venue results / rankings view
   ========================================================= */

.page-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.page-toolbar-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.page-title {
    margin: 0 0 6px;
}

.page-subtitle {
    color: #6b7280;
    font-size: 14px;
}

.admin-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    margin-bottom: 14px;
}

.card-header h2 {
    margin: 0 0 6px;
}

.muted {
    color: #6b7280;
}

.venue-results-hero {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 20px;
    flex-wrap: wrap;
}

.venue-results-hero-left {
    flex: 1 1 540px;
}

.venue-results-hero-right {
    flex: 0 0 180px;
}

.status-line {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 999px;
    display: inline-block;
}

.status-dot-green {
    background: #22c55e;
}

.status-dot-amber {
    background: #f59e0b;
}

.venue-results-meta {
    display: flex;
    gap: 18px;
    flex-wrap: wrap;
    color: #374151;
    font-size: 14px;
}

.stat-card {
    border: 1px solid #dbe2ea;
    border-radius: 14px;
    padding: 14px 16px;
    min-height: 100%;
    text-align: right;
    background: #fafafa;
}

.stat-card-label {
    color: #6b7280;
    font-size: 13px;
    margin-bottom: 4px;
}

.stat-card-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
}

.final-lock-card h2 {
    margin: 0 0 10px;
}

.final-lock-card p {
    margin: 0 0 12px;
    color: #b45309;
    font-size: 18px;
    line-height: 1.4;
}

.final-lock-meta {
    color: #6b7280;
    font-size: 14px;
}

.table-wrap {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.admin-table thead th {
    text-align: left;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    padding: 10px 12px;
    border-bottom: 1px solid #e5e7eb;
    white-space: nowrap;
}

.admin-table tbody td {
    padding: 14px 12px;
    border-bottom: 1px solid #eef2f7;
    vertical-align: middle;
}

.admin-table tbody tr:last-child td {
    border-bottom: 0;
}

.venue-results-table .school-name {
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

.venue-results-table .school-meta {
    margin-top: 4px;
    color: #6b7280;
    font-size: 13px;
}

.rank-cell {
    font-size: 18px;
    font-weight: 700;
    color: #0f172a;
}

.final-score-cell {
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 86px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid transparent;
}

.pill-success {
    background: #e8f7ef;
    color: #0f766e;
    border-color: #b7e4d0;
}

.pill-muted {
    background: #f3f4f6;
    color: #6b7280;
    border-color: #e5e7eb;
}

.empty-state {
    padding: 18px 0 4px;
    color: #6b7280;
}

@media (max-width: 900px) {
    .venue-results-hero-right {
        flex: 1 1 100%;
    }

    .stat-card {
        text-align: left;
    }
}
/* =========================================================
   Venue management / results / recordings polish
   ========================================================= */

.section-header-inline {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.section-header-inline h2,
.section-header-inline h3 {
    margin: 0 0 6px;
}

.admin-data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 980px;
}

.admin-data-table th,
.admin-data-table td {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 12px 12px;
    text-align: left;
    vertical-align: middle;
}

.admin-data-table th {
    background: #f8fafc;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.admin-data-table tbody tr:last-child td {
    border-bottom: 0;
}

.table-title {
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

.table-subtext {
    margin-top: 3px;
    color: #6b7280;
    font-size: 13px;
    line-height: 1.35;
}

.empty-table {
    color: #6b7280;
    text-align: center;
    padding: 22px 12px;
}

.nowrap {
    white-space: nowrap;
}

.score-cell {
    font-weight: 700;
    color: #0f172a;
    white-space: nowrap;
}

.rank-cell {
    font-size: 28px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1;
}

.table-action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.table-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 8px 12px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    text-decoration: none;
    font-weight: 700;
    font-size: 13px;
    white-space: nowrap;
}

.table-action:hover {
    background: #dbeafe;
}

.button-small {
    padding: 9px 13px;
    min-height: 36px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
}

.badge-muted {
    background: #e5e7eb;
    color: #4b5563;
}

.mini-label {
    display: grid;
    gap: 6px;
    font-size: 12px;
    color: #6b7280;
    font-weight: 700;
}

.venues-admin-table {
    min-width: 1180px;
}

.venue-edit-cell {
    padding: 0 !important;
}

.venue-row-form {
    margin: 0;
}

.venue-row-grid {
    display: grid;
    grid-template-columns: 90px minmax(220px, 1.8fr) 140px 150px 110px 120px 180px 240px;
    gap: 12px;
    padding: 12px;
    align-items: center;
}

.venue-row-id,
.venue-row-active,
.venue-row-finalised,
.venue-row-actions {
    align-self: center;
}

.venue-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-start;
}

.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
}

.checkbox-inline input {
    width: 18px;
    height: 18px;
    margin: 0;
}

.checkbox-inline-compact {
    min-height: 38px;
}

.recordings-table-clean {
    min-width: 1220px;
}

.filename-cell {
    word-break: break-word;
    max-width: 280px;
}

.audio-player {
    width: 220px;
    max-width: 100%;
}

.venue-results-hero-card {
    padding: 18px 22px;
}

.venue-results-hero-grid {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    gap: 20px;
    flex-wrap: wrap;
}

.venue-results-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
    margin-top: 10px;
}

.venue-results-hero-stat {
    min-width: 170px;
    padding: 14px 16px;
    border: 1px solid #dbe2ea;
    border-radius: 14px;
    background: #f8fafc;
    text-align: right;
}

.hero-stat-label {
    color: #6b7280;
    font-size: 13px;
    margin-bottom: 4px;
}

.hero-stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
}

.status-line {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.status-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 999px;
}

.status-dot-green {
    background: #22c55e;
}

.status-dot-amber {
    background: #f59e0b;
}

.finalised-summary-card h3 {
    margin: 0 0 8px;
}

.finalised-summary-card p {
    margin: 0 0 10px;
    color: #9a3412;
    font-size: 18px;
}

.venue-results-table {
    min-width: 1100px;
}

.w-venue-id { width: 90px; }
.w-code { width: 140px; }
.w-division { width: 150px; }
.w-scheme { width: 110px; }
.w-active { width: 120px; }
.w-finalised { width: 180px; }
.w-actions-lg { width: 240px; }
.w-created { width: 160px; }
.w-venue { width: 160px; }
.w-order { width: 90px; }
.w-school-code { width: 140px; }
.w-filename { width: 280px; }
.w-length { width: 90px; }
.w-listen { width: 240px; }
.w-links { width: 220px; }
.w-score { width: 130px; }
.w-status { width: 120px; }
.w-updated { width: 180px; }
.w-actions { width: 110px; }
.w-rank { width: 90px; }
.w-piece { width: 120px; }

@media (max-width: 900px) {
    .form-grid,
    .filter-grid {
        grid-template-columns: 1fr;
    }

    .venue-results-hero-stat {
        text-align: left;
        width: 100%;
    }
}

/* =========================================================
   Wider admin layout + venue action polish
   ========================================================= */

.shell {
    max-width: 1560px;
}

.venues-admin-table {
    min-width: 1320px;
}

.venue-row-grid {
    grid-template-columns: 90px minmax(260px, 2fr) 150px 150px 110px 120px 180px 260px;
}

.venue-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.venue-row-actions .button-link,
.venue-row-actions .table-action,
.venue-row-actions button {
    margin: 0;
}

.table-wrap {
    overflow-x: auto;
}

/* =========================================================
   Safe table alignment patch
   ========================================================= */

.shell {
    max-width: 1560px;
}

.venues-admin-table {
    min-width: 1340px;
}

.venue-row-grid {
    grid-template-columns: 80px minmax(260px, 2.2fr) 140px 130px 100px 110px 150px 240px;
    gap: 10px;
    padding: 10px 12px;
    align-items: center;
}

.venue-row-name input,
.venue-row-code input,
.venue-row-division input,
.venue-row-scheme select {
    min-width: 0;
}

.venue-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.venue-row-finalised .table-subtext {
    margin-top: 6px;
    font-size: 12px;
}

.recordings-table-clean {
    min-width: 1280px;
}

.recordings-table-clean .w-created {
    width: 160px;
}

.recordings-table-clean .w-venue {
    width: 160px;
}

.recordings-table-clean .w-order {
    width: 70px;
}

.recordings-table-clean .w-filename {
    width: 300px;
}

.recordings-table-clean .w-length {
    width: 80px;
}

.recordings-table-clean .w-listen {
    width: 250px;
}

.recordings-table-clean .w-links {
    width: 210px;
}

.filename-cell {
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.audio-player {
    width: 210px;
    max-width: 100%;
}

.table-action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
}

.table-action {
    margin: 0;
}