/* ================================================================
   SGCP Terminal — terminal.css
   Brand: Deep Racing Green #0F2E23 | Charcoal Black #1A1A1A
   ================================================================ */

/* ── Google Fonts ─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Custom Properties ────────────────────────────────────── */
:root {
    /* SGCP Brand */
    --sgcp-green:        #0F2E23;
    --sgcp-green-mid:    #1A4A36;
    --sgcp-green-light:  #2A6B4F;
    --sgcp-black:        #1A1A1A;
    --sgcp-grey:         #B7B7B7;
    --sgcp-light:        #F4F4F2;
    --sgcp-steel:        #6F7478;

    /* Typography */
    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;

    /* Radius */
    --r-xs: 3px;
    --r-sm: 5px;
    --r-md: 8px;
    --r-lg: 12px;

    /* Layout */
    --topbar-h:   52px;
    --sidebar-w:  230px;
}

/* ── Dark Mode (default) ──────────────────────────────────────── */
html, html[data-theme="dark"] {
    --term-bg:             #060d09;
    --term-sidebar-bg:     #0F2E23;
    --term-sidebar-hover:  rgba(255,255,255,0.06);
    --term-sidebar-active: rgba(255,255,255,0.12);
    --term-sidebar-text:   #b8d4c0;
    --term-sidebar-muted:  #6a8a74;
    --term-topbar-bg:      #0b2219;
    --term-topbar-text:    #c8e0d0;
    --term-topbar-border:  #1a3d2c;
    --term-card-bg:        #0c1a10;
    --term-card-hover:     #111f14;
    --term-border:         #1a3020;
    --term-text:           #dce8df;
    --term-text-muted:     #8aaa90;
    --term-text-dim:       #5a7060;
    --term-positive:       #4ade80;
    --term-negative:       #f87171;
    --term-neutral:        #94a3b8;
    --term-input-bg:       #0f1d13;
    --term-input-border:   #1e3828;
    --term-scrollbar:      #1e3828;
    --term-scrollbar-thumb:#2a5038;
    --term-shadow:         rgba(0,0,0,0.5);
    --term-chart-grid:     rgba(255,255,255,0.05);
}

/* ── Light Mode ───────────────────────────────────────────────── */
html[data-theme="light"] {
    --term-bg:             #F4F4F2;
    --term-sidebar-bg:     #0F2E23;
    --term-sidebar-hover:  rgba(255,255,255,0.07);
    --term-sidebar-active: rgba(255,255,255,0.13);
    --term-sidebar-text:   #c0d8c6;
    --term-sidebar-muted:  #6a8a74;
    --term-topbar-bg:      #0F2E23;
    --term-topbar-text:    #c8e0d0;
    --term-topbar-border:  #1a3d2c;
    --term-card-bg:        #ffffff;
    --term-card-hover:     #f9f9f7;
    --term-border:         #dededd;
    --term-text:           #1A1A1A;
    --term-text-muted:     #6F7478;
    --term-text-dim:       #B7B7B7;
    --term-positive:       #15803d;
    --term-negative:       #dc2626;
    --term-neutral:        #64748b;
    --term-input-bg:       #ffffff;
    --term-input-border:   #c8c8c6;
    --term-scrollbar:      #e0e0de;
    --term-scrollbar-thumb:#B7B7B7;
    --term-shadow:         rgba(0,0,0,0.08);
    --term-chart-grid:     rgba(0,0,0,0.06);
}

/* ── Global Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }

body {
    font-family: var(--font-sans);
    background: var(--term-bg);
    color: var(--term-text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
}

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--term-scrollbar); }
::-webkit-scrollbar-thumb { background: var(--term-scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--sgcp-green-light); }

/* ================================================================
   TERMINAL LAYOUT
   ================================================================ */
.terminal-wrapper {
    display: grid;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-areas:
        "topbar topbar"
        "sidebar main";
    height: 100vh;
    overflow: hidden;
}

/* ================================================================
   TOP BAR
   ================================================================ */
.term-topbar {
    grid-area: topbar;
    background: var(--term-topbar-bg);
    border-bottom: 1px solid var(--term-topbar-border);
    display: flex;
    align-items: center;
    gap: 0;
    height: var(--topbar-h);
    z-index: 100;
    overflow: hidden;
}

/* Logo block */
.term-logo {
    flex: 0 0 var(--sidebar-w);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    border-right: 1px solid var(--term-topbar-border);
    height: 100%;
    text-decoration: none;
}

