:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --text: #17202a;
    --muted: #64748b;
    --line: #d9e2ec;
    --primary: #146c94;
    --primary-dark: #0f4f6d;
    --accent: #d97706;
    --danger: #b42318;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background: var(--bg);
}

body.login-page {
    min-height: 100vh;
    background:
        linear-gradient(90deg, rgba(6, 22, 32, 0.86) 0%, rgba(6, 22, 32, 0.58) 45%, rgba(6, 22, 32, 0.22) 100%),
        url('login-bg.png') center center / cover no-repeat fixed;
}

a {
    color: var(--primary);
    text-decoration: none;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: 68px;
    padding: 0 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.login-page .topbar {
    position: relative;
    z-index: 2;
    background: transparent;
    border-bottom: 0;
}

.login-page .brand {
    color: #fff;
}

.brand {
    color: var(--text);
    font-size: 22px;
    font-weight: 700;
}

.nav {
    display: flex;
    flex: 1;
    gap: 8px;
    flex-wrap: wrap;
}

.nav a {
    color: var(--muted);
    padding: 10px 12px;
    border-radius: 6px;
}

.nav a.active,
.nav a:hover,
.nav-menu > button.active,
.nav-menu > button:hover {
    color: var(--text);
    background: #edf4f8;
}

.nav-menu {
    position: relative;
}

.nav-menu > button {
    min-height: 40px;
    padding: 10px 12px;
    border: 0;
    border-radius: 6px;
    color: var(--muted);
    background: transparent;
    cursor: pointer;
    font: inherit;
}

.nav-menu-list {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 50;
    display: none;
    min-width: 180px;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgb(15 36 46 / 14%);
}

.nav-menu:hover .nav-menu-list,
.nav-menu:focus-within .nav-menu-list {
    display: grid;
    gap: 2px;
}

.nav-menu-list a {
    display: block;
    white-space: nowrap;
}

.account {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
}

.message-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 6px;
}

.message-link:hover,
.message-link.active {
    background: #edf4f8;
}

.message-envelope-icon {
    width: 28px;
    height: 22px;
    fill: none;
    stroke: var(--primary);
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.message-link.unread .message-envelope-icon {
    stroke-width: 2.4;
}

.message-envelope-icon text {
    fill: var(--primary);
    stroke: none;
    font-size: 9px;
    font-weight: 800;
}

.language-switcher {
    display: flex;
    align-items: center;
    gap: 6px;
}

.language-switcher a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 32px;
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.language-switcher a:hover,
.language-switcher a.active {
    color: var(--text);
    border-color: var(--line);
    background: #edf4f8;
}

.language-switcher.login {
    justify-content: flex-end;
    margin-bottom: 4px;
}

.language-switcher.login a {
    min-width: 40px;
    font-size: 22px;
    background: #fff;
    border-color: var(--line);
}

.language-switcher.login a.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(20, 108, 148, 0.16);
}

.language-menu {
    position: relative;
}

.language-menu > button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    background: #fff;
    cursor: pointer;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
}

.language-menu-list {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 65;
    display: none;
    min-width: 150px;
    padding: 6px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgb(15 36 46 / 14%);
}

.language-menu:hover .language-menu-list,
.language-menu:focus-within .language-menu-list {
    display: grid;
    gap: 2px;
}

.language-menu-list a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    border-radius: 5px;
    color: var(--muted);
    white-space: nowrap;
}

.language-menu-list a:hover,
.language-menu-list a.active {
    color: var(--text);
    background: #edf4f8;
}

.impersonate-inline {
    margin: 0;
}

.button.impersonate {
    min-height: 36px;
    border-color: #d8e3ea;
    color: var(--primary);
    background: #fff;
}

.button.impersonate.active {
    border-color: var(--danger);
    color: #fff;
    background: var(--danger);
}

.impersonate-menu {
    position: relative;
}

.impersonate-list {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 60;
    display: none;
    min-width: 320px;
    padding: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgb(15 36 46 / 14%);
}

.impersonate-menu:hover .impersonate-list,
.impersonate-menu:focus-within .impersonate-list {
    display: grid;
    gap: 8px;
}

.impersonate-list select {
    margin: 0;
}

.account-link {
    color: var(--muted);
    font-weight: 700;
}

.account-link:hover,
.account-link.active {
    color: var(--primary);
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 32px auto;
}

.login-page .shell {
    width: min(1180px, calc(100% - 32px));
    min-height: calc(100vh - 68px);
    margin: 0 auto;
    display: grid;
    align-items: center;
}

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 22px;
}

