/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --color-bg:           #f4f5f7;
    --color-surface:      #ffffff;
    --color-border:       #e1e4e8;
    --color-header-bg:    #1a2b4a;
    --color-header-text:  #ffffff;
    --color-nav-active:   #4a9eff;
    --color-text:         #24292e;
    --color-text-muted:   #6a737d;
    --color-row-alt:      #f6f8fa;
    --color-green:        #28a745;
    --color-yellow:       #ffc107;
    --color-red:          #dc3545;
    --color-link:         #0366d6;
    --radius:             6px;
    --font:               -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono:          'SFMono-Regular', Consolas, monospace;
}

html, body {
    font-family: var(--font);
    font-size: 13px;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.4;
}

a { color: var(--color-link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Site header / nav ────────────────────────────────────────────────────── */
.site-header {
    background: var(--color-header-bg);
    color: var(--color-header-text);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
}

.header-inner {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 20px;
    height: 48px;
    display: flex;
    align-items: center;
    gap: 32px;
}

.site-title {
    font-size: 15px;
    font-weight: 600;
    white-space: nowrap;
    color: #fff;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.main-nav a {
    color: rgba(255,255,255,.75);
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    transition: background .15s, color .15s;
}

.main-nav a:hover,
.main-nav a.active {
    background: rgba(255,255,255,.12);
    color: #fff;
    text-decoration: none;
}

.main-nav a.nav-download { margin-left: auto; }
.main-nav a.nav-logout   { color: rgba(255,255,255,.55); font-size: 12px; }

/* ── Staging styles ───────────────────────────────────────────────────────── */
.site-header-staging { background: #7b0000; }

.staging-badge {
    display: inline-block;
    background: #ff0000;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
    vertical-align: middle;
    letter-spacing: .05em;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%   { opacity: 1; }
    50%  { opacity: 0.6; }
    100% { opacity: 1; }
}

.nav-divider {
    color: rgba(255,255,255,.3);
    margin: 0 4px;
    font-size: 13px;
}

.main-nav a.nav-staging {
    color: #ffaaaa;
}

.main-nav a.nav-staging:hover,
.main-nav a.nav-staging.active {
    background: rgba(255,100,100,.2);
    color: #ffdddd;
}

/* ── Promote button ───────────────────────────────────────────────────────── */
.promote-bar {
    background: #7b0000;
    color: #fff;
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 12px;
}

.promote-bar .promote-info { flex: 1; opacity: .8; }

.btn-promote {
    background: #ff0000;
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: var(--radius);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: .03em;
}
.btn-promote:hover { background: #cc0000; }

/* ── Page wrapper ─────────────────────────────────────────────────────────── */
.page-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 30px 20px 0 20px;
    overflow: hidden;
}

.page-title {
    font-size: 20px;
    font-weight: 600;
    margin-top: 0;
    margin-bottom: 2px;
}

.page-subtitle {
    color: var(--color-text-muted);
    font-size: 12px;
    margin-bottom: 8px;
}

/* ── Dashboard table ──────────────────────────────────────────────────────── */
.dash-table-wrap {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.dash-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    white-space: nowrap;
}

.dash-table thead {
    position: relative;
    z-index: 20;
}

.dash-table th {
    background: var(--color-header-bg);
    color: rgba(255,255,255,.9);
    font-weight: 500;
    padding: 8px 10px;
    text-align: center;
    border-right: none;
    height: 42px;
    vertical-align: bottom;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.3;
}

.dash-table th.th-left {
    text-align: left;
    position: sticky;
    left: 0;
    z-index: 30;
}

.dash-table th a {
    color: rgba(255,255,255,.9);
    display: block;
}
.dash-table th a:hover { color: #fff; text-decoration: none; }

.dash-table td {
    padding: 6px 10px;
    text-align: right;
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

.dash-table td.td-name {
    text-align: left;
    font-weight: 500;
    min-width: 160px;
    position: sticky;
    left: 0;
    z-index: 10;
    background: inherit;
}

.dash-table td.td-center { text-align: center; }

.dash-table tbody tr:nth-child(odd)  { background: var(--color-surface); }
.dash-table tbody tr:nth-child(even) { background: var(--color-row-alt); }
.dash-table tbody tr:hover           { background: #eaf3ff; }

/* Group header rows */
.dash-table tr.group-header th {
    background: #2c3e6b;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 5px 10px;
}

/* ── Traffic lights ───────────────────────────────────────────────────────── */
.light {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    vertical-align: middle;
    cursor: pointer;
}
.light-green  { background: var(--color-green);  box-shadow: 0 0 4px rgba(40,167,69,.5); }
.light-yellow { background: var(--color-yellow); box-shadow: 0 0 4px rgba(255,193,7,.5); }
.light-red    { background: var(--color-red);    box-shadow: 0 0 4px rgba(220,53,69,.5); }
.light-none   { background: var(--color-border); }

/* ── Values ───────────────────────────────────────────────────────────────── */
.val-pos  { color: var(--color-green); }
.val-neg  { color: var(--color-red); }
.val-warn { color: #b38600; }

/* ── Combined stoplight + value cell ──────────────────────────────────────── */
.td-light {
    text-align: left;
    white-space: nowrap;
    padding: 6px 10px;
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}
.td-light .light {
    vertical-align: middle;
    margin-right: 4px;
}

/* ── Modal / popup ────────────────────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 500;
    align-items: center;
    justify-content: center;
}
.modal-overlay.open { display: flex; }

.modal-box {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,.3);
    padding: 16px;
    max-width: 95vw;
    max-height: 90vh;
    overflow: auto;
    position: relative;
}

.modal-close {
    position: absolute;
    top: 10px; right: 14px;
    font-size: 20px;
    cursor: pointer;
    color: var(--color-text-muted);
    line-height: 1;
    border: none;
    background: none;
}
.modal-close:hover { color: var(--color-text); }

.modal-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-right: 24px;
}

.modal-chart { display: block; }

/* ── Property detail popup ────────────────────────────────────────────────── */
.prop-detail { font-size: 13px; line-height: 1.8; }
.prop-detail strong { display: block; font-size: 15px; margin-bottom: 8px; }

/* ── Tight padding for light+value pairs ──────────────────────────────────── */
.dash-table td.td-light-pair {
    text-align: center;
    padding: 6px 2px 6px 10px;
    border-right: none;
}
.dash-table td.td-val-pair {
    text-align: left;
    padding: 6px 4px 6px 3px;
}

/* Blended borders for light+value pairs — handled by td-light-pair class */
.dash-table tbody tr:nth-child(odd)  td.td-light-pair { border-right-color: var(--color-surface); }
.dash-table tbody tr:nth-child(even) td.td-light-pair { border-right-color: var(--color-row-alt); }
.dash-table tbody tr:hover           td.td-light-pair { border-right-color: #eaf3ff; }
th.sorted-asc  a::after { content: ' ▲'; }
th.sorted-desc a::after { content: ' ▼'; }

/* ── Login page ───────────────────────────────────────────────────────────── */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-header-bg);
}

.login-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 36px 40px;
    width: 360px;
    box-shadow: 0 4px 24px rgba(0,0,0,.25);
}

.login-card h1 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 24px;
    color: var(--color-header-bg);
}

.login-card label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: 4px;
    margin-top: 14px;
}

.login-card input[type=text],
.login-card input[type=password] {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
}

.login-card input:focus {
    outline: none;
    border-color: var(--color-nav-active);
    box-shadow: 0 0 0 3px rgba(74,158,255,.2);
}

.login-card button {
    width: 100%;
    margin-top: 20px;
    padding: 10px;
    background: var(--color-header-bg);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}
.login-card button:hover { background: #243d6a; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-top: 12px;
}
.alert-error   { background: #ffeef0; color: #b31d28; border: 1px solid #f9c0c5; }
.alert-warning { background: #fffbdd; color: #735c0f; border: 1px solid #ffe58f; }
.alert-success { background: #e6f4ea; color: #1e7e34; border: 1px solid #a8d5b0; }