.term-logo-mark {
    width: 28px;
    height: 28px;
    background: var(--sgcp-green-light);
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
    flex-shrink: 0;
}

.term-logo-text {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.term-logo-name {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.08em;
}

.term-logo-sub {
    font-size: 9px;
    font-weight: 400;
    color: var(--term-sidebar-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-top: 2px;
}

/* ── Ticker strip — böser Farb-Streifen ──────────────────────── */
.term-ticker-wrap {
    flex: 1 1 0;
    overflow: hidden;
    height: 100%;
    display: flex;
    align-items: stretch;
    position: relative;
    cursor: default;
}

/* Fade-out edges */
.term-ticker-wrap::before,
.term-ticker-wrap::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    width: 32px;
    z-index: 2;
    pointer-events: none;
}
.term-ticker-wrap::before {
    left: 0;
    background: linear-gradient(to right, var(--term-topbar-bg), transparent);
}
.term-ticker-wrap::after {
    right: 0;
    background: linear-gradient(to left, var(--term-topbar-bg), transparent);
}

.term-ticker-track {
    display: flex;
    align-items: stretch;
    white-space: nowrap;
    animation: ticker-scroll 80s linear infinite;
    will-change: transform;
}

.term-ticker-track:hover { animation-play-state: paused; }

@keyframes ticker-scroll {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-50%); }
}

/* ── Each ticker item: colored block based on direction ── */
.term-ticker-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    height: 100%;
    font-size: 11px;
    font-family: var(--font-mono);
    white-space: nowrap;
    transition: filter 0.15s;
    border-right: 1px solid transparent;
}

.term-ticker-item.pos {
    background: rgba(5, 40, 18, 0.92);
    color: #6ee7a0;
    border-right-color: rgba(74, 222, 128, 0.12);
}

.term-ticker-item.neg {
    background: rgba(50, 10, 10, 0.92);
    color: #fca5a5;
    border-right-color: rgba(248, 113, 113, 0.12);
}

.term-ticker-item.flat {
    background: rgba(20, 28, 22, 0.7);
    color: #94a3b8;
    border-right-color: rgba(148, 163, 184, 0.08);
}

.term-ticker-item:hover { filter: brightness(1.2); }

.term-ticker-name {
    font-weight: 700;
    font-size: 10px;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    opacity: 0.80;
}

.term-ticker-price { font-weight: 500; }

.term-ticker-arrow { font-size: 9px; }

/* Deprecated class names kept for compat */
.term-ticker-change.pos { color: #6ee7a0; }
.term-ticker-change.neg { color: #fca5a5; }
.term-ticker-change.flat { color: #94a3b8; }

/* Top-right controls */
.term-controls {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 14px;
    height: 100%;
    border-left: 1px solid var(--term-topbar-border);
}

.term-ctrl-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background: transparent;
    border: none;
    border-radius: var(--r-sm);
    color: var(--term-topbar-text);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.term-ctrl-btn:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.term-ctrl-btn svg { width: 16px; height: 16px; }

.term-datetime {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 0 8px;
    line-height: 1.2;
}

.term-time {
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font-mono);
    color: #fff;
    letter-spacing: 0.04em;
}

.term-date {
    font-size: 10px;
    color: var(--term-sidebar-muted);
    letter-spacing: 0.03em;
}

/* Theme toggle in topbar */
.term-theme-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.term-theme-input {
    width: 0;
    height: 0;
    visibility: hidden;
    position: absolute;
}

.term-theme-label {
    width: 44px;
    height: 22px;
    display: block;
    position: relative;
    background: rgba(255,255,255,0.12);
    border-radius: 22px;
    cursor: pointer;
    transition: background 0.3s;
}

.term-theme-label::after {
    content: "";
    width: 16px;
    height: 16px;
    position: absolute;
    top: 3px;
    left: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.term-theme-label .t-sun,
.term-theme-label .t-moon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 11px;
    height: 11px;
    z-index: 1;
}

.term-theme-label .t-sun  { left: 5px;  fill: rgba(255,200,50,0.8); }
.term-theme-label .t-moon { right: 5px; fill: rgba(180,200,255,0.7); }

.term-theme-input:checked + .term-theme-label { background: rgba(255,255,255,0.25); }

.term-theme-input:checked + .term-theme-label::after { transform: translateX(22px); }

/* ================================================================
   SIDEBAR
   ================================================================ */
.term-sidebar {
    grid-area: sidebar;
    background: var(--term-sidebar-bg);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid rgba(255,255,255,0.06);
}

.term-sidebar-section {
    padding: 18px 0 8px;
}

.term-sidebar-label {
    padding: 0 16px 8px;
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--term-sidebar-muted);
}

.term-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    text-decoration: none;
    color: var(--term-sidebar-text);
    font-size: 13px;
    font-weight: 400;
    border-radius: 0;
    transition: background 0.12s, color 0.12s;
    border-left: 2px solid transparent;
    position: relative;
}

