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

:root {
    --bg: #0a0a12;
    --bg-card: #12121f;
    --bg-alt: #181830;
    --border: #1e1e3a;
    --text: #e0e0f0;
    --muted: #7878a0;
    --accent: #6366f1;
    --accent-l: #818cf8;
    --green: #ef4444;       /* 台股紅漲 */
    --green-dim: rgba(239, 68, 68, .12);
    --red: #22c55e;         /* 台股綠跌 */
    --red-dim: rgba(34, 197, 94, .12);
    --gold: #f59e0b;
    --gold-dim: rgba(245, 158, 11, .1);
    --cyan: #06b6d4;
    --purple: #a855f7;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Inter', sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* ── Layout ─────────────────────────────────────────────────────────────── */
.layout { display: flex; height: 100vh; }

.sidebar {
    width: 220px;
    min-width: 220px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 0 20px 20px;
    font-weight: 700;
    font-size: 16px;
    color: var(--accent);
    border-bottom: 1px solid var(--border);
    letter-spacing: .02em;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--muted);
    text-decoration: none;
    transition: background .15s, color .15s;
    font-size: 13px;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.nav-item:hover { background: var(--bg-alt); color: var(--text); }
.nav-item.active { background: var(--bg-alt); color: var(--text); border-left-color: var(--accent); }

.main-content { flex: 1; overflow-y: auto; padding: 24px 28px; }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
}

.card-title {
    font-weight: 600;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 16px;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.page-title { font-size: 20px; font-weight: 700; margin-bottom: 20px; }

/* ── Grids ──────────────────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

/* ── Metric tiles ───────────────────────────────────────────────────────── */
.metric { background: var(--bg-alt); border-radius: 6px; padding: 14px 16px; }
.metric-label { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.metric-value { font-size: 22px; font-weight: 700; }
.metric-value.pos { color: var(--green); }
.metric-value.neg { color: var(--red); }

/* ── Tables ─────────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 600; letter-spacing: .06em; }
td { color: var(--text); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-alt); }

.ticker-link {
    color: var(--accent-l);
    text-decoration: none;
    border-bottom: 1px dashed var(--accent);
    transition: color 0.2s, border-bottom-style 0.2s;
}

.ticker-link:hover {
    color: var(--accent);
    border-bottom-style: solid;
}

.tag-pos { color: var(--green); }
.tag-neg { color: var(--red); }
.tag-warn { color: var(--gold); }

/* ── Login ──────────────────────────────────────────────────────────────── */
.login-wrap { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 36px 40px;
    width: 340px;
}
.login-box h1 { font-size: 18px; font-weight: 700; margin-bottom: 24px; color: var(--accent); }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.form-group input, .form-group select {
    width: 100%;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color .15s;
}
.form-group input:focus, .form-group select:focus { border-color: var(--accent); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    font-family: inherit;
    transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-l); }
.btn:not(.btn-primary):hover { background: var(--bg-alt); color: var(--text); }

/* ── Alerts ─────────────────────────────────────────────────────────────── */
.alert {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-size: 13px;
}
.alert-warn { background: var(--gold-dim); border: 1px solid var(--gold); color: var(--gold); }
.alert-danger { background: var(--red-dim); border: 1px solid var(--red); color: var(--red); }
.alert-ok { background: var(--green-dim); border: 1px solid var(--green); color: var(--green); }

/* ── Login Slider ───────────────────────────────────────────────────────── */
.slider-container {
    width: 100%;
    height: 40px;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 6px;
    position: relative;
    overflow: hidden;
    margin-top: 16px;
    margin-bottom: 12px;
}
.slider-bg {
    position: absolute;
    top: 0; left: 0; height: 100%; width: 0;
    background: var(--green-dim);
    transition: width 0.1s;
}
.slider-text {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; color: var(--muted);
    user-select: none;
    z-index: 1;
}
.slider-btn {
    position: absolute;
    top: 0; left: 0; width: 40px; height: 100%;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    z-index: 2;
    transition: left 0.1s, background 0.2s;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}
.slider-btn:hover { background: var(--bg-alt); }
.slider-container.success .slider-btn { cursor: default; }
.slider-container.success .slider-bg { background: var(--green); opacity: 0.2; }
.slider-container.success .slider-text { color: var(--green); font-weight: 600; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Misc ───────────────────────────────────────────────────────────────── */
.loading { color: var(--muted); font-size: 13px; padding: 20px 0; }
.error-msg { color: var(--red); font-size: 13px; margin-top: 8px; }
.muted { color: var(--muted); }

.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.page-btn {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border);
    background: var(--bg-alt);
    color: var(--muted);
    transition: background .15s;
}
.page-btn.active, .page-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}
.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
    font-size: 13px;
    margin-bottom: 4px;
}
.sidebar-footer a:last-child {
    margin-bottom: 0;
}
.sidebar-footer a:hover {
    background: var(--bg-alt);
    color: var(--text);
}

/* ── Modals ─────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 1000;
    opacity: 0; pointer-events: none;
    transition: opacity 0.2s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 400px;
    max-width: 90vw;
    padding: 24px;
    transform: translateY(-20px);
    transition: transform 0.2s;
}
.modal-overlay.active .modal-content { transform: translateY(0); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 16px; font-weight: 700; color: var(--text); }
.modal-close { cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; transition: color 0.2s; border: none; background: transparent; }
.modal-close:hover { color: var(--text); }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }


