:root {
    --bg: #f6f7f9;
    --panel: #ffffff;
    --text: #1f2933;
    --muted: #65717f;
    --line: #d9dee5;
    --field: #fdfefe;
    --accent: #d40011;
    --accent-dark: #aa0010;
    --focus: #0f6c81;
    --success: #1f7a4d;
    --danger: #b42318;
    --shadow: 0 18px 45px rgba(27, 39, 51, 0.08);
}

* {
    box-sizing: border-box;
}

/* label/fieldset set an explicit display, which beats the browser default for
   [hidden]; without this, hidden fields such as the "Other team" input show. */
[hidden] {
    display: none !important;
}

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

.app-header {
    border-bottom: 1px solid var(--line);
    background: #ffffff;
}

.app-header > div,
.app-shell {
    width: min(1040px, calc(100vw - 32px));
    margin: 0 auto;
}

.app-header > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 28px 0 22px;
}

.logout-link {
    flex: 0 0 auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    padding: 9px 14px;
    font-weight: 800;
    text-decoration: none;
}

.logout-link:hover {
    border-color: #b9c1ca;
    color: var(--accent);
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

h1,
h2,
legend {
    margin: 0;
    letter-spacing: 0;
}

h1 {
    font-size: 2rem;
    line-height: 1.1;
}

h2,
legend {
    font-size: 1.15rem;
    font-weight: 700;
}

.app-shell {
    padding: 24px 0 56px;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.tab {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    padding: 0 18px;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.tab:hover {
    border-color: #b9c1ca;
}

.tab.is-active {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
}

.notice {
    margin-bottom: 16px;
    border-radius: 8px;
    padding: 12px 14px;
    font-weight: 700;
}

.notice-success {
    border: 1px solid rgba(31, 122, 77, 0.25);
    background: rgba(31, 122, 77, 0.1);
    color: var(--success);
}

.notice-error {
    border: 1px solid rgba(180, 35, 24, 0.25);
    background: rgba(180, 35, 24, 0.09);
    color: var(--danger);
}

.form-panel {
    display: none;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 24px;
}

.form-panel.is-active {
    display: block;
}

.panel-heading {
    margin-bottom: 18px;
}

form {
    display: grid;
    gap: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

label {
    display: grid;
    gap: 7px;
}

label > span,
legend {
    color: var(--text);
}

label > span {
    font-size: 0.92rem;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid #c8d0d9;
    border-radius: 8px;
    background: var(--field);
    color: var(--text);
    padding: 10px 12px;
    font: inherit;
}

textarea {
    min-height: 112px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
    border-color: var(--focus);
    outline: 3px solid rgba(15, 108, 129, 0.18);
    outline-offset: 1px;
}

fieldset {
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.choice-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 14px;
    margin-top: 12px;
}

.event-choice-grid {
    grid-auto-flow: column;
    grid-template-rows: repeat(var(--event-rows, 6), auto);
}

.choice {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 8px;
    align-items: center;
}

.choice input {
    min-height: 18px;
    width: 18px;
    margin: 0;
}

.inline-choice {
    display: inline-grid;
    justify-self: start;
}

.helper-link {
    justify-self: start;
    color: var(--focus);
    font-size: 0.88rem;
    font-weight: 700;
    text-decoration: none;
}

.helper-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.team-choice-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.other-team-field {
    margin-top: 14px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    padding-top: 4px;
}

.form-actions button {
    min-height: 44px;
    border: 1px solid var(--accent);
    border-radius: 8px;
    background: var(--accent);
    color: #ffffff;
    padding: 0 22px;
    font: inherit;
    font-weight: 800;
    cursor: pointer;
}

.form-actions button:hover {
    border-color: var(--accent-dark);
    background: var(--accent-dark);
}

.active-list {
    margin-top: 28px;
    border-top: 1px solid var(--line);
    padding-top: 20px;
}

.active-list-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.active-list-heading h3 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.3;
}

.active-list-heading span {
    display: inline-grid;
    min-width: 30px;
    min-height: 28px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.list-message {
    margin: 0;
    color: var(--muted);
    font-size: 0.94rem;
}

.list-search {
    margin-bottom: 12px;
}

.list-search input {
    min-height: 40px;
}

.import-drawer {
    margin-top: 28px;
}

.import-drawer summary {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    padding: 0 16px;
    font-weight: 800;
    cursor: pointer;
    list-style: none;
}

.import-drawer summary::-webkit-details-marker {
    display: none;
}

.import-drawer summary:hover {
    border-color: #b9c1ca;
    color: var(--accent);
}

.import-drawer[open] summary {
    border-color: var(--accent);
    background: var(--accent);
    color: #ffffff;
}

.import-drawer-body {
    margin-top: 16px;
}

.import-drawer-body .active-list:first-child {
    margin-top: 0;
    border-top: 0;
    padding-top: 0;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.summary-grid span {
    display: grid;
    gap: 2px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfd;
    padding: 10px 12px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
    text-transform: uppercase;
}

.summary-grid strong {
    color: var(--text);
    font-size: 1.2rem;
    line-height: 1.1;
}

.report-subheading {
    margin: 16px 0 8px;
    font-size: 0.92rem;
    line-height: 1.3;
}

.copilot-prompt {
    margin-top: 16px;
}

.copilot-prompt textarea {
    min-height: 220px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
    font-size: 0.86rem;
}

.example-import {
    margin-top: 16px;
}

.example-import-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.external-action {
    display: inline-grid;
    min-height: 36px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    padding: 0 12px;
    font-size: 0.88rem;
    font-weight: 800;
    text-decoration: none;
}

.external-action:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.example-table {
    min-width: 1500px;
}

.mapping-grid {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(150px, 0.7fr) auto;
    gap: 16px;
    align-items: end;
}

.mapping-actions {
    padding-top: 0;
}

.compact-table-wrap {
    margin-top: 12px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
}

.item-table {
    width: 100%;
    min-width: 720px;
    border-collapse: collapse;
}

.compact-table {
    min-width: 520px;
}

.item-table th,
.item-table td {
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    text-align: left;
    vertical-align: top;
}

.item-table th {
    background: #f1f4f7;
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.item-table td {
    overflow-wrap: anywhere;
    font-size: 0.92rem;
}

.item-table tbody tr:last-child td {
    border-bottom: 0;
}

.sort-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    background: transparent;
    color: inherit;
    padding: 0;
    font: inherit;
    text-align: left;
    text-transform: inherit;
    cursor: pointer;
}

.sort-button:hover {
    color: var(--accent);
}

.sort-indicator {
    position: relative;
    flex: 0 0 auto;
    width: 8px;
    height: 12px;
    opacity: 0.45;
}

.sort-indicator::before,
.sort-indicator::after {
    position: absolute;
    left: 0;
    content: "";
    border-right: 4px solid transparent;
    border-left: 4px solid transparent;
}

.sort-indicator::before {
    top: 0;
    border-bottom: 6px solid currentColor;
}

.sort-indicator::after {
    bottom: 0;
    border-top: 6px solid currentColor;
}

.sort-button.is-ascending .sort-indicator,
.sort-button.is-descending .sort-indicator {
    opacity: 1;
}

.sort-button.is-ascending .sort-indicator::after,
.sort-button.is-descending .sort-indicator::before {
    opacity: 0.2;
}

.actions-column,
.actions-cell {
    width: 82px;
    text-align: center;
}

.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.delete-form {
    display: inline-flex;
    justify-content: center;
}

.edit-button {
    display: inline-grid;
    width: 24px;
    height: 24px;
    min-height: 24px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #ffffff;
    color: var(--focus);
    font-size: 0.82rem;
    line-height: 1;
    text-decoration: none;
}

.edit-button:hover {
    border-color: var(--focus);
    background: var(--focus);
    color: #ffffff;
}

.edit-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 0;
    border: 1px solid var(--line);
    border-left: 4px solid var(--focus);
    border-radius: 8px;
    background: #f1f4f7;
    padding: 10px 12px;
    font-size: 0.9rem;
}

.edit-banner a {
    color: var(--focus);
    font-weight: 700;
}

.delete-button {
    display: inline-grid;
    width: 24px;
    height: 24px;
    min-height: 24px;
    place-items: center;
    border: 1px solid var(--danger);
    border-radius: 999px;
    background: var(--danger);
    color: #ffffff;
    padding: 0;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
}

.delete-button:hover {
    border-color: #8f1c14;
    background: #8f1c14;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.trap {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.login-shell {
    width: min(420px, 100%);
}

.login-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 28px;
}

.confirm-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.confirm-shell {
    width: min(640px, 100%);
}

.confirm-card {
    display: grid;
    gap: 22px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
    padding: 28px;
}

.confirm-details {
    display: grid;
    gap: 0;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.confirm-details div {
    display: grid;
    grid-template-columns: minmax(130px, 0.35fr) minmax(0, 1fr);
    border-bottom: 1px solid var(--line);
}

.confirm-details div:last-child {
    border-bottom: 0;
}

.confirm-details dt,
.confirm-details dd {
    margin: 0;
    padding: 10px 12px;
}

.confirm-details dt {
    background: #f1f4f7;
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.confirm-details dd {
    overflow-wrap: anywhere;
}

.confirm-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.confirm-actions form {
    display: block;
}

.secondary-action,
.danger-action {
    display: inline-grid;
    min-height: 42px;
    place-items: center;
    border-radius: 8px;
    padding: 0 16px;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.secondary-action {
    border: 1px solid var(--line);
    background: #ffffff;
    color: var(--text);
}

.secondary-action:hover {
    border-color: #b9c1ca;
    color: var(--accent);
}

.danger-action {
    border: 1px solid var(--danger);
    background: var(--danger);
    color: #ffffff;
}

.danger-action:hover {
    border-color: #8f1c14;
    background: #8f1c14;
}

.date-popover {
    position: absolute;
    z-index: 20;
    width: 304px;
    border: 1px solid #c8d0d9;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 18px 42px rgba(27, 39, 51, 0.18);
    padding: 12px;
}

.date-popover[hidden] {
    display: none;
}

.date-head {
    display: grid;
    grid-template-columns: 36px 1fr 36px;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.date-head button,
.date-day {
    min-height: 34px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font: inherit;
    cursor: pointer;
}

.date-head button:hover,
.date-day:hover {
    border-color: #c8d0d9;
    background: #f1f4f7;
}

.date-title {
    text-align: center;
    font-weight: 800;
}

.date-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.date-weekday {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 800;
    text-align: center;
}

.date-day {
    padding: 0;
}

.date-day.is-muted {
    color: #9aa4af;
}

.date-weekday.is-weekend {
    color: #9aa4af;
}

.date-day.is-weekend {
    background: #e9edf1;
}

.date-day.is-weekend:hover {
    background: #dde3ea;
}

.date-day.is-today {
    border-color: var(--accent);
    font-weight: 800;
}

.date-day.is-selected {
    background: var(--focus);
    border-color: var(--focus);
    color: #ffffff;
}

@media (max-width: 720px) {
    .app-header > div,
    .app-shell {
        width: min(100% - 24px, 1040px);
    }

    .form-panel {
        padding: 18px;
    }

    .form-grid,
    .choice-grid,
    .team-choice-grid,
    .mapping-grid,
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .event-choice-grid {
        grid-auto-flow: row;
        grid-template-rows: none;
    }

    .tab {
        flex: 1 1 calc(50% - 8px);
        padding: 0 10px;
    }

    .app-header > div {
        align-items: flex-start;
        flex-direction: column;
    }

    .confirm-details div {
        grid-template-columns: 1fr;
    }

    .confirm-actions {
        justify-content: stretch;
    }

    .secondary-action,
    .danger-action,
    .confirm-actions form {
        width: 100%;
    }

    .date-popover {
        width: min(304px, calc(100vw - 24px));
    }
}