.term-nav-item:hover {
    background: var(--term-sidebar-hover);
    color: #fff;
    text-decoration: none;
}

.term-nav-item.active {
    background: var(--term-sidebar-active);
    color: #fff;
    border-left-color: var(--sgcp-green-light);
    font-weight: 500;
}

.term-nav-item .nav-icon {
    width: 15px;
    height: 15px;
    opacity: 0.7;
    flex-shrink: 0;
}

.term-nav-item.active .nav-icon { opacity: 1; }

.term-sidebar-divider {
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 6px 14px;
}

.term-sidebar-footer {
    margin-top: auto;
    padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    gap: 8px;
}

.term-user-avatar {
    width: 28px;
    height: 28px;
    background: var(--sgcp-green-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.term-user-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.term-user-name {
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.term-user-role {
    font-size: 10px;
    color: var(--term-sidebar-muted);
}

.term-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: transparent;
    border: none;
    border-radius: var(--r-sm);
    color: var(--term-sidebar-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}

.term-logout-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--term-negative);
}

.term-logout-btn svg { width: 15px; height: 15px; }

/* ================================================================
   MAIN CONTENT
   ================================================================ */
.term-main {
    grid-area: main;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.term-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
}

.term-page-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--term-text);
    margin: 0;
    letter-spacing: -0.01em;
}

.term-page-subtitle {
    font-size: 12px;
    color: var(--term-text-muted);
    margin: 3px 0 0;
}

/* ── Widgets Grid ─────────────────────────────────────────────── */
.widgets-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
    align-items: start;
}

.widgets-grid.two-col {
    grid-template-columns: 1fr 1fr;
}

.widgets-grid.three-col {
    grid-template-columns: 1fr 1fr 1fr;
}

/* ── Card ─────────────────────────────────────────────────────── */
.term-card {
    background: var(--term-card-bg);
    border: 1px solid var(--term-border);
    border-radius: var(--r-md);
    overflow: hidden;
    transition: border-color 0.2s;
}

.term-card:hover { border-color: var(--sgcp-green-mid); }

.term-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--term-border);
}

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

.term-card-body {
    padding: 16px;
}

.term-card-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--term-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* span full columns */
.term-card.span-2 { grid-column: span 2; }
.term-card.span-full { grid-column: 1 / -1; }

/* ── Data Table ───────────────────────────────────────────────── */
.term-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.term-table th {
    text-align: left;
    padding: 6px 10px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--term-text-dim);
    border-bottom: 1px solid var(--term-border);
}

.term-table th.r, .term-table td.r { text-align: right; }

.term-table td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--term-border);
    color: var(--term-text);
    font-family: var(--font-mono);
    font-size: 12px;
}

.term-table td.name-col {
    font-family: var(--font-sans);
    font-weight: 500;
}

.term-table tr:last-child td { border-bottom: none; }
.term-table tr:hover td { background: var(--term-card-hover); }

/* ── Value badges ─────────────────────────────────────────────── */
.val-pos { color: var(--term-positive); }
.val-neg { color: var(--term-negative); }
.val-neu { color: var(--term-neutral); }

.badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono);
}

.badge.pos { background: rgba(74,222,128,0.12); color: var(--term-positive); }
.badge.neg { background: rgba(248,113,113,0.12); color: var(--term-negative); }
.badge.neu { background: rgba(148,163,184,0.12); color: var(--term-neutral); }

/* ── Form elements ────────────────────────────────────────────── */
.term-input {
    width: 100%;
    background: var(--term-input-bg);
    border: 1px solid var(--term-input-border);
    border-radius: var(--r-sm);
    color: var(--term-text);
    font-family: var(--font-sans);
    font-size: 13px;
    padding: 8px 12px;
    outline: none;
    transition: border-color 0.15s;
}

.term-input:focus {
    border-color: var(--sgcp-green-light);
    box-shadow: 0 0 0 3px rgba(42,107,79,0.2);
}

.term-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--term-text-muted);
    margin-bottom: 5px;
}

.term-field { margin-bottom: 14px; }

.term-select {
    appearance: none;
    -webkit-appearance: none;
    background: var(--term-input-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236a8a74' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.term-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--r-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    font-family: var(--font-sans);
    text-decoration: none;
}

.term-btn-primary {
    background: var(--sgcp-green);
    color: #fff;
    border: 1px solid var(--sgcp-green-mid);
}

.term-btn-primary:hover {
    background: var(--sgcp-green-mid);
    color: #fff;
    text-decoration: none;
}

.term-btn-secondary {
    background: transparent;
    color: var(--term-text-muted);
    border: 1px solid var(--term-border);
}

.term-btn-secondary:hover {
    border-color: var(--sgcp-green-mid);
    color: var(--term-text);
    background: var(--term-card-hover);
}

.term-btn svg { width: 14px; height: 14px; }

/* ── Stat tile ────────────────────────────────────────────────── */
.stat-tile {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-tile-label {
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--term-text-dim);
}

.stat-tile-value {
    font-size: 22px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--term-text);
    letter-spacing: -0.02em;
    line-height: 1;
}

.stat-tile-sub {
    font-size: 11px;
    color: var(--term-text-muted);
    font-family: var(--font-mono);
}

/* ── Stat grid ────────────────────────────────────────────────── */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 16px;
}

/* ── Tag ──────────────────────────────────────────────────────── */
.term-tag {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 10.5px;
    font-weight: 600;
    background: rgba(42,107,79,0.15);
    color: var(--term-positive);
    letter-spacing: 0.04em;
}

/* ── Divider ──────────────────────────────────────────────────── */
.term-divider {
    height: 1px;
    background: var(--term-border);
    margin: 16px 0;
}

/* ── Tooltip ──────────────────────────────────────────────────── */
.term-tooltip {
    position: relative;
    cursor: help;
}

.term-tooltip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--sgcp-black);
    color: #fff;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: var(--r-sm);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 200;
}

.term-tooltip:hover::after { opacity: 1; }

/* ── Chart container ──────────────────────────────────────────── */
.chart-container {
    position: relative;
    width: 100%;
}

/* ── Progress bar ─────────────────────────────────────────────── */
.term-progress {
    height: 4px;
    background: var(--term-border);
    border-radius: 2px;
    overflow: hidden;
}

.term-progress-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--sgcp-green-light);
    transition: width 0.4s ease;
}

/* ── Loading skeleton ─────────────────────────────────────────── */
.skeleton {
    background: linear-gradient(90deg,
        var(--term-border) 25%,
        var(--term-card-hover) 50%,
        var(--term-border) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--r-sm);
}

@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ================================================================
   WIKIFOLIO PAGE — two-column master/detail
   ================================================================ */
.wf-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 16px;
    align-items: start;
    min-height: 0;
}

.wf-sidebar {
    position: sticky;
    top: 0;
    background: var(--term-card-bg);
    border: 1px solid var(--term-border);
    border-radius: var(--r-md);
    overflow: hidden;
}

.wf-sidebar-header {
    padding: 12px 14px;
    border-bottom: 1px solid var(--term-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wf-sidebar-list { overflow-y: auto; max-height: 60vh; }

.wf-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.12s;
    border-bottom: 1px solid var(--term-border);
}

.wf-list-item:hover  { background: var(--term-card-hover); }
.wf-list-item.active { border-left-color: var(--sgcp-green-light); background: var(--term-sidebar-active); }

.wf-list-item .wf-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sgcp-green-light);
    flex-shrink: 0;
}

.wf-list-item .wf-name {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--term-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* ── Tabs inside wikifolio detail ────────────────────────────── */
.term-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--term-border);
    margin-bottom: 16px;
}

.term-tab {
    padding: 9px 16px;
    font-size: 12px;
    font-weight: 500;
    color: var(--term-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.12s, border-color 0.12s;
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
}

.term-tab:hover { color: var(--term-text); }
.term-tab.active { color: var(--term-text); border-bottom-color: var(--sgcp-green-light); }

.term-tab-pane { display: none; }
.term-tab-pane.active { display: block; }

/* ── Modal overlay ───────────────────────────────────────────── */
.term-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.65);
    z-index: 400;
    align-items: center;
    justify-content: center;
}

.term-modal-overlay.open { display: flex; }

.term-modal {
    background: var(--term-card-bg);
    border: 1px solid var(--term-border);
    border-radius: var(--r-lg);
    padding: 24px;
    width: 520px;
    max-width: 92vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 24px 64px var(--term-shadow);
}

.term-modal-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 18px;
}

.term-modal-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

/* ================================================================
   COMPANY PLANNER — TODOs & Timeline
   ================================================================ */

/* Priority badge colors */
.prio-critical { background: rgba(248,113,113,0.15); color: #f87171; }
.prio-high     { background: rgba(251,146,60,0.15);  color: #fb923c; }
.prio-medium   { background: rgba(250,204,21,0.15);  color: #fde047; }
.prio-low      { background: rgba(148,163,184,0.15); color: #94a3b8; }

/* Status badge colors */
.stat-open        { background: rgba(148,163,184,0.1); color: var(--term-text-muted); }
.stat-in_progress { background: rgba(59,130,246,0.15); color: #60a5fa; }
.stat-review      { background: rgba(168,85,247,0.15); color: #c084fc; }
.stat-done        { background: rgba(74,222,128,0.12); color: #4ade80; }
.stat-cancelled   { background: rgba(107,114,128,0.1); color: #6b7280; text-decoration: line-through; }

/* TODO card */
.todo-card {
    background: var(--term-card-bg);
    border: 1px solid var(--term-border);
    border-radius: var(--r-md);
    margin-bottom: 8px;
    transition: border-color 0.15s;
}

.todo-card:hover { border-color: var(--sgcp-green-mid); }

.todo-card.done { opacity: 0.55; }

.todo-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
}

.todo-expand-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--term-text-dim);
    transition: transform 0.2s;
}

.todo-card.expanded .todo-expand-icon { transform: rotate(90deg); }

.todo-title {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--term-text);
}

.todo-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.todo-body {
    display: none;
    padding: 0 14px 14px 40px;
    border-top: 1px solid var(--term-border);
}

.todo-card.expanded .todo-body { display: block; }

.todo-description {
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--term-text-muted);
    white-space: pre-wrap;
    margin: 10px 0 12px;
}

/* ── Timeline ─────────────────────────────────────────────────── */
.timeline {
    position: relative;
    padding: 20px 0;
    overflow-x: auto;
}

.timeline-line {
    position: absolute;
    top: 50%;
    left: 20px;
    right: 20px;
    height: 2px;
    background: var(--term-border);
    transform: translateY(-50%);
}

.timeline-track {
    display: flex;
    gap: 0;
    position: relative;
    min-width: max-content;
    padding: 60px 20px;
}

.milestone {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 130px;
    padding: 0 8px;
}

.milestone-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid;
    background: var(--term-bg);
    z-index: 2;
    flex-shrink: 0;
    transition: transform 0.15s;
    cursor: pointer;
}

.milestone:hover .milestone-dot { transform: scale(1.4); }

.milestone-dot.achieved { background: currentColor; }

.milestone-date {
    font-size: 9.5px;
    font-family: var(--font-mono);
    color: var(--term-text-dim);
    margin-top: 8px;
    letter-spacing: 0.04em;
}

.milestone-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--term-text);
    text-align: center;
    max-width: 110px;
    margin-top: 4px;
    line-height: 1.3;
}

.milestone-type-badge {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 99px;
    margin-top: 3px;
    font-weight: 600;
    letter-spacing: 0.04em;
    opacity: 0.8;
}

/* Milestone alternating above/below the line */
.milestone:nth-child(odd)  { flex-direction: column;         padding-top: 0;  }
.milestone:nth-child(even) { flex-direction: column-reverse; padding-bottom: 0; }

/* ================================================================
   LOGIN PAGE
   ================================================================ */
.login-page {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--sgcp-green);
    position: relative;
    overflow: hidden;
}

/* Subtle grid background */
.login-page::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}

.login-card {
    position: relative;
    width: 360px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--r-lg);
    padding: 40px 36px;
    backdrop-filter: blur(12px);
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.login-logo-mark {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.04em;
}

.login-logo-text { display: flex; flex-direction: column; }

.login-brand {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.1em;
}

.login-tagline {
    font-size: 10px;
    color: rgba(255,255,255,0.45);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-top: 2px;
}

.login-heading {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255,255,255,0.6);
    margin-bottom: 20px;
}

.login-field { margin-bottom: 14px; }

.login-label {
    display: block;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.45);
    margin-bottom: 6px;
}

.login-input {
    width: 100%;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--r-sm);
    color: #fff;
    font-size: 14px;
    font-family: var(--font-mono);
    padding: 10px 14px;
    outline: none;
    transition: border-color 0.15s, background 0.15s;
    letter-spacing: 0.08em;
}

.login-input::placeholder { color: rgba(255,255,255,0.2); }

.login-input:focus {
    border-color: rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.09);
}

.login-btn {
    width: 100%;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--r-sm);
    color: #fff;
    font-size: 13.5px;
    font-weight: 600;
    padding: 11px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: var(--font-sans);
    letter-spacing: 0.04em;
    margin-top: 6px;
}

.login-btn:hover {
    background: rgba(255,255,255,0.16);
    border-color: rgba(255,255,255,0.25);
}

.login-btn:active { transform: scale(0.99); }

.login-error {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(248,113,113,0.1);
    border: 1px solid rgba(248,113,113,0.25);
    border-radius: var(--r-sm);
    color: #fca5a5;
    font-size: 12.5px;
    margin-bottom: 14px;
}

.login-footer {
    margin-top: 28px;
    text-align: center;
    font-size: 10.5px;
    color: rgba(255,255,255,0.2);
    letter-spacing: 0.05em;
}

/* ================================================================
   PAGE-SPECIFIC: Utility classes
   ================================================================ */
.p-0  { padding: 0 !important; }
.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-mono { font-family: var(--font-mono); }
.text-muted { color: var(--term-text-muted); }
.text-dim { color: var(--term-text-dim); }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 12px; }

/* ================================================================
   COMPANY PLANNER — Layout & additional classes
   ================================================================ */

.cp-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1rem;
    align-items: start;
}

.cp-main { min-width: 0; }

/* Shared badge base for priority + status */
.prio-badge,
.stat-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .03em;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Icon action buttons inside todo/milestone rows */
.cp-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--term-text-muted);
    padding: 0 .15rem;
    font-size: .85rem;
    line-height: 1;
    transition: color .12s;
}
.cp-icon-btn:hover     { color: var(--term-text); }
.cp-icon-danger        { color: var(--accent-danger, #f87171) !important; }
.cp-icon-danger:hover  { opacity: .8; }

/* Todo body description */
.todo-desc {
    font-size: .84rem;
    line-height: 1.65;
    color: var(--text-secondary, var(--term-text-muted));
    padding-top: .5rem;
    white-space: pre-wrap;
}

/* Milestone vertical list layout */
.milestone-content {
    padding-left: 1rem;
    flex: 1;
    min-width: 0;
}

.milestone-title {
    font-size: .9rem;
    line-height: 1.4;
    margin-bottom: .2rem;
}

.milestone-desc {
    font-size: .8rem;
    color: var(--text-secondary, var(--term-text-muted));
    margin-top: .2rem;
    line-height: 1.5;
}

/* Vertical timeline */
.timeline {
    position: relative;
    padding: .5rem 0;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--term-border, var(--border));
}

.milestone {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .65rem 0 .65rem 0;
    position: relative;
}

.milestone-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid;
    background: var(--term-bg, var(--bg-primary));
    flex-shrink: 0;
    margin-top: .15rem;
    z-index: 1;
    transition: transform .15s;
}

.milestone:hover .milestone-dot { transform: scale(1.25); }

.milestone-dot.achieved  { }
.milestone-dot.delayed   { border-style: dashed; }
.milestone-dot.cancelled { opacity: .4; }

.milestone-date {
    font-size: .75rem;
    font-family: var(--font-mono);
    color: var(--term-text-dim, var(--text-muted));
    margin-bottom: .2rem;
}

/* ================================================================
   WIKIFOLIO TRADES — Layout
   ================================================================ */

.wt-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 1rem;
    align-items: start;
}

.wt-main { min-width: 0; }

/* Trade form grid */
.wt-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: .75rem;
}

/* Small button variant */
.term-btn-sm {
    padding: 3px 10px;
    font-size: .78rem;
    line-height: 1.5;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 900px) {
    :root {
        --sidebar-w: 0px;
    }
    .term-sidebar { display: none; }
    .terminal-wrapper {
        grid-template-columns: 1fr;
        grid-template-areas:
            "topbar"
            "main";
    }
    .widgets-grid.two-col,
    .widgets-grid.three-col { grid-template-columns: 1fr; }
    .term-card.span-2 { grid-column: span 1; }
}
