@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    /* Light Theme Palette */
    --bg-main: #ffffff;
    --bg-subtle: #f8fafc;
    --bg-card: #ffffff;
    --primary: #059669; /* Slightly deeper Emerald for light theme */
    --primary-hover: #047857;
    --secondary: #d97706; /* Amber/Gold */
    --text-main: #0f172a; /* Dark Slate */
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --accent-red: #e11d48;
}

/* Base Styles */
html, body {
    background-color: var(--bg-main) !important;
    color: var(--text-main);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    overflow-x: hidden;
}

h1, h2, h3, .brand {
    font-family: 'Outfit', sans-serif;
    color: var(--text-main);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* Navbar */
nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2.5rem;
    background: var(--bg-main);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

.brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.double-brand-mark { display:flex; align-items:center; gap:3px; flex:0 0 auto; }
.double-brand-mark span { width:13px; height:24px; border:2px solid var(--navy, #0f172a); border-radius:7px; transform:rotate(18deg); }
.double-brand-mark span:last-child { transform:rotate(-18deg); }

.nav-links {
    display: flex;
    gap: 2.5rem;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.nav-links a:hover, .nav-links a.active {
    color: var(--primary);
}

/* Hero Section */
.hero {
    padding: 4rem 0 2rem;
    text-align: center;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.hero h1 {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.04em;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 650px;
    margin: 0 auto;
}

/* Cards */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: box-shadow 0.3s ease;
}

.glass-card:hover {
    box-shadow: var(--shadow-lg);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-outline {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: var(--bg-subtle);
    border-color: var(--primary);
    color: var(--primary);
}

/* Table Styles */
.table-container {
    overflow-x: auto;
    margin-top: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 0.75rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    padding: 1rem 1.5rem;
    background: var(--bg-subtle);
    color: var(--text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: white;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: #fdfdfd;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.85rem;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 700;
}

.status-online { background: #ecfdf5; color: #059669; border: 1px solid #d1fae5; }
.status-offline { background: #fff1f2; color: #e11d48; border: 1px solid #ffe4e6; }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pulse { animation: pulse 2s infinite; }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.4; } 100% { opacity: 1; } }

/* Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
}

/* Forms */
.form-group { margin-bottom: 1.25rem; }
label { display: block; margin-bottom: 0.5rem; color: var(--text-muted); font-size: 0.85rem; font-weight: 500; }
input, select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: white;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    color: var(--text-main);
    transition: all 0.2s;
}
input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1); }

/* Animation */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.animate-fade-in { animation: fadeIn 0.4s ease-out forwards; }

/* Professional Table Layout for History */
.race-header-bar {
    background-color: #5b8db8;
    color: white;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    border-radius: 4px 4px 0 0;
}

.details-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-top: none;
}

.details-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.details-table th {
    background-color: #666666;
    color: white;
    padding: 0.4rem 0.6rem;
    text-align: center;
    font-weight: 500;
    border: 1px solid #999;
    white-space: nowrap;
}

.details-table td {
    padding: 0.4rem 0.6rem;
    text-align: center;
    border: 1px solid var(--border);
    color: #333;
    white-space: nowrap;
}

.details-table tr:hover td {
    background-color: #f0f7ff;
}

.silk-placeholder {
    width: 24px;
    height: 24px;
    background: #eee;
    border-radius: 3px;
    display: inline-block;
}

.strength-box {
    font-weight: 700;
    color: #555;
}

.star-rating {
    color: #f59e0b;
    display: flex;
    justify-content: center;
    gap: 1px;
}

.edit-btn {
    padding: 2px 4px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 3px;
    color: #166534;
    cursor: pointer;
}

.edit-btn:hover {
    background: #dcfce7;
}

.sectional-sub {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* History Details Adjustments */
.pedigree-box {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
}

#live-feed {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-subtle);
}

/* Horse Profile Links */
.horse-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.horse-link:hover {
    text-decoration: underline;
}

/* Dropdown Container */
.dropdown {
    position: relative;
    display: inline-block;
}

/* Dropdown Button */
.dropdown .dropbtn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
    min-height: 38px;
    padding: 0.35rem 0.7rem;
}

/* Dropdown Content (Vertical List) */
.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: #eeeeee; /* Light gray background matching mockup */
    min-width: 168px;
    border: 1px solid #999999; /* Outer border matching mockup */
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    margin-top: 0;
    padding: 0;
    border-radius: 0;
}

/* Links inside the dropdown */
.dropdown-content a {
    color: #000000 !important;
    padding: 0.42rem 0.75rem;
    text-decoration: none;
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.2;
    text-align: left;
    border-bottom: 1px solid #cccccc !important; /* Separator lines matching mockup */
    transition: background-color 0.1s, color 0.1s;
}

.dropdown-content a:last-child {
    border-bottom: none !important;
}

.racingapp-main-nav .dropdown-content a { display:flex; width:100%; min-height:42px; align-items:center; box-sizing:border-box; }
.racingapp-main-nav .odds-dropdown-content { min-width:205px; }
.racingapp-main-nav .common-dropdown-content { min-width:235px; }
.racingapp-main-nav .history-dropdown-content { min-width:185px; }
.racingapp-main-nav .mega-dropdown { min-width:370px; grid-template-columns:repeat(2,minmax(0,1fr)); align-items:start; }
.racingapp-main-nav .dropdown:hover > .mega-dropdown { display:grid !important; }
.mega-nav-headings { display:flex; align-items:center; gap:clamp(1rem,2.4vw,2.5rem); }
.mega-menu-column { min-width:0; display:grid; align-content:start; }
.mega-menu-column + .mega-menu-column { border-left:1px solid #cccccc; }
.mega-menu-column a:last-child { border-bottom:1px solid #cccccc !important; }

/* Change color of dropdown links on hover (mockup red style) */
.dropdown-content a:hover {
    background-color: #ef4444 !important; /* Red hover matching mockup highlight style */
    color: #ffffff !important;
}

/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
    display: block !important;
}

/* Arrow micro-animation on hover */
.dropdown:hover .dropbtn svg {
    transform: rotate(180deg);
}

/* 2026 responsive presentation system */
:root {
    --navy: #10233f;
    --surface: #ffffff;
    --surface-muted: #f4f7fa;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

body {
    background: #f4f7fa !important;
    padding-bottom: env(safe-area-inset-bottom);
}

nav {
    min-height: 64px;
    padding: .65rem clamp(1rem, 3vw, 2.5rem);
}

.container {
    max-width: 1440px;
    padding: 1.25rem clamp(1rem, 2.4vw, 2rem);
}

.nav-links { gap: clamp(1rem, 2.4vw, 2.5rem); }
.nav-links a { min-height: 40px; display: inline-flex; align-items: center; }
.language-toggle {
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    padding: .45rem .7rem;
    color: var(--primary);
    background: #edf8f4;
    border: 1px solid #cce9df;
    border-radius: 9px;
    font: inherit;
    font-size: .76rem;
    font-weight: 800;
    cursor: pointer;
    white-space: nowrap;
}

.glass-card {
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgb(15 23 42 / .05);
}

.table-container {
    margin-top: .75rem;
    border-radius: var(--radius-md);
    scrollbar-width: thin;
}

th { padding: .7rem .85rem; }
td { padding: .8rem .85rem; }

button, a, select, input { touch-action: manipulation; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible {
    outline: 3px solid rgb(5 150 105 / .25);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.command-centre { padding-top: 1rem; }
.dashboard-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    padding: .65rem 0 1rem;
}
.dashboard-heading h1 { font-size: clamp(1.8rem, 3vw, 2.45rem); line-height: 1.1; letter-spacing: -.035em; }
.dashboard-heading p { color: var(--text-muted); margin-top: .35rem; }
.dashboard-heading-actions { display: flex; align-items: center; gap: .75rem; flex-shrink: 0; }
.eyebrow { display: block; color: var(--primary); font-size: .66rem; font-weight: 800; letter-spacing: .12em; margin-bottom: .25rem; }

.stat-strip {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .75rem;
    margin-bottom: .9rem;
}
.stat-tile {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: .85rem 1rem;
    color: var(--text-main);
    text-decoration: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 2px 7px rgb(15 23 42 / .04);
    transition: border-color .2s, transform .2s;
}
.stat-tile:hover { border-color: #9bd8c4; transform: translateY(-1px); }
.stat-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 10px;
    background: #e9f8f2;
    color: var(--primary);
}
.stat-icon.amber { color: #b45309; background: #fff5df; }
.stat-icon.blue { color: #2563eb; background: #eaf1ff; }
.stat-tile span:nth-child(2) { min-width: 0; display: flex; flex-direction: column; }
.stat-tile small { color: var(--text-muted); font-size: .7rem; }
.stat-tile strong { font-size: 1.1rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-arrow { color: #a0aec0; font-size: .7rem; margin-left: auto; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: .9rem; align-items: start; }
.primary-workspace, .quick-panel, .sync-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: 0 2px 8px rgb(15 23 42 / .04);
}
.primary-workspace { min-width: 0; padding: 1rem; }
.side-workspace { display: grid; gap: .9rem; }
.quick-panel, .sync-panel { padding: 1rem; }
.section-heading { min-height: 46px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.section-heading h2, .sync-heading h2 { font-size: 1.15rem; line-height: 1.15; }
.section-heading.compact { min-height: 38px; }
.section-actions { display: flex; align-items: center; gap: .9rem; }
.section-actions select { width: auto; min-width: 132px; padding: .45rem 2rem .45rem .7rem; font-weight: 700; color: var(--primary); }
.text-link { color: var(--primary); text-decoration: none; font-size: .8rem; font-weight: 700; white-space: nowrap; }
.results-panel { max-height: 600px; overflow: auto; }
#latest-results-table { font-size: .8rem; }
#latest-results-table thead { position: sticky; top: 0; z-index: 2; }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; margin-top: .55rem; }
.quick-grid a {
    min-height: 66px;
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .65rem;
    color: var(--text-main);
    text-decoration: none;
    background: var(--surface-muted);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
}
.quick-grid a:hover { color: var(--primary); border-color: #bce5d7; background: #f0faf6; }
.quick-grid i { width: 28px; height: 28px; display: grid; place-items: center; color: var(--primary); background: white; border-radius: 7px; }
.quick-grid span { font-size: .78rem; font-weight: 700; line-height: 1.2; }
.quick-grid small { display: block; color: var(--text-muted); font-size: .61rem; font-weight: 500; margin-top: .15rem; }
.sync-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; }
.sync-panel > p { color: var(--text-muted); font-size: .78rem; margin: .55rem 0 .7rem; }
.sync-button { width: 100%; padding: .65rem; }
.sync-progress { margin-bottom: .75rem; }
.sync-progress > div:first-child { display: flex; justify-content: space-between; font-size: .68rem; margin-bottom: .35rem; }
.progress-track { height: 5px; background: var(--border); border-radius: 10px; overflow: hidden; }
#progress-bar { width: 0; height: 100%; background: var(--primary); transition: width .3s; }
.live-feed-compact { max-height: 132px; overflow-y: auto; margin-top: .7rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-muted); }
.live-feed-compact > div { color: var(--text-muted); font-size: .72rem; text-align: center; padding: .75rem; }

.mobile-tabbar, .mobile-full-menu { display: none; }

@media (max-width: 1024px) {
    .workspace-grid { grid-template-columns: minmax(0, 1fr) 290px; }
    .brand span { max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .nav-links { gap: .8rem; }
}

@media (max-width: 820px) {
    /*
     * Mobile navigation layout
     * EN: Keep the compact navigation at the top on phones and reserve its
     *     height in the document flow.  This prevents it from covering the
     *     language switch, calendar controls, or the first page heading.
     * 繁中：手機版導覽列固定在最上方，並在頁面預留相同高度，避免遮住
     *       中英文切換、賽期表日期及頁面第一行內容。
     */
    :root { --mobile-tabbar-height: 76px; }
    body {
        padding-top: calc(var(--mobile-tabbar-height) + env(safe-area-inset-top));
        padding-bottom: env(safe-area-inset-bottom);
    }
    nav { position: relative; top: auto; align-items: flex-start; min-height: 58px; overflow: hidden; }
    .brand { min-height: 40px; font-size: 1rem; }
    .nav-links {
        max-width: 58vw;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        gap: .35rem;
        padding-bottom: .25rem;
        scrollbar-width: none;
    }
    .nav-links::-webkit-scrollbar { display: none; }
    .language-toggle { min-width: 44px; min-height: 40px; padding: .45rem; }
    .language-toggle i { display: none; }
    .nav-links > a, .dropdown > a { min-height: 40px; padding: .4rem .6rem; white-space: nowrap; border-radius: 8px; background: var(--surface-muted); }
    .dropdown .dropbtn { min-height: 40px; padding: .4rem .6rem; }
    .mega-nav-headings { gap:.35rem; }
    .mega-nav-headings > a { min-height:40px; display:inline-flex; align-items:center; padding:.4rem .6rem; white-space:nowrap; border-radius:8px; background:var(--surface-muted); }
    .dropdown-content { position: fixed; top: calc(var(--mobile-tabbar-height) + 58px + env(safe-area-inset-top)); left: .75rem; right: .75rem; min-width: 0; max-height: calc(100vh - 150px); overflow-y: auto; border-radius: 10px; background: white; }
    .dropdown:hover .dropdown-content { display: none !important; }
    .dropdown.is-open .dropdown-content { display: block !important; }
    .racingapp-main-nav .dropdown:hover > .mega-dropdown { display:none !important; }
    .racingapp-main-nav .dropdown.is-open > .mega-dropdown { display:grid !important; grid-template-columns:1fr; }
    .mega-menu-column + .mega-menu-column { border-left:0; }
    .dropdown-content a { min-height: 46px; }

    .container { padding: 1rem; }
    .dashboard-heading { align-items: center; }
    .dashboard-heading-actions .status-badge { display: none; }
    .stat-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .workspace-grid { grid-template-columns: 1fr; }
    .side-workspace { grid-template-columns: 1fr 1fr; }
    .mobile-tabbar {
        position: fixed;
        z-index: 1200;
        left: 0;
        right: 0;
        top: 0;
        bottom: auto;
        height: calc(var(--mobile-tabbar-height) + env(safe-area-inset-top));
        padding: env(safe-area-inset-top) max(8px, env(safe-area-inset-left)) 6px max(8px, env(safe-area-inset-right));
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        background: rgb(255 255 255 / .96);
        border-top: 1px solid var(--border);
        box-shadow: 0 -6px 20px rgb(15 23 42 / .08);
        backdrop-filter: blur(12px);
    }
    .mobile-tabbar a, .mobile-tabbar button { min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding:0; border:0; color: var(--text-muted); background:transparent; text-decoration: none; font:inherit; font-size: .62rem; font-weight: 700; }
    .mobile-tabbar a i, .mobile-tabbar button i { font-size: 1rem; }
    .mobile-tabbar a.active, .mobile-tabbar button[aria-expanded="true"] { color: var(--primary); }
    body.mobile-menu-open { overflow:hidden; }
    .mobile-full-menu:not([hidden]) { position:fixed; z-index:1300; inset:0; display:block; }
    .mobile-menu-backdrop { position:absolute; inset:0; width:100%; border:0; background:rgb(15 23 42 / .48); backdrop-filter:blur(2px); }
    .mobile-menu-sheet { position:absolute; left:0; right:0; bottom:0; max-height:min(82vh,720px); overflow-y:auto; padding:.8rem .85rem calc(1rem + env(safe-area-inset-bottom)); border-radius:18px 18px 0 0; background:#fff; box-shadow:0 -16px 40px rgb(15 23 42 / .2); }
    .mobile-menu-sheet>header { position:sticky; z-index:2; top:-.8rem; display:flex; justify-content:space-between; align-items:center; gap:1rem; margin:-.8rem -.85rem .7rem; padding:.85rem; border-bottom:1px solid var(--border); background:rgb(255 255 255 / .96); backdrop-filter:blur(12px); }
    .mobile-menu-sheet>header span,.mobile-menu-sheet>header strong { display:block; }.mobile-menu-sheet>header span { color:var(--primary); font-size:.72rem; font-weight:850; }.mobile-menu-sheet>header strong { margin-top:.12rem; font-size:.6rem; color:var(--text-muted); }
    .mobile-menu-close { width:38px; height:38px; border:1px solid var(--border); border-radius:50%; background:var(--surface-muted); color:var(--text-main); }
    .mobile-menu-group { margin-top:.75rem; }.mobile-menu-group h2 { margin:0 0 .38rem; color:var(--text-muted); font-size:.62rem; letter-spacing:.08em; text-transform:uppercase; }
    .mobile-menu-group>div { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.4rem; }
    .mobile-menu-group a { min-width:0; min-height:46px; display:flex; align-items:center; gap:.55rem; padding:.58rem .65rem; border:1px solid var(--border); border-radius:10px; background:var(--surface-muted); color:var(--text-main); text-decoration:none; font-size:.72rem; font-weight:700; line-height:1.2; }
    .mobile-menu-group a i { width:20px; color:var(--primary); text-align:center; }.mobile-menu-group a.active { border-color:#86efac; background:#f0fdf4; color:var(--primary); }
    .mobile-account-group a { background:#ecfdf5; }
}

@media (max-width: 620px) {
    .brand span { display: none; }
    .nav-links { max-width: calc(100vw - 122px); }
    .dashboard-heading { padding-top: .25rem; }
    .dashboard-heading h1 { font-size: 1.6rem; }
    .dashboard-heading p { font-size: .78rem; }
    .dashboard-heading-actions .btn { min-width: 44px; padding: .7rem; font-size: 0; }
    .dashboard-heading-actions .btn i { font-size: 1rem; }
    .stat-strip { gap: .45rem; }
    .stat-tile { flex-direction: column; align-items: flex-start; gap: .35rem; padding: .65rem; }
    .stat-icon { width: 30px; height: 30px; border-radius: 8px; font-size: .78rem; }
    .stat-arrow { display: none; }
    .stat-tile small { font-size: .62rem; }
    .stat-tile strong { font-size: .86rem; }
    .primary-workspace, .quick-panel, .sync-panel { border-radius: 10px; }
    .primary-workspace { padding: .75rem; }
    .section-heading { align-items: flex-start; }
    .section-actions { gap: .55rem; }
    .section-actions select { min-width: 115px; max-width: 132px; font-size: .72rem; }
    .text-link { font-size: 0; }
    .text-link i { font-size: .8rem; padding: .6rem; border: 1px solid var(--border); border-radius: 8px; }
    .side-workspace { grid-template-columns: 1fr; }

    #latest-results-table thead { display: none; }
    #latest-results-table, #latest-results-table tbody, #latest-results-table tr, #latest-results-table td { display: block; width: 100%; }
    #latest-results-table tr { padding: .7rem; border-bottom: 1px solid var(--border); }
    #latest-results-table tr:last-child { border-bottom: 0; }
    #latest-results-table td { display: grid; grid-template-columns: 74px 1fr; gap: .6rem; padding: .3rem 0; border: 0; white-space: normal; }
    #latest-results-table td::before { color: var(--text-muted); font-size: .65rem; font-weight: 800; text-transform: uppercase; }
    #latest-results-table td:nth-child(1)::before { content: '日期'; }
    #latest-results-table td:nth-child(2)::before { content: '場地'; }
    #latest-results-table td:nth-child(3)::before { content: '場次'; }
    #latest-results-table td:nth-child(4)::before { content: '前三名'; }
    #latest-results-table td:nth-child(5)::before { content: '賽事資料'; }
    #latest-results-table td:nth-child(6)::before { content: '場地 / 騎練'; }
    .results-panel { max-height: none; overflow: visible; }

    .dashboard-grid { grid-template-columns: 1fr !important; gap: .75rem; }
    .hero { padding: 1.5rem 1rem 1rem; margin-bottom: 1rem; }
    .hero h1 { font-size: 2rem; }
    .race-header-bar { overflow-x: auto; white-space: nowrap; gap: .75rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Administrator authentication */
.auth-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(145deg, #f7faf9, #edf5f2) !important; }
.auth-shell { width: min(440px, calc(100% - 2rem)); padding: 2rem 0; }
.auth-back { display: inline-block; margin-bottom: 1rem; color: var(--text-muted); text-decoration: none; font-size: .82rem; font-weight: 600; }
.auth-card { padding: clamp(1.4rem, 5vw, 2.2rem); background: white; border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 20px 45px rgb(15 23 42 / .09); }
.auth-mark { width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 1.25rem; color: white; background: var(--primary); border-radius: 13px; font-weight: 900; }
.auth-card h1 { font-size: 1.65rem; letter-spacing: -.03em; }
.auth-card > p:not(.eyebrow) { margin: .4rem 0 1.35rem; color: var(--text-muted); font-size: .85rem; }
.auth-card label { margin-top: .9rem; }
.auth-card input { min-height: 46px; }
.auth-card button[type="submit"] { width: 100%; min-height: 46px; margin-top: 1.2rem; }
.auth-help { margin-top: .45rem; color: var(--text-muted); font-size: .72rem; }
.auth-error { margin-top: 1rem; padding: .7rem; color: #b42318; background: #fff1f0; border: 1px solid #ffc9c5; border-radius: 8px; font-size: .78rem; }
.auth-notice { margin: 0 0 1rem; padding: .7rem; color: #075985; background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 8px; font-size: .78rem; line-height: 1.5; }
.auth-switch { margin-top: 1.15rem; padding-top: 1rem; border-top: 1px solid var(--border); color: var(--text-muted); text-align: center; font-size: .78rem; }
.auth-switch a { color: var(--primary); font-weight: 750; text-decoration: none; }
.auth-honeypot { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; overflow: hidden !important; }
.auth-signout { width: 100%; min-height: 42px; margin-top: .7rem; border: 1px solid var(--border); border-radius: 10px; color: #475569; background: #f8fafc; font-weight: 700; cursor: pointer; }
.admin-session-bar { position: sticky; top: 0; z-index: 1500; min-height: 54px; display: flex; align-items: center; justify-content: flex-end; gap: .8rem; padding: .45rem clamp(1rem, 3vw, 2rem); color: var(--text-main); background: #f0faf6; border-bottom: 1px solid #cce9df; }
.admin-session-bar span { display: flex; flex-direction: column; text-align: right; line-height: 1.2; }
.admin-session-bar small { color: var(--text-muted); font-size: .65rem; }
.admin-session-bar .btn { padding: .45rem .7rem; font-size: .72rem; }

/* Racing logic stays on Hong Kong time; visitors also see their detected device timezone. */
.racingapp-dual-clock { display: flex; justify-content: flex-end; align-items: center; gap: .3rem; max-width: 1400px; margin: .28rem auto 0; padding: 0 1.25rem; }
.racingapp-dual-clock > div { min-width: 0; display:flex; align-items:baseline; gap:.28rem; padding: .22rem .38rem; border: 1px solid var(--border); border-radius: .42rem; background: rgba(255,255,255,.94); }
.racingapp-dual-clock span,.racingapp-dual-clock strong,.racingapp-dual-clock small { display: inline; white-space:nowrap; }
.racingapp-dual-clock span { color: var(--text-muted); font-size: .48rem; font-weight: 800; text-transform: uppercase; letter-spacing: .025em; }
.racingapp-dual-clock strong { color: var(--text-main); font-size: .64rem; font-variant-numeric: tabular-nums; }
.racingapp-dual-clock small { color: var(--text-muted); font-size: .46rem; }
.clock-visibility-toggle { min-width:28px; min-height:28px; display:inline-flex; align-items:center; justify-content:center; gap:.25rem; padding:.22rem .4rem; border:1px solid var(--border); border-radius:.42rem; background:#fff; color:var(--text-muted); cursor:pointer; font-size:.5rem; }
.clock-visibility-toggle:hover { color:var(--primary); border-color:var(--primary); }
.racingapp-dual-clock.is-hidden { margin-top:.18rem; }
.racingapp-dual-clock.is-hidden > div { display:none; }
.racingapp-dual-clock.is-hidden .clock-visibility-toggle span { display:none; }
.racingapp-dual-clock.is-admin-clock { min-height: 30px; margin-top: .12rem; padding-right: 1rem; }
.racingapp-dual-clock.is-admin-clock.is-hidden { min-height: 30px; margin-bottom: 0; }
.racingapp-dual-clock.is-admin-clock .clock-visibility-toggle { min-width: 26px; min-height: 26px; padding: .16rem .34rem; }
@media (max-width: 600px) {
    .racingapp-dual-clock { justify-content: flex-end; flex-wrap:wrap; gap: .25rem; margin-top: .22rem; padding: 0 .6rem; }
    .racingapp-dual-clock > div { flex:0 1 auto; padding:.2rem .3rem; }
    .racingapp-dual-clock > div span,.racingapp-dual-clock small { display:none; }
    .racingapp-dual-clock strong { font-size: .58rem; }
    .racingapp-dual-clock small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .clock-visibility-toggle span { display:none; }
}

/* ------------------------------------------------------------------
 * Menu entries for pages that are specified but not built yet.
 * app-shell.js renders these as <span class="nav-soon"> instead of <a>,
 * so the intended structure is visible without shipping a link that 404s.
 * They must match the real menu items' box in both the desktop dropdown
 * and the two-column mobile drawer, otherwise an unstyled inline span
 * collapses the grid cell.
 * 未建好的頁面以 <span class="nav-soon"> 呈現，令選單結構完整但不可點擊。
 * 桌面選單及手機兩欄抽屜都必須與正式項目同一尺寸，否則未設樣式的 inline
 * span 會令格線塌陷。
 * ------------------------------------------------------------------ */
.nav-soon {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: .72;
}
.nav-soon::after {
  content: '即將推出';
  margin-left: auto;
  padding-left: .5rem;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
  opacity: .85;
}
html[lang="en"] .nav-soon::after { content: 'Soon'; }
.dropdown-content .nav-soon { width: 100%; min-height: 42px; padding: .5rem .9rem; }
.mobile-menu-group .nav-soon {
  min-width: 0;
  min-height: 46px;
  gap: .55rem;
  padding: .58rem .65rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.2;
}
@media (max-width: 820px) {
  .dropdown-content .nav-soon { min-height: 46px; }
}

/* ------------------------------------------------------------------
 * Desktop dropdown widths, resized for the 2026-08-21 menu labels.
 * The per-menu widths above were set for the old short names; several
 * entries are now much longer (分析賽馬數據搵贏馬嘅共通特徵, 外部 AI 設定管理模型),
 * and the two new groups had no rule at all. On mobile .dropdown-content is
 * position:fixed and full width, so only the desktop sizes need this.
 * 桌面選單寬度按 2026-08-21 的新名稱調整；手機版選單為固定定位滿寬，不受影響。
 * ------------------------------------------------------------------ */
.common-nav-dropdown .dropdown-content { min-width: 250px; }
.history-nav-dropdown .dropdown-content { min-width: 290px; }
.fixtures-nav-dropdown .dropdown-content { min-width: 175px; }
.admin-nav-dropdown .dropdown-content { min-width: 190px; }

/* Long Chinese labels must wrap inside the two-column mobile drawer rather
 * than overflow their cell. / 手機抽屜為兩欄格線，長標籤需換行而非溢出。 */
.mobile-menu-group a,
.mobile-menu-group .nav-soon { overflow-wrap: anywhere; }