h1,
h2 {
    margin: 0;
}

h1 {
    font-size: 32px;
}

h2 {
    font-size: 20px;
    margin-bottom: 16px;
}

.subhead {
    font-size: 17px;
    margin-top: 12px;
    margin-bottom: 4px;
}

p {
    color: var(--muted);
    margin: 8px 0 0;
}

.hint {
    font-size: 13px;
    margin-top: 0;
}

.grid {
    display: grid;
    gap: 20px;
}

.grid.two {
    grid-template-columns: minmax(280px, 420px) 1fr;
}

.grid > div {
    display: grid;
    align-content: start;
    gap: 20px;
}

.card,
.metric {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 20px;
}

.match-list {
    display: grid;
    gap: 18px;
}

.match-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.match-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}

.match-head h2 {
    margin-bottom: 0;
}

.match-id {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

.roles-table th,
.roles-table td {
    padding-left: 20px;
    padding-right: 20px;
}

.assign-cell {
    cursor: pointer;
    min-width: 260px;
}

.assign-cell:hover {
    background: #f8fafc;
}

.assign-form {
    display: none;
    margin-top: 8px;
}

.assign-form.visible {
    display: block;
}

.assign-form.visible select {
    min-width: 220px;
    margin: 0;
}

.assign-form.visible .button {
    margin-left: 6px;
}

.lookup-form.visible {
    position: absolute;
    z-index: 20;
    display: grid;
    grid-template-columns: 170px 34px 34px 34px;
    align-items: center;
    gap: 0;
    width: max-content;
    margin-top: -4px;
    padding: 4px;
    background: #fff;
    border: 1px solid #c8d8df;
    border-radius: 4px;
    box-shadow: 0 2px 7px rgb(15 36 46 / 18%);
}

.lookup-input {
    min-height: 32px;
    margin: 0;
    border-color: #198c24;
    border-radius: 3px 0 0 3px;
    box-shadow: 0 0 0 1px #198c24;
}

.lookup-button,
.lookup-approve,
.lookup-cancel {
    min-height: 32px;
    border: 1px solid #b9cbd3;
    background: #fff;
    cursor: pointer;
}

.lookup-button {
    color: #007399;
}

.lookup-approve {
    color: #237b2a;
    font-weight: 700;
}

.lookup-cancel {
    color: #c81e35;
    font-weight: 700;
    border-radius: 0 3px 3px 0;
}

.lookup-list {
    position: absolute;
    top: 42px;
    left: 4px;
    display: none;
    width: 300px;
    max-height: 260px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #c8d8df;
    box-shadow: 0 3px 9px rgb(15 36 46 / 18%);
}

.lookup-list.visible {
    display: block;
}

.lookup-status {
    padding: 4px 8px;
    color: #006b8f;
    background: #e7f3f7;
    border-bottom: 1px solid #c8d8df;
    font-size: 13px;
    font-weight: 700;
}

.lookup-option {
    display: block;
    width: 100%;
    min-height: 30px;
    padding: 6px 10px;
    border: 0;
    background: #fff;
    color: #006b8f;
    text-align: left;
    cursor: pointer;
}

.lookup-option[hidden] {
    display: none;
}

.lookup-option:hover {
    background: #e8f3f6;
}

.lookup-modal[hidden] {
    display: none;
}

.lookup-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgb(15 36 46 / 22%);
}

.lookup-modal-window {
    width: min(820px, calc(100vw - 48px));
    height: min(620px, calc(100vh - 48px));
    display: grid;
    grid-template-rows: auto auto 1fr auto;
    overflow: hidden;
    background: #fff;
    border: 1px solid #b9cbd3;
    border-radius: 10px;
    box-shadow: 0 18px 45px rgb(15 36 46 / 28%);
}

.lookup-modal-titlebar {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 12px;
    background: #f8fbfc;
    border-bottom: 1px solid #c8d8df;
}

.lookup-modal-titlebar span {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ff5f57;
}

.lookup-modal-titlebar span:nth-child(2) {
    background: #ffbd2e;
}

.lookup-modal-titlebar span:nth-child(3) {
    background: #28c840;
}

.lookup-modal-titlebar strong {
    color: var(--muted);
    font-size: 13px;
}

.lookup-modal-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 10px;
    background: #e6f0f3;
    border-bottom: 1px solid #c8d8df;
}

.lookup-modal-toolbar strong {
    font-size: 14px;
}

