:root {
  --ink: #15232d;
  --muted: #5c6e78;
  --line: #d7e0df;
  --soft-line: #e8eeec;
  --surface: #ffffff;
  --canvas: #f4f7f6;
  --sidebar: #173f3c;
  --sidebar-ink: #d7ebe5;
  --accent: #007c67;
  --accent-strong: #006451;
  --accent-soft: #e2f1ec;
  --warning: #a95f09;
  --danger: #a23c31;
  --shadow: 0 10px 26px rgba(21, 35, 45, 0.07);
  --input-border: #bdccca;
  --input-surface: #ffffff;
  --content-surface: #fbfcfc;
  --table-head: #f1f5f4;
  --table-hover: #f4faf8;
  --control-focus: #8bd1c0;
  --font-ui: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
}

html { min-height: 100%; font-size: 13px; }
body { min-height: 100vh; margin: 0; color: var(--ink); background: var(--canvas); font-family: var(--font-ui); }
button, input, select, textarea { font: inherit; }
button { font-weight: 650; }
button:focus-visible, input:focus, select:focus, textarea:focus { outline: 2px solid var(--control-focus); outline-offset: 1px; }

.app-header { min-height: 64px; padding: 0 26px; display: flex; align-items: center; justify-content: space-between; gap: 19px; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--surface); }
.app-brand { display: flex; align-items: baseline; gap: 11px; min-width: 0; color: var(--ink); text-decoration: none; }
.app-brand-mark { flex: 0 0 auto; color: var(--accent); font-size: 15px; font-weight: 800; letter-spacing: 0.08em; }
.eyebrow, .sidebar-label { color: var(--accent); font-size: 10px; font-weight: 750; letter-spacing: 0.08em; }
.app-brand-name { display: inline; color: var(--accent); font-size: 12px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; }
.app-main { width: min(1344px, calc(100% - 38px)); margin: 0 auto; padding: 22px 0 38px; }

