:root {
    color-scheme: light;
    font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --navy: #102033;
    --navy-2: #172b43;
    --page: #f4f7fb;
    --card: #ffffff;
    --text: #102033;
    --muted: #63758a;
    --border: #dfe7f0;
    --primary: #0da66b;
    --primary-dark: #08784d;
    --blue: #2d85f4;
    --orange: #f47c20;
    --violet: #7857d8;
    --danger: #cf3c45;
    --shadow: 0 10px 28px rgba(20, 48, 78, .08);
    --radius: 16px;
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; margin: 0; }
body { background: var(--page); color: var(--text); font-size: 15px; }
a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .62; }

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.65rem, 3vw, 2.25rem); margin-bottom: .35rem; line-height: 1.14; }
h2 { font-size: 1.1rem; margin: 0; }
h3 { font-size: 1rem; margin: 0; }
p { color: var(--muted); line-height: 1.55; }

.brand-mark {
    width: 50px; height: 50px; border-radius: 15px; display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #16c785, #087f52); color: white; font-weight: 800; letter-spacing: -.04em;
    box-shadow: 0 8px 22px rgba(13, 166, 107, .28); flex: 0 0 auto;
}
.brand-mark.large { width: 64px; height: 64px; border-radius: 20px; font-size: 1.15rem; }
.brand-mark.small { width: 40px; height: 40px; border-radius: 12px; }
.brand-mark.tiny { width: 34px; height: 34px; border-radius: 10px; font-size: .8rem; }

.eyebrow { display: block; color: var(--primary-dark); font-size: .72rem; font-weight: 800; letter-spacing: .12em; margin-bottom: 6px; }