.lookup-modal-toolbar select,
.lookup-modal-toolbar input {
    min-height: 32px;
    margin: 0;
    border-radius: 3px;
}

.lookup-modal-toolbar input {
    width: 280px;
    border-color: #198c24;
    box-shadow: 0 0 0 1px #198c24;
}

.lookup-modal-body {
    overflow-y: auto;
}

.lookup-modal-body table {
    font-size: 14px;
}

.lookup-modal-body th {
    color: #112b36;
    background: #fff;
    text-transform: none;
}

.lookup-modal-body td {
    padding: 7px 10px;
}

.lookup-modal-body tbody tr:nth-child(even) {
    background: #f2f7f8;
}

.lookup-modal-body tbody tr:hover {
    background: #e8f3f6;
    cursor: pointer;
}

.lookup-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #0084a8;
}

.lookup-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 10px;
    border-top: 1px solid #c8d8df;
    background: #f8fbfc;
}

.filter-bar {
    display: grid;
    grid-template-columns: 120px minmax(240px, 420px);
    align-items: end;
    gap: 12px;
    margin-bottom: 18px;
}

.matches-table td {
    vertical-align: top;
}

.match-id.inline {
    display: block;
    margin-top: 4px;
}

.role-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 320px;
}

.role-chip {
    display: grid;
    gap: 4px;
    min-width: 150px;
    max-width: 240px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.role-chip.open {
    border-color: #b7d9ea;
    background: #f5fbff;
}

.role-chip.assigned {
    border-color: #c9e4d2;
    background: #f7fcf8;
}

.role-chip.empty {
    color: var(--muted);
    background: #f8fafc;
}

.role-name {
    font-weight: 700;
}

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

.role-chip .book-form {
    margin-top: 4px;
}

.role-stack {
    display: grid;
    gap: 8px;
    min-width: 150px;
}

.role-slot {
    position: relative;
    display: grid;
    gap: 4px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.role-slot.open {
    border-color: #b7d9ea;
    background: #f5fbff;
}

.role-slot.assigned {
    border-color: #c9e4d2;
    background: #f7fcf8;
}

.role-slot.empty {
    color: var(--muted);
    background: #f8fafc;
}

.role-slot .book-form {
    margin-top: 4px;
}

.list-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    margin: 12px calc(50% - 50vw) 0;
    padding: 0 6px 0 10px;
    background: #e6f0f3;
    border: 0;
    border-bottom: 1px solid #c8d8df;
}

.list-toolbar strong {
    font-size: 14px;
}

.toolbar-icon {
    color: #006b8f;
    font-size: 15px;
    min-width: 22px;
    text-align: center;
}

.toolbar-series {
    display: flex;
    margin: 0;
}

.list-toolbar select,
.list-toolbar input {
    min-height: 32px;
    margin-top: 0;
    border-color: #9fb8c5;
    border-radius: 3px;
}

.toolbar-spacer {
    flex: 1;
}

.list-toolbar .toolbar {
    margin: 0;
}

.list-toolbar .toolbar label {
    display: none;
}

.list-view {
    overflow-x: auto;
    background: #fff;
    border: 0;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding-left: 10px;
}

.list-view .matches-table {
    min-width: 1120px;
}

.matches-table {
    font-size: 14px;
}

.matches-table th {
    color: #112b36;
    background: #fff;
    border-bottom: 1px solid #b9cbd3;
    font-size: 13px;
    text-transform: none;
}

.matches-table th,
.matches-table td {
    padding: 6px 10px;
}

.matches-table .date-col {
    min-width: 110px;
    white-space: nowrap;
}

.matches-table .match-col {
    min-width: 260px;
}

.matches-table tbody tr:nth-child(even) {
    background: #f2f7f8;
}

.matches-table tbody tr:hover {
    background: #e8f3f6;
}

.matches-table .match-id.inline {
    color: #647887;
    font-size: 12px;
}

.cell-line {
    display: block;
    line-height: 1.25;
}

.cell-line.strong {
    font-weight: 700;
}

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

.matches-table .assign-cell {
    min-width: 140px;
}

.matches-table .assign-cell:hover {
    background: #dceff5;
}

.matches-table .role-stack {
    min-width: 130px;
    gap: 5px;
}

.matches-table .role-slot {
    padding: 0;
    border: 0;
    background: transparent;
}

.matches-table .role-slot.open .role-user {
    color: #006b8f;
}

.matches-table .role-slot.assigned .role-user {
    color: #14232b;
}

.matches-table .role-slot.empty {
    color: var(--muted);
}

.matches-table .role-name {
    display: none;
}

.matches-table .book-form {
    margin-top: 4px;
}

.matches-table .button.small {
    min-height: 26px;
    padding: 0 8px;
    font-size: 12px;
}

.metric span {
    color: var(--muted);
    display: block;
}

.metric strong {
    display: block;
    font-size: 34px;
    margin-top: 8px;
}

.bar-list {
    display: grid;
    gap: 14px;
}

.bar-row {
    display: grid;
    gap: 6px;
}

.bar-label {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    font-size: 14px;
}

.bar-label strong {
    color: var(--primary);
}

.bar-track {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e4edf2;
}

.bar-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--primary);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.status-pill.success {
    color: #14532d;
    background: #dcfce7;
}