.session-tools, .view-heading, .filter-actions, .pager, .dialog-actions, .query-tools { display: flex; align-items: center; gap: 16px; }
.session-tools { flex: 0 0 auto; margin-left: auto; white-space: nowrap; }
.app-header > .session-context { margin-left: auto; }
.app-header > .session-tools { margin-left: 0; }
.session-context { display: flex; align-items: center; }
.session-detail { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.session-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.session-label::after { content: "："; }
.session-label { display: none; }
.session-detail strong { color: var(--ink); font-size: 13px; font-weight: 700; }
.language-switch, .theme-switch { display: flex; align-items: center; gap: 8px; min-width: auto; }
.language-switch span, .theme-switch span { color: var(--muted); font-size: 12px; font-weight: 700; }
.language-switch span, .theme-switch { display: none; }
.language-switch select, .theme-switch select { min-height: 35px; min-width: 104px; padding: 6px 9px; border: 0; background: transparent; font-size: 13px; }
.language-switch select:focus, .theme-switch select:focus { border: 0; }
.result-count, .page-context { color: var(--muted); }
.page-context { margin: 6px 0 0; font-size: 13px; line-height: 1.5; }
.usage-delay-warning { margin-left: 10px; color: #d6453d; font-weight: 700; }
.eyebrow { margin: 0 0 6px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 26px; line-height: 1.2; letter-spacing: 0; }
h2 { margin-bottom: 0; font-size: 18px; line-height: 1.3; }

.button { min-height: 35px; padding: 7px 13px; border: 1px solid transparent; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.button:disabled { cursor: not-allowed; opacity: 0.45; }
.button-primary { color: #fff; background: var(--accent); }
.button-primary:hover:not(:disabled) { background: var(--accent-strong); }
.button-quiet { color: var(--ink); border-color: var(--line); background: var(--surface); }
.button-quiet:hover:not(:disabled) { color: var(--accent-strong); border-color: var(--accent); }

.notice { margin-bottom: 14px; padding: 10px 12px; border-left: 3px solid var(--accent); color: #18453c; background: var(--accent-soft); font-size: 12px; }
.notice.error { border-left-color: var(--danger); color: var(--danger); background: #fff1ef; }

.login-card { position: relative; display: flex; flex-direction: column; align-items: center; width: 100vw; min-height: calc(100vh - 65px); margin: -22px calc(50% - 50vw) -38px; padding: clamp(34px, 7vh, 70px) 18px 48px; overflow: hidden; box-sizing: border-box; border: 0; border-radius: 0; background: linear-gradient(180deg, rgba(5, 37, 29, 0.38), rgba(5, 37, 29, 0.08)), url("../images/login-golf-hero.png") center / cover no-repeat; box-shadow: none; transition: filter 180ms ease, opacity 180ms ease; }
.login-card::before { position: absolute; inset: 0; content: ""; background: radial-gradient(circle at 50% 19%, rgba(255, 255, 255, 0.24), transparent 30%), linear-gradient(180deg, rgba(5, 32, 26, 0.5), rgba(5, 32, 26, 0.12) 42%, rgba(5, 32, 26, 0.34)); pointer-events: none; }
.login-copy, .login-form { position: relative; z-index: 1; margin-left: auto; margin-right: auto; }
.login-copy { width: min(430px, calc(100% - 48px)); padding-top: 0; color: #fff; text-align: center; transition: transform 180ms ease, opacity 180ms ease; }
.login-copy .eyebrow { color: #9df2d4; }
.login-copy h1 { color: #fff; font-family: var(--font-display); font-size: clamp(30px, 4vw, 46px); font-weight: 800; letter-spacing: 0; text-shadow: 0 2px 14px rgba(0, 0, 0, 0.22); }
.login-form { display: grid; grid-template-columns: 1fr; gap: 15px; width: min(390px, calc(100% - 48px)); margin-top: 24px; padding: 24px; box-sizing: border-box; border: 1px solid rgba(255, 255, 255, 0.48); border-radius: 8px; background: rgba(255, 255, 255, 0.9); box-shadow: 0 18px 40px rgba(5, 26, 22, 0.26); backdrop-filter: blur(10px); transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease, background-color 180ms ease; }
.login-form label { color: #17332d; }
.login-form .button { width: 100%; margin-top: 4px; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 44px; }
.password-toggle { position: absolute; top: 50%; right: 6px; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; min-height: 32px; padding: 0; transform: translateY(-50%); border: 0; border-radius: 4px; color: #536b64; background: transparent; cursor: pointer; }
.password-toggle:hover:not(:disabled), .password-toggle:focus-visible { color: var(--accent-strong); background: rgba(0, 124, 103, 0.1); }
.password-toggle:disabled { cursor: not-allowed; opacity: 0.55; }
.password-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.password-eye-off-icon { display: none; }
.password-toggle.is-visible .password-eye-icon { display: none; }
.password-toggle.is-visible .password-eye-off-icon { display: block; }
.login-card.is-authenticating .login-copy { transform: translateY(-2px); opacity: 0.92; }
.login-form.is-submitting { transform: translateY(-2px); border-color: rgba(0, 124, 103, 0.36); background: rgba(255, 255, 255, 0.94); box-shadow: 0 22px 46px rgba(5, 26, 22, 0.32); }
.login-form.is-submitting input:disabled { color: #63766f; background: rgba(255, 255, 255, 0.78); }
#login-submit-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; transition: background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, opacity 160ms ease; }
#login-submit-button:disabled { opacity: 1; background: var(--accent-strong); box-shadow: 0 8px 18px rgba(0, 100, 81, 0.22); }
.button-progress { display: none; width: 14px; height: 14px; min-width: 14px; box-sizing: border-box; border: 2px solid rgba(255, 255, 255, 0.44); border-top-color: #fff; border-radius: 50%; }
.login-form.is-submitting .button-progress { display: inline-block; animation: login-spin 760ms linear infinite; }
.login-options { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: -2px; }
.login-check { display: inline-flex; grid-template-columns: none; align-items: center; gap: 7px; color: #38534c; font-size: 12px; font-weight: 700; }
.login-check input { width: auto; min-height: auto; accent-color: var(--accent); }
.login-check span { white-space: nowrap; }
.login-error-message { margin: -2px 0 0; padding: 8px 10px; border-left: 3px solid var(--danger); color: var(--danger); background: #fff1ef; font-size: 12px; font-weight: 700; }
.login-hint { margin: -4px 0 0; color: #5b716b; text-align: center; font-size: 12px; font-weight: 650; }

@keyframes login-spin {
  to { transform: rotate(360deg); }
}

@keyframes workspace-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

label, legend { color: var(--ink); font-size: 12px; font-weight: 700; }
label { display: grid; gap: 6px; }
input, select, textarea { box-sizing: border-box; width: 100%; min-height: 37px; padding: 8px 10px; color: var(--ink); border: 1px solid var(--input-border); border-radius: 3px; background: var(--input-surface); }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.app-workspace { display: grid; grid-template-columns: 171px minmax(0, 1fr); min-height: calc(100vh - 116px); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); animation: workspace-in 180ms ease both; }
.app-sidebar { padding: 18px 10px; background: var(--sidebar); }
.sidebar-group + .sidebar-group { margin-top: 22px; }
.sidebar-label { margin: 0 10px 6px; color: #9fc6ba; }
.nav-item { display: block; width: 100%; min-height: 35px; padding: 7px 10px; border: 0; border-left: 2px solid transparent; border-radius: 3px; color: var(--sidebar-ink); background: transparent; text-align: left; cursor: pointer; font-size: 13px; }
.nav-item:hover { background: rgba(255, 255, 255, 0.09); }
.nav-item.active { border-left-color: #86d9c2; color: #fff; background: rgba(255, 255, 255, 0.14); }
.app-content { min-width: 0; padding: 26px; background: var(--content-surface); }
.view-heading { align-items: flex-start; justify-content: space-between; gap: 19px; margin-bottom: 19px; }
.result-count { font-size: 12px; white-space: nowrap; }

.filter-panel { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-template-areas: "course quick from to" "bays events page actions"; gap: 13px; align-items: start; padding: 16px; border: 1px solid var(--line); background: var(--surface); }
.filter-panel.has-tenant-filter { grid-template-areas: "tenant tenant tenant tenant" "course quick from to" "bays events page actions"; }
.filter-tenant { grid-area: tenant; max-width: none; }
.filter-course { grid-area: course; min-width: 0; }
.filter-quick-range { grid-area: quick; }
.filter-from { grid-area: from; }
.filter-to { grid-area: to; }
.filter-bays { grid-area: bays; }
.filter-events { grid-area: events; }
.filter-page-size { grid-area: page; }
.filter-actions-cell { grid-area: actions; }
.course-select { width: 100%; min-height: 37px; padding: 7px 10px; border: 1px solid var(--input-border); border-radius: 3px; color: var(--ink); background: var(--input-surface); font-size: 12px; font-weight: 600; }
.course-select:hover { border-color: var(--accent); }
.check-field { display: flex; grid-template-columns: none; align-items: center; gap: 7px; min-width: 0; font-size: 12px; font-weight: 500; }
.check-field input { width: auto; min-height: auto; accent-color: var(--accent); }
.field-hint { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; font-weight: 400; }
.filter-actions { align-self: end; justify-content: flex-end; gap: 8px; }
.filter-actions #export-excel-button { order: 1; }
.filter-actions #reset-query-button { order: 2; }
.filter-actions button[type="submit"] { order: 3; }

.summary-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.metric-card { min-height: 78px; padding: 14px 14px; border: 1px solid var(--line); border-left: 3px solid var(--accent); background: var(--surface); box-sizing: border-box; }
.metric-card span { display: block; color: var(--muted); font-size: 11px; font-weight: 700; }
.metric-card strong { display: block; margin-top: 7px; color: var(--ink); font-size: 18px; font-weight: 750; line-height: 1.15; }
.metric-card-blue { border-left-color: #4c8fb8; }
.metric-card-warm { border-left-color: #c67739; }
.metric-card-violet { border-left-color: #7c659b; }
.metric-card-green { border-left-color: #5c9367; }
.metric-card-gold { border-left-color: #aa8238; }
.metric-card-steel { border-left-color: #5d7897; }
.metric-card-rose { border-left-color: #9a6372; }

.view-tabs { display: flex; gap: 3px; margin-top: 21px; border-bottom: 1px solid var(--line); }
.view-tab { min-height: 37px; padding: 8px 14px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; cursor: pointer; font-size: 13px; }
.view-tab:hover, .view-tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.view-panel[hidden] { display: none; }
.table-frame { margin-top: 16px; overflow-x: auto; border: 1px solid var(--line); background: var(--surface); }
.event-table, .management-table { width: 100%; min-width: 816px; border-collapse: collapse; font-size: 12px; }
.event-table th, .event-table td, .management-table th, .management-table td { padding: 11px 11px; border-bottom: 1px solid var(--soft-line); text-align: left; vertical-align: middle; white-space: nowrap; }
.event-table th, .management-table th { color: var(--muted); background: var(--table-head); font-size: 11px; font-weight: 750; letter-spacing: 0; }
.event-table tbody tr:hover, .management-table tbody tr:hover { background: var(--table-hover); }
.table-sort-button { display: inline-flex; align-items: center; gap: 5px; min-height: 0; padding: 0; border: 0; color: inherit; background: transparent; font: inherit; font-weight: inherit; letter-spacing: inherit; white-space: nowrap; cursor: pointer; }
.table-sort-button:hover, .table-sort-button.sort-asc, .table-sort-button.sort-desc { color: var(--ink); }
.table-sort-indicator { display: inline-flex; justify-content: center; width: 10px; min-width: 10px; color: var(--accent-strong); font-size: 10px; line-height: 1; }
.table-sort-button.sort-asc .table-sort-indicator::before { content: "\2191"; }
.table-sort-button.sort-desc .table-sort-indicator::before { content: "\2193"; }
.management-table { min-width: 608px; }
.network-license-table { min-width: 1060px; }
.network-license-filter-panel { grid-template-areas: "tenant state search actions"; }
.network-license-filter-panel #network-license-tenant-filter { grid-area: tenant; }
.network-license-filter-panel label:nth-of-type(2) { grid-area: state; }
.network-license-filter-panel label:nth-of-type(3) { grid-area: search; }
.network-license-filter-panel .filter-actions { grid-area: actions; }
.table-actions { min-width: 120px; }
.table-action { min-height: 26px; margin-right: 7px; padding: 2px 0; border: 0; color: var(--accent-strong); background: transparent; cursor: pointer; font-size: 11px; }
.table-action:hover { text-decoration: underline; }
.permission-hidden { display: none; }
.empty-state { padding: 29px 16px; color: var(--muted); text-align: center; font-size: 12px; }
.pager { justify-content: flex-end; margin-top: 12px; }
.pager span { min-width: 75px; color: var(--muted); text-align: center; font-size: 11px; }

.permission-layout { display: grid; grid-template-columns: minmax(208px, 304px) minmax(208px, 1fr); gap: 19px; align-items: start; padding: 19px; border: 1px solid var(--line); background: var(--surface); }
.permission-form { display: grid; grid-template-columns: repeat(2, minmax(152px, 1fr)); gap: 11px 19px; }
.permission-form label { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.permission-form input { width: auto; min-height: auto; accent-color: var(--accent); }
.permission-form button { justify-self: start; grid-column: 1 / -1; }

.live-status-filters { display: grid; grid-template-columns: repeat(3, minmax(176px, 1fr)); gap: 13px; margin-top: 18px; padding: 16px; border: 1px solid var(--line); background: var(--surface); }
.live-status-filters label { display: grid; gap: 6px; color: var(--ink); font-size: 12px; font-weight: 700; }
.live-status-summary { display: grid; gap: 6px; margin-top: 10px; padding: 8px 10px; border: 1px solid var(--line); background: var(--surface); }
.live-status-summary-bar { display: flex; width: 100%; height: 12px; overflow: hidden; border: 1px solid #c7d1d0; background: #e9eeed; }
.live-status-summary-segment { min-width: 0; }
.live-status-summary-segment.active { background: #05835f; }
.live-status-summary-segment.ready { background: #226db4; }
.live-status-summary-segment.maintenance { background: #d19a00; }
.live-status-summary-segment.fault { background: #c23434; }
.live-status-summary-segment.offline { background: #35434a; }
.live-status-summary-segment.other { background: #71818a; }
.live-status-summary-empty { display: grid; width: 100%; place-items: center; color: var(--muted); font-size: 12px; }
.live-status-summary-legend { display: flex; flex-wrap: wrap; gap: 4px 13px; align-items: center; }
.live-status-summary-item { display: inline-flex; align-items: center; gap: 6px; color: #43555e; font-size: 11px; font-weight: 700; white-space: nowrap; }
.live-status-summary-item strong { min-width: 19px; color: var(--ink); font-size: 14px; text-align: right; }
.live-status-summary-marker { width: 10px; height: 10px; box-sizing: border-box; background: #71818a; }
.live-status-summary-item.active .live-status-summary-marker { background: #05835f; }
.live-status-summary-item.ready .live-status-summary-marker { background: #226db4; }
.live-status-summary-item.maintenance .live-status-summary-marker { background: #d19a00; }
.live-status-summary-item.fault .live-status-summary-marker { background: #c23434; }
.live-status-summary-item.offline .live-status-summary-marker { background: #35434a; }
.live-status-summary-item.other .live-status-summary-marker { background: #71818a; }
.live-status-installations { display: grid; gap: 14px; margin-top: 16px; }
.live-status-empty { margin-top: 16px; border: 1px solid var(--line); background: var(--surface); }
.live-installation { border: 1px solid var(--line); background: var(--surface); }
.live-installation-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 14px 16px; border-bottom: 1px solid var(--soft-line); background: #f7faf9; }
.live-installation-heading h2 { margin: 0; color: var(--ink); font-size: 15px; font-weight: 750; }
.live-installation-heading p { margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.live-upload-time { color: var(--muted); font-size: 11px; font-weight: 650; white-space: nowrap; }
.live-upload-time.stale { color: #a85137; }
.bay-status-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; padding: 13px 16px 16px; }
.bay-status-card { display: grid; gap: 6px; min-height: 85px; padding: 11px; border: 1px solid var(--line); border-left: 4px solid #71818a; background: #fff; box-sizing: border-box; }
.bay-status-card strong { color: var(--ink); font-size: 13px; }
.bay-status-label { display: inline-flex; align-items: center; gap: 6px; color: #43555e; font-size: 11px; font-weight: 750; }
.bay-status-dot { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: #71818a; }
.bay-status-values { color: var(--muted); font-size: 10px; line-height: 1.35; }
.bay-status-card.active { border-left-color: #05835f; background: #c8f3de; }
.bay-status-card.active .bay-status-label { color: #056b50; }
.bay-status-card.active .bay-status-dot { background: #05835f; }
.bay-status-card.ready { border-left-color: #226db4; background: #edf6ff; }
.bay-status-card.ready .bay-status-label { color: #17558d; }
.bay-status-card.ready .bay-status-dot { background: #226db4; }
.bay-status-card.maintenance { border-left-color: #d19a00; background: #fff9df; }
.bay-status-card.maintenance .bay-status-label { color: #806000; }
.bay-status-card.maintenance .bay-status-dot { background: #d19a00; }
.bay-status-card.fault { border-left-color: #c23434; background: #ffd2d2; }
.bay-status-card.fault .bay-status-label { color: #a42020; }
.bay-status-card.fault .bay-status-dot { background: #c23434; }
.bay-status-card.offline { border-left-color: #35434a; background: #edf0f1; }
.bay-status-card.offline .bay-status-label { color: #35434a; }
.bay-status-card.offline .bay-status-dot { background: #35434a; }
.bay-status-card.other { border-left-color: #71818a; background: #f3f6f7; }
.bay-status-card.other .bay-status-label { color: #46555d; }
.bay-status-card.other .bay-status-dot { background: #71818a; }
.app-view:fullscreen { min-height: 100vh; padding: 22px; overflow-y: auto; background: var(--canvas); }
#live-status-workspace:fullscreen .live-status-filters { display: none; }
.app-view:fullscreen .live-status-installations { padding-bottom: 22px; }

.editor-dialog { width: min(480px, calc(100% - 26px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: var(--surface); box-shadow: 0 16px 45px rgba(21, 35, 45, 0.22); }
.editor-dialog::backdrop { background: rgba(15, 29, 33, 0.36); }
.editor-dialog form { display: grid; gap: 16px; padding: 19px; }
.dialog-heading { display: flex; align-items: center; justify-content: space-between; gap: 13px; }
.icon-button { width: 29px; height: 29px; padding: 0; border: 1px solid var(--line); border-radius: 3px; color: var(--ink); background: #fff; cursor: pointer; font-size: 19px; line-height: 1; }
.editor-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.editor-fields label:has(textarea), .editor-fields .check-field { grid-column: 1 / -1; }
.password-dialog-fields { display: grid; gap: 16px; }
.password-dialog-fields label { display: block; min-width: 0; line-height: 1.35; }
.password-dialog-fields input { display: block; width: 100%; min-height: 46px; margin-top: 7px; position: relative; z-index: 1; }
#password-dialog { position: fixed; inset: 0; width: min(420px, calc(100vw - 24px)); max-width: calc(100vw - 24px); height: fit-content; max-height: calc(100dvh - 24px); margin: auto; box-sizing: border-box; overflow: auto; transform: none; }
#password-dialog form { max-height: none; box-sizing: border-box; overflow: visible; }
#password-dialog .dialog-heading { min-height: 36px; }
#password-dialog .password-dialog-fields { width: 100%; }
#password-dialog .password-dialog-fields input { box-sizing: border-box; }
#password-dialog .dialog-actions { position: relative; z-index: 1; }
.dialog-error { margin: 0; padding: 8px 10px; border-left: 3px solid var(--danger); color: var(--danger); background: #fff1ef; font-size: 12px; line-height: 1.45; }
.dialog-actions { justify-content: flex-end; }

@media (max-width: 1080px) {
  .filter-panel, .filter-panel.has-tenant-filter { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-areas: "tenant tenant" "course course" "quick quick" "from to" "bays events" "page actions"; }
  .filter-panel:not(.has-tenant-filter) { grid-template-areas: "course course" "quick quick" "from to" "bays events" "page actions"; }
  .summary-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .live-status-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-main { width: min(1344px, calc(100% - 28px)); }
  .app-header { padding: 0 18px; }
}

@media (max-width: 760px) {
  html { font-size: 16px; }
  .app-header { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 10px 12px; overflow-x: auto; }
  .app-brand { flex: 0 0 auto; }
  .session-context { flex: 0 1 auto; min-width: 0; }
  .session-tools { display: flex; align-items: center; justify-content: flex-end; flex: 0 0 auto; min-width: 0; margin-left: 0; gap: 8px; }
  .language-switch { display: none; }
  #change-password-button { display: none; }
  .app-workspace { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .app-sidebar { align-self: start; display: flex; gap: 8px; padding: 10px; overflow-x: auto; }
  .sidebar-group { display: flex; gap: 6px; align-items: center; }
  .sidebar-group + .sidebar-group { margin-top: 0; }
  .sidebar-label { display: none; }
  .nav-item { width: max-content; min-width: 94px; border-left: 0; border-bottom: 3px solid transparent; text-align: center; }
  .nav-item.active { border-bottom-color: #86d9c2; }
  .app-content { padding: 16px 12px; }
  .view-heading { align-items: flex-start; flex-direction: column; }
  .query-tools { align-items: center; flex-direction: row; flex-wrap: wrap; gap: 8px; width: 100%; }
  .query-tools .result-count { flex: 1 1 100%; white-space: normal; }
  .query-tools .button { flex: 1 1 0; min-width: 0; width: auto; }
  .login-card { width: 100vw; min-height: calc(100vh - 65px); margin: -16px calc(50% - 50vw) -38px; padding: 30px 14px 42px; background-position: 58% center; }
  .login-card::before { background: linear-gradient(180deg, rgba(5, 37, 29, 0.56), rgba(5, 37, 29, 0.16) 44%, rgba(5, 37, 29, 0.34)); }
  .login-copy, .login-form { margin-left: auto; margin-right: auto; }
  .login-copy { width: min(420px, calc(100% - 32px)); padding-top: 36px; }
  .login-copy h1 { font-size: 32px; }
  .login-form { width: min(420px, calc(100% - 32px)); margin-top: 22px; padding: 20px; }
  .button { min-height: 44px; padding: 9px 16px; }
  label, legend { font-size: 15px; }
  input, select, textarea { min-height: 46px; padding: 10px 12px; border-radius: 4px; }
  .page-context { font-size: 16px; }
  .nav-item { font-size: 16px; }
  .login-form, .permission-layout, .permission-form, .editor-fields { grid-template-columns: 1fr; }
  .filter-panel, .filter-panel.has-tenant-filter { grid-template-columns: 1fr; grid-template-areas: "tenant" "course" "quick" "from" "to" "bays" "events" "page" "actions"; }
  .filter-panel:not(.has-tenant-filter) { grid-template-areas: "course" "quick" "from" "to" "bays" "events" "page" "actions"; }
  .filter-actions { justify-content: stretch; }
  .filter-actions .button { flex: 1; }
  .summary-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .live-status-filters { grid-template-columns: 1fr; margin-top: 10px; padding: 12px; }
  .live-installation-heading { flex-direction: column; }
  .live-upload-time { white-space: normal; }
  .live-status-summary-legend { gap: 8px 12px; }
  .bay-status-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 7px; padding: 11px; }
  .bay-status-card { min-height: 78px; padding: 9px; }
  .metric-card { min-height: 78px; padding: 11px 10px; }
  .metric-card span { font-size: 10px; }
  .metric-card strong { font-size: 17px; }
  .permission-form button { grid-column: auto; }
  .app-header { gap: 10px; }
  .app-brand { gap: 7px; }
  .app-brand-mark { font-size: 12px; }
  .app-brand-name { font-size: 14px; }
  .session-tools { gap: 9px; }
  .session-label { font-size: 10px; }
  .session-detail strong { font-size: 11px; }
  .language-switch { gap: 5px; }
  .language-switch span, .theme-switch span { font-size: 10px; }
  .language-switch select, .theme-switch select { min-width: 82px; min-height: 34px; padding: 5px 7px; font-size: 11px; }
  h1 { font-size: 27px; }
  .editor-dialog { width: min(600px, calc(100% - 32px)); max-height: calc(100vh - 40px); }
  .editor-dialog form { gap: 20px; padding: 24px; }
  .icon-button { width: 36px; height: 36px; font-size: 24px; }

  #query-workspace .eyebrow,
  #query-workspace #query-heading,
  #query-workspace .page-context,
  #live-status-workspace .eyebrow,
  #live-status-workspace #live-status-heading,
  #live-status-workspace .page-context,
  #tenants-workspace .eyebrow,
  #tenants-workspace h1,
  #tenants-workspace .page-context,
  #courses-workspace .eyebrow,
  #courses-workspace h1,
  #courses-workspace .page-context,
  #users-workspace .eyebrow,
  #users-workspace h1,
  #users-workspace .page-context,
  #installations-workspace .eyebrow,
  #installations-workspace h1,
  #installations-workspace .page-context,
  #audit-workspace .eyebrow,
  #audit-workspace h1,
  #audit-workspace .page-context,
  #query-total,
  #export-excel-button,
  #reset-query-button,
  #query-form .filter-from,
  #query-form .filter-to,
  #query-form .filter-bays,
  #query-form .filter-events,
  #query-form .filter-page-size,
  #report-tabs,
  #summary-view,
  #sessions-view,
  #events-view,
  #query-workspace .pager {
    display: none !important;
  }

  #query-form,
  #query-form.has-tenant-filter {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: "tenant course" "quick actions";
    align-items: end;
    gap: 10px;
  }

  #query-form:not(.has-tenant-filter) {
    grid-template-areas: "course quick" "actions actions";
  }

  #query-form .filter-field,
  #query-form label,
  #query-form .filter-actions-cell {
    width: 100%;
    min-width: 0;
  }

  #query-form .filter-actions-cell {
    align-self: stretch;
    display: flex;
    align-items: end;
  }

  #query-form select,
  #query-form .course-select,
  #query-form label > select,
  #query-form .filter-actions-cell button[type="submit"] {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 48px;
    padding: 10px 12px;
    font-size: 16px;
    font-weight: 750;
    line-height: 1.25;
  }

  #query-form .filter-actions-cell button[type="submit"] {
    flex: 0 0 100%;
  }

  .live-status-filter-field {
    display: none !important;
  }

  #query-form label {
    height: 100%;
    align-content: end;
    justify-content: stretch;
    justify-items: stretch;
    font-size: 16px;
  }

  #quick-range option[value=""] {
    display: none;
  }
}

@media (max-width: 520px) {
  .app-header { justify-content: initial; }
  .app-brand-name { display: none; }
  .session-tools { justify-content: flex-end; }
  .session-context { max-width: 48%; }
  .session-detail strong { max-width: 13ch; overflow: hidden; text-overflow: ellipsis; }
}

html[data-theme="night"] {
  color-scheme: dark;
  --ink: #e9f1f2;
  --muted: #a8bec3;
  --line: #365159;
  --soft-line: #293f45;
  --surface: #12242a;
  --canvas: #08151a;
  --sidebar: #071c22;
  --sidebar-ink: #c7e0e0;
  --accent: #38d1b0;
  --accent-strong: #1ca88a;
  --accent-soft: #153b35;
  --warning: #f3bd54;
  --danger: #ff827b;
  --shadow: 0 10px 26px rgba(0, 0, 0, 0.28);
  --input-border: #47646b;
  --input-surface: #172f36;
  --content-surface: #0e2026;
  --table-head: #183139;
  --table-hover: #1b3c3e;
  --control-focus: #62e5cb;
}

html[data-theme="ocean"] {
  color-scheme: light;
  --ink: #173047;
  --muted: #587083;
  --line: #cbdde7;
  --soft-line: #e4eef3;
  --surface: #ffffff;
  --canvas: #eef6fa;
  --sidebar: #123e58;
  --sidebar-ink: #d9edf6;
  --accent: #147a9c;
  --accent-strong: #0d5f7b;
  --accent-soft: #e1f1f7;
  --warning: #a86b10;
  --danger: #a43f48;
  --shadow: 0 10px 26px rgba(23, 48, 71, 0.1);
  --input-border: #b9d0dc;
  --input-surface: #ffffff;
  --content-surface: #f8fbfd;
  --table-head: #e9f2f6;
  --table-hover: #edf8fb;
  --control-focus: #78c4dc;
}

html[data-theme="contrast"] {
  color-scheme: light;
  --ink: #111111;
  --muted: #343434;
  --line: #111111;
  --soft-line: #777777;
  --surface: #ffffff;
  --canvas: #f4f4f4;
  --sidebar: #111111;
  --sidebar-ink: #ffffff;
  --accent: #005a46;
  --accent-strong: #003d30;
  --accent-soft: #d9eee8;
  --warning: #714900;
  --danger: #8f0000;
  --shadow: 0 8px 0 rgba(17, 17, 17, 0.12);
  --input-border: #111111;
  --input-surface: #ffffff;
  --content-surface: #ffffff;
  --table-head: #e4e4e4;
  --table-hover: #e7f5f0;
  --control-focus: #005a46;
}

html[data-theme="night"] .button-quiet,
html[data-theme="night"] .icon-button,
html[data-theme="night"] .editor-dialog,
html[data-theme="night"] .login-card,
html[data-theme="night"] .filter-panel,
html[data-theme="night"] .table-frame,
html[data-theme="night"] .live-status-filters,
html[data-theme="night"] .live-status-summary,
html[data-theme="night"] .live-installation,
html[data-theme="night"] .live-status-empty,
html[data-theme="night"] .permission-layout {
  color: var(--ink);
  background: var(--surface);
}

html[data-theme="night"] .notice.error { background: #3b2022; }
html[data-theme="night"] .editor-dialog::backdrop { background: rgba(0, 0, 0, 0.68); }
html[data-theme="night"] .live-installation-heading { background: #172f36; }
html[data-theme="night"] select option,
html[data-theme="night"] select optgroup { color: #15232d; background: #ffffff; }
html[data-theme="night"] .bay-status-card { background: var(--surface); }
html[data-theme="night"] .bay-status-card.active { background: #174c3f; }
html[data-theme="night"] .bay-status-card.ready { background: #173b57; }
html[data-theme="night"] .bay-status-card.maintenance { background: #4a3b16; }
html[data-theme="night"] .bay-status-card.fault { background: #542526; }
html[data-theme="night"] .bay-status-card.offline { background: #253338; }
html[data-theme="night"] .bay-status-card.other { background: #26383d; }

/* Audit filters use the event time saved by the server, not the viewer's browser time zone. */
.audit-filter-panel {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-areas: "from to action user" "actions actions actions actions";
}

.audit-filter-panel.has-audit-tenant-filter {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-areas: "tenant from to action user" "actions actions actions actions actions";
}

.audit-filter-tenant { grid-area: tenant; }
.audit-filter-from { grid-area: from; }
.audit-filter-to { grid-area: to; }
.audit-filter-action { grid-area: action; }
.audit-filter-user { grid-area: user; }
.audit-filter-actions { grid-area: actions; justify-content: flex-end; }

@media (max-width: 1080px) {
  .audit-filter-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: "from to" "action user" "actions actions";
  }

  .audit-filter-panel.has-audit-tenant-filter {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: "tenant tenant" "from to" "action user" "actions actions";
  }
}

@media (max-width: 760px) {
  .audit-filter-panel,
  .audit-filter-panel.has-audit-tenant-filter {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "from" "to" "action" "user" "actions";
  }

  .audit-filter-panel.has-audit-tenant-filter {
    grid-template-areas: "tenant" "from" "to" "action" "user" "actions";
  }

  .audit-filter-actions { justify-content: stretch; }
  .audit-filter-actions button { flex: 1 1 0; }
}

/* Network authorization has a compact desktop filter and card rows on phones. */
.network-license-filter-panel {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-areas: "tenant state search actions";
}

.network-license-filter-panel:not(.has-network-license-tenant) {
  grid-template-columns: minmax(150px, 0.8fr) minmax(220px, 1.4fr) auto;
  grid-template-areas: "state search actions";
}

.network-license-filter-panel #network-license-tenant-filter { grid-area: tenant; }
.network-license-filter-panel .network-license-state-filter { grid-area: state; }
.network-license-filter-panel .network-license-search-field { grid-area: search; }
.network-license-filter-panel .network-license-filter-actions { grid-area: actions; }

@media (max-width: 1080px) {
  .network-license-filter-panel,
  .network-license-filter-panel:not(.has-network-license-tenant) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas: "tenant tenant" "state search" "actions actions";
  }

  .network-license-filter-panel:not(.has-network-license-tenant) {
    grid-template-areas: "state search" "actions actions";
  }
}

@media (max-width: 760px) {
  html, body { max-width: 100%; overflow-x: hidden; }
  .app-main { width: 100%; box-sizing: border-box; padding: 16px 10px 28px; }

  /* Keep every navigation item visible without a clipped horizontal strip. */
  .app-sidebar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px 6px;
    box-sizing: border-box;
    overflow: visible;
  }

  .sidebar-group { display: contents; }
  .nav-item {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: 8px 4px;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .network-licenses-workspace .view-heading {
    gap: 10px;
    margin-bottom: 14px;
  }

  .network-licenses-workspace .view-heading > div { width: 100%; }
  .network-licenses-workspace .eyebrow { margin-bottom: 4px; font-size: 10px; }
  .network-licenses-workspace h1 { font-size: clamp(24px, 7vw, 30px); line-height: 1.18; }
  .network-licenses-workspace .page-context { max-width: 100%; font-size: 14px; line-height: 1.45; }
  .network-licenses-workspace #refresh-network-licenses-button { align-self: stretch; width: 100%; }

  .network-license-filter-panel,
  .network-license-filter-panel:not(.has-network-license-tenant),
  .network-license-filter-panel.has-network-license-tenant {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "state" "search" "actions";
    gap: 11px;
    padding: 12px;
  }

  .network-license-filter-panel.has-network-license-tenant {
    grid-template-areas: "tenant" "state" "search" "actions";
  }

  .network-license-filter-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .network-license-filter-actions .button { width: 100%; }

  .network-license-table-frame { overflow: visible; }
  .network-license-table {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .network-license-table thead { display: none; }
  .network-license-table tbody { display: grid; gap: 10px; padding: 10px; box-sizing: border-box; }
  .network-license-table tr {
    display: block;
    padding: 5px 12px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--surface);
  }

  .network-license-table td {
    display: grid;
    grid-template-columns: minmax(106px, 38%) minmax(0, 1fr);
    gap: 8px;
    min-width: 0;
    padding: 9px 0;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .network-license-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
  }

  .network-license-table td:last-child { border-bottom: 0; }
  .network-license-table td.table-actions { display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
  .network-license-table td.table-actions::before { flex: 0 0 100%; }
  .network-license-table .table-action {
    min-height: 36px;
    margin: 0;
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface);
  }
}