.button {
    min-height: 42px; min-width: 88px; border: 1px solid transparent; border-radius: 10px; padding: 9px 15px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; white-space: nowrap;
    transition: .16s ease; color: var(--text); background: white;
}
.button:hover { transform: translateY(-1px); }
.button.primary { background: var(--primary); color: white; border-color: var(--primary); }
.button.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.button.secondary { border-color: var(--border); background: white; color: #24374d; }
.button.secondary:hover, .button.subtle:hover { background: #edf4fb; color: #173b61; }
.button.subtle { border-color: transparent; background: #eef3f8; color: #334a63; }
.button.danger { background: #fff1f1; color: #a8242d; border-color: #f3c7ca; }
.button.danger:hover { background: #fee2e3; color: #861a22; }
.button.compact { min-height: 36px; min-width: 0; padding: 7px 11px; font-size: .84rem; }
.button.full-width { width: 100%; }

.input-control {
    width: 100%; min-height: 48px; border: 1px solid #cad6e3; border-radius: 11px; background: #fff; color: #102033;
    padding: 11px 13px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input-control:focus { border-color: #3c91ec; box-shadow: 0 0 0 3px rgba(45, 133, 244, .13); }
.input-control:disabled { background: #eef2f6; color: #75869a; }
.field-group { display: grid; gap: 7px; }
.field-group label { font-weight: 700; color: #2a3f56; }

.alert { border-radius: 11px; padding: 11px 13px; font-weight: 600; line-height: 1.45; }
.alert.error { background: #fff0f1; color: #9d2630; border: 1px solid #f4c7cb; }
.alert.success { background: #e9f9f1; color: #08784d; border: 1px solid #b9e7cf; }

.spinner, .button-spinner {
    width: 22px; height: 22px; border: 3px solid rgba(45, 133, 244, .2); border-top-color: var(--blue); border-radius: 50%; animation: spin .75s linear infinite;
}
.button-spinner { width: 16px; height: 16px; border-width: 2px; border-color: rgba(255,255,255,.35); border-top-color: white; }
@keyframes spin { to { transform: rotate(360deg); } }

.boot-loader, .app-loading { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 15px; color: #31475f; }

.auth-shell { min-height: 100vh; position: relative; overflow: hidden; background: linear-gradient(145deg, #eef6fb, #f8fbfd 45%, #eef9f4); }
.auth-background { position: fixed; border-radius: 50%; filter: blur(2px); pointer-events: none; }
.auth-background-one { width: 420px; height: 420px; background: rgba(16, 181, 119, .11); top: -180px; right: -150px; }
.auth-background-two { width: 360px; height: 360px; background: rgba(45, 133, 244, .09); left: -170px; bottom: -160px; }
.auth-content { position: relative; z-index: 1; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card, .not-found-card {
    width: min(100%, 470px); background: rgba(255,255,255,.97); border: 1px solid rgba(211,224,236,.9); border-radius: 22px; padding: clamp(22px, 5vw, 36px); box-shadow: 0 22px 60px rgba(27, 62, 95, .14);
}
.login-brand { display: flex; gap: 16px; align-items: center; margin-bottom: 28px; }
.login-brand h1 { margin: 0 0 5px; font-size: 2rem; }
.login-brand p { margin: 0; font-size: .91rem; }
.login-form { display: grid; gap: 17px; }
.login-button { margin-top: 4px; min-height: 50px; }
.login-security-note { display: flex; gap: 11px; margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--border); color: #40566e; }
.login-security-note .security-icon { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #e4f8ee; color: #0a8958; font-weight: 900; }
.login-security-note strong, .login-security-note small { display: block; }
.login-security-note small { color: var(--muted); margin-top: 3px; line-height: 1.4; }
.not-found-card { text-align: center; }
.not-found-card .brand-mark { margin-bottom: 14px; }

.app-shell { min-height: 100vh; }
.sidebar { display: none; }
.app-main { min-height: 100vh; min-width: 0; }
.mobile-header {
    height: 62px; position: sticky; top: 0; z-index: 30; display: flex; align-items: center; justify-content: space-between;
    background: rgba(255,255,255,.96); border-bottom: 1px solid var(--border); padding: 8px 14px; backdrop-filter: blur(10px);
}
.mobile-brand { display: flex; align-items: center; gap: 9px; min-width: 0; }
.mobile-brand strong, .mobile-brand small { display: block; }
.mobile-brand strong { font-size: .96rem; }
.mobile-brand small { color: var(--muted); font-size: .74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 145px; }
.page-content { width: min(100%, 1520px); margin: 0 auto; padding: 18px 13px calc(92px + env(safe-area-inset-bottom)); }
.mobile-bottom-nav {
    position: fixed; z-index: 40; left: 8px; right: 8px; bottom: calc(7px + env(safe-area-inset-bottom));
    height: 66px; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: rgba(16,32,51,.97); border: 1px solid rgba(255,255,255,.08);
    border-radius: 17px; padding: 5px; box-shadow: 0 14px 40px rgba(16,32,51,.25); backdrop-filter: blur(12px);
}
.mobile-nav-item { color: #b9c8d8; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border-radius: 12px; font-size: 1.05rem; }
.mobile-nav-item small { font-size: .67rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.mobile-nav-item.active { background: #0d8f5c; color: white; }

.page-heading { display: flex; flex-direction: column; gap: 12px; justify-content: space-between; margin-bottom: 17px; }
.page-heading p { margin-bottom: 0; }
.refresh-button { align-self: flex-start; }
.dashboard-alert { margin-bottom: 14px; }

.kpi-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.kpi-card { min-width: 0; background: white; border: 1px solid var(--border); border-radius: 14px; padding: 13px; display: flex; gap: 11px; align-items: flex-start; box-shadow: 0 5px 18px rgba(26,55,84,.05); }
.kpi-card > div:last-child { min-width: 0; }
.kpi-card span, .kpi-card strong, .kpi-card small { display: block; }
.kpi-card > div > span { color: #52677e; font-weight: 700; font-size: .76rem; line-height: 1.2; }
.kpi-card strong { font-size: clamp(1.02rem, 4vw, 1.35rem); margin: 5px 0 3px; color: #0c1d30; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-card small { color: #718399; font-size: .69rem; line-height: 1.3; }
.kpi-icon { width: 37px; height: 37px; flex: 0 0 37px; display: grid; place-items: center; border-radius: 11px; font-weight: 900; font-size: 1.05rem; }
.kpi-card.green { background: linear-gradient(135deg, #f5fff9, #fff); }.kpi-card.green .kpi-icon { background: #d9f8e7; color: #07824f; }
.kpi-card.blue { background: linear-gradient(135deg, #f2f8ff, #fff); }.kpi-card.blue .kpi-icon { background: #dcecff; color: #236fca; }
.kpi-card.emerald { background: linear-gradient(135deg, #f4fcf7, #fff); }.kpi-card.emerald .kpi-icon { background: #d9f6e4; color: #178a4c; }
.kpi-card.orange { background: linear-gradient(135deg, #fff7ef, #fff); }.kpi-card.orange .kpi-icon { background: #ffead7; color: #d25e0e; }
.kpi-card.sky { background: linear-gradient(135deg, #f2f8ff, #fff); }.kpi-card.sky .kpi-icon { background: #dcecff; color: #1d6fd5; }
.kpi-card.violet { background: linear-gradient(135deg, #f8f4ff, #fff); }.kpi-card.violet .kpi-icon { background: #ebe0ff; color: #6842c1; }

.dashboard-section, .panel-card { background: white; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.dashboard-section { padding: 14px; margin-bottom: 14px; }
.section-heading { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.section-heading > div { display: flex; align-items: center; gap: 8px; }
.section-heading > small { color: var(--muted); }
.section-accent { width: 4px; height: 21px; border-radius: 4px; background: var(--primary); }
.compact-heading { margin-bottom: 16px; }
.compact-heading > strong { font-size: .94rem; }

.court-card-grid { display: grid; grid-template-columns: 1fr; gap: 11px; }
.court-card { border: 1px solid #dce5ee; border-radius: 14px; overflow: hidden; background: #fff; min-width: 0; }
.court-image { height: 118px; position: relative; overflow: hidden; display: grid; place-items: center; font-size: 2.2rem; color: rgba(255,255,255,.9); }
.court-image.football { background: linear-gradient(150deg, #2b7443, #5d9b52); }
.court-image.pickleball { background: linear-gradient(150deg, #246eb4, #5ca1de); }
.court-image img { width: 100%; height: 100%; object-fit: cover; }
.status-pill { display: inline-flex; align-items: center; justify-content: center; border-radius: 999px; padding: 5px 9px; font-size: .69rem; font-weight: 800; white-space: nowrap; }
.court-image .status-pill { position: absolute; left: 9px; bottom: 9px; box-shadow: 0 3px 12px rgba(0,0,0,.13); }
.status-pill.playing { background: #daf7e6; color: #087c47; }
.status-pill.social { background: #ece4ff; color: #6040ac; }
.status-pill.soon { background: #deedff; color: #1e68ba; }
.status-pill.booked { background: #fff0d2; color: #a95409; }
.status-pill.empty { background: #e5f8eb; color: #107a45; }
.court-card-body { padding: 11px 12px 12px; }
.court-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.court-title-row small { color: var(--muted); }
.capacity-chip { font-size: .72rem; background: #f0f4f8; color: #496077; padding: 5px 7px; border-radius: 8px; white-space: nowrap; }
.court-meta { display: grid; gap: 6px; margin-top: 11px; color: #536a81; font-size: .78rem; }
.court-meta span { display: flex; gap: 7px; align-items: baseline; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.court-meta b { color: #243b53; min-width: 15px; }

.dashboard-two-column { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 14px; }
.panel-card { padding: 14px; min-width: 0; }
.revenue-chart { min-height: 190px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; align-items: end; }
.chart-column { min-width: 0; display: grid; grid-template-rows: 24px 140px 22px; gap: 4px; align-items: end; text-align: center; }
.chart-value { font-size: .65rem; font-weight: 700; color: #5b6e83; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-track { height: 140px; display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid #dce5ee; }
.chart-bar { width: min(72%, 42px); min-width: 12px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, #65aff6, #368ee2); }
.chart-bar.today { background: linear-gradient(180deg, #36bd7d, #15975d); }
.chart-column small { color: #65788d; font-size: .67rem; }

.composition-total { background: #f4f8fc; border-radius: 12px; padding: 12px; display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 17px; }
.composition-total span { color: var(--muted); }
.composition-total strong { font-size: 1.15rem; }
.composition-row { margin-bottom: 15px; }
.composition-label { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; margin-bottom: 7px; color: #40566c; font-size: .83rem; }
.composition-label strong { color: #182c42; }
.dot { width: 9px; height: 9px; border-radius: 50%; }.green-dot { background: #21ab6b; }.blue-dot { background: #338de4; }.orange-dot { background: #f1822d; }
.progress-track { height: 8px; border-radius: 999px; background: #edf2f6; overflow: hidden; }
.progress-fill { display: block; height: 100%; border-radius: inherit; }.green-fill { background: #21ab6b; }.blue-fill { background: #338de4; }.orange-fill { background: #f1822d; }

.mobile-list, .activity-list, .device-list { display: grid; gap: 0; }
.booking-row, .activity-row { display: grid; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid #e9eef3; }
.booking-row:last-child, .activity-row:last-child { border-bottom: 0; }
.booking-row { grid-template-columns: minmax(64px, auto) 1fr auto; }
.booking-time strong, .booking-time small, .booking-main strong, .booking-main small, .activity-main strong, .activity-main small { display: block; }
.booking-time strong { font-size: .78rem; }.booking-time small, .booking-main small, .activity-main small { color: var(--muted); font-size: .72rem; margin-top: 2px; }
.booking-main { min-width: 0; }.booking-main strong, .booking-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-row { grid-template-columns: 34px 1fr auto; }
.activity-icon { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: #e4f7ed; color: #0b8754; font-weight: 900; }
.activity-main { min-width: 0; }.activity-main strong { font-size: .82rem; line-height: 1.3; }.activity-main small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.activity-row time { color: #718399; font-size: .7rem; }
.empty-state { padding: 28px 12px; text-align: center; color: #718399; background: #f7f9fb; border-radius: 12px; }
.dashboard-footer { text-align: center; color: #8190a1; font-size: .72rem; padding: 3px 0 8px; }

.page-loading-card { min-height: 210px; background: white; border: 1px solid var(--border); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; gap: 12px; color: #536a81; }
.page-loading-card.inline { min-height: 130px; border: 0; box-shadow: none; }
.permission-card, .module-placeholder { max-width: 650px; margin: 8vh auto 0; text-align: center; background: white; border: 1px solid var(--border); border-radius: 20px; padding: 32px 22px; box-shadow: var(--shadow); }
.permission-icon, .module-placeholder-icon { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 17px; display: grid; place-items: center; background: #edf5fd; color: #246fbd; font-size: 1.6rem; font-weight: 900; }
.permission-card p, .module-placeholder p { max-width: 520px; margin-left: auto; margin-right: auto; }

.devices-card { margin-bottom: 14px; }
.device-row { display: grid; grid-template-columns: 42px 1fr; gap: 11px; padding: 14px 0; border-bottom: 1px solid #e9eef3; align-items: center; }
.device-row:last-child { border-bottom: 0; }
.device-row > .button { grid-column: 2; justify-self: start; }
.device-icon { width: 42px; height: 42px; border-radius: 13px; background: #e7f1fb; color: #236eb8; display: grid; place-items: center; font-weight: 900; }
.device-copy { min-width: 0; }.device-copy > span, .device-copy > small { display: block; color: var(--muted); margin-top: 3px; font-size: .76rem; line-height: 1.35; }
.device-title-line { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.current-device-badge { background: #e4f8ed; color: #097d4d; border-radius: 999px; padding: 3px 7px; font-size: .65rem; font-weight: 800; }
.danger-zone { border: 1px solid #f0c5c9; background: #fff7f7; border-radius: 15px; padding: 15px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; justify-content: space-between; }
.danger-zone strong { color: #8d242b; }.danger-zone p { margin: 3px 0 0; color: #7d6265; font-size: .82rem; }

#blazor-error-ui { background: #fff1d9; bottom: 0; box-shadow: 0 -1px 8px rgba(0,0,0,.12); display: none; left: 0; padding: .8rem 1.25rem; position: fixed; width: 100%; z-index: 1000; color: #4b3a19; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .55rem; }

@media (min-width: 620px) {
    .page-content { padding-left: 22px; padding-right: 22px; }
    .page-heading, .section-heading { flex-direction: row; align-items: center; }
    .refresh-button { align-self: center; }
    .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
    .court-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .device-row { grid-template-columns: 46px 1fr auto; }.device-row > .button { grid-column: 3; justify-self: end; }
    .danger-zone { flex-direction: row; align-items: center; }
}

@media (min-width: 960px) {
    .app-shell { display: grid; grid-template-columns: 238px minmax(0, 1fr); }
    .sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: linear-gradient(180deg, #102033, #0d1b2c); color: white; padding: 18px 12px 14px; }
    .sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 7px 19px; border-bottom: 1px solid rgba(255,255,255,.08); }
    .sidebar-brand strong, .sidebar-brand small { display: block; }.sidebar-brand strong { font-size: 1.05rem; }.sidebar-brand small { color: #96a9bd; font-size: .72rem; margin-top: 2px; }
    .sidebar-nav { display: grid; gap: 4px; padding-top: 16px; overflow-y: auto; }
    .nav-item { min-height: 43px; display: flex; align-items: center; gap: 11px; border-radius: 10px; padding: 9px 11px; color: #c7d3df; font-weight: 650; transition: .15s; }
    .nav-item:hover { color: white; background: rgba(255,255,255,.07); }.nav-item.active { color: white; background: linear-gradient(90deg, #0c9660, #117b5a); box-shadow: inset 3px 0 #1de09a; }
    .nav-icon { width: 22px; text-align: center; font-size: 1.05rem; }
    .sidebar-account { margin-top: auto; border-top: 1px solid rgba(255,255,255,.08); padding: 15px 5px 3px; display: grid; grid-template-columns: 38px 1fr 34px; gap: 9px; align-items: center; }
    .avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: #dceaf6; color: #1f466b; font-weight: 800; }
    .account-copy { min-width: 0; }.account-copy strong, .account-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.account-copy strong { font-size: .8rem; }.account-copy small { color: #8fa4b8; font-size: .68rem; margin-top: 2px; }
    .icon-button { width: 32px; height: 32px; border-radius: 9px; border: 0; background: rgba(255,255,255,.07); color: #dce7f1; }.icon-button:hover { background: rgba(255,255,255,.14); color: white; }
    .mobile-header, .mobile-bottom-nav { display: none; }
    .page-content { padding: 26px 24px 34px; }
    .kpi-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .kpi-card { padding: 14px; }.kpi-card strong { font-size: 1.22rem; }
    .court-card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .dashboard-two-column { grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); }
    .lower-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

@media (min-width: 1280px) {
    .court-card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 390px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .booking-row { grid-template-columns: 1fr auto; }.booking-time { grid-column: 1 / -1; display: flex; justify-content: space-between; }.booking-main { grid-column: 1; }
    .mobile-bottom-nav { left: 5px; right: 5px; }
}