.status-pill.warning {
    color: #92400e;
    background: #fef3c7;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form.compact {
    margin-bottom: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 14px;
}

label {
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

input,
select,
textarea {
    display: block;
    width: 100%;
    min-height: 40px;
    margin-top: 6px;
    padding: 9px 10px;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
}

textarea {
    resize: vertical;
}

.points-grid {
    grid-template-columns: repeat(3, minmax(120px, 1fr));
}

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 24px;
}

.check input {
    width: auto;
    min-height: auto;
    margin: 0;
}

.check.compact {
    padding-top: 0;
    font-weight: 400;
}

.checkbox-list {
    display: grid;
    gap: 6px;
    max-height: 160px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--primary);
    border-radius: 6px;
    color: #fff;
    background: var(--primary);
    font-weight: 700;
    cursor: pointer;
}

.button:hover {
    background: var(--primary-dark);
}

.button.ghost {
    color: var(--primary);
    background: transparent;
}

.button.ghost.danger {
    color: var(--danger);
    border-color: #ffc9c4;
}

.button.small {
    min-height: 32px;
    padding: 0 10px;
    font-size: 13px;
}

.toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toolbar select {
    min-width: 220px;
}

.notice {
    margin-bottom: 20px;
    padding: 12px 14px;
    border-radius: 6px;
    background: #e7f6ed;
    color: #14532d;
    border: 1px solid #bbebcc;
}

.notice.error {
    color: var(--danger);
    background: #fff1f0;
    border-color: #ffd4d0;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

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

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.message-unread td {
    font-weight: 700;
    background: #f0f7fb;
}

.message-body {
    white-space: normal;
    line-height: 1.55;
}

.actions form {
    margin: 0;
}

.session-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    min-width: 160px;
    white-space: nowrap;
}

.session-actions form {
    margin: 0;
}

.event-time-value {
    display: grid;
    gap: 2px;
    padding: 0;
    border: 0;
    color: var(--primary);
    background: transparent;
    cursor: pointer;
    font: inherit;
}

.event-time-cell {
    position: relative;
    min-width: 140px;
}

.event-time-form {
    display: none;
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 20;
    grid-template-columns: 180px auto auto;
    align-items: center;
    gap: 6px;
    width: max-content;
    padding: 4px;
    background: #fff;
    border: 1px solid #c8d8df;
    border-radius: 4px;
    box-shadow: 0 2px 7px rgb(15 36 46 / 18%);
}

.event-time-form input {
    margin: 0;
}

.event-time-form.visible {
    display: grid;
}

.event-session-table th:last-child,
.event-session-table td:last-child {
    text-align: right;
}

.role-list {
    display: grid;
    gap: 8px;
    margin: 8px 0;
}

.role-row {
    display: grid;
    grid-template-columns: 1fr 78px 104px;
    align-items: center;
    gap: 10px;
}

.role-row input {
    margin-top: 0;
}

.split-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.split-head h2 {
    margin-bottom: 0;
}

.login-panel {
    min-height: calc(100vh - 150px);
    display: grid;
    grid-template-columns: 1fr 380px;
    align-items: center;
    gap: 36px;
    padding: 36px 0 56px;
    color: #fff;
}

.login-panel h1 {
    font-size: 48px;
    color: #fff;
}

.login-panel p {
    color: rgba(255, 255, 255, 0.86);
    font-size: 18px;
    max-width: 440px;
}

.login-panel .card {
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
    backdrop-filter: blur(8px);
}

@media (max-width: 820px) {
    .topbar,
    .page-head,
    .account {
        align-items: flex-start;
        flex-direction: column;
    }

    .grid.two,
    .metrics,
    .login-panel,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .topbar {
        padding: 16px;
    }

    .shell {
        margin-top: 20px;
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}
