/* PM Dashboard — server-rendered pages (login, legacy) — 2026 design system */

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

/* ---- Design tokens ---- */
:root {
    /* Backgrounds */
    --color-bg:           #0a0a0b;
    --color-card:         rgba(255, 255, 255, 0.03);
    --color-card-hover:   rgba(255, 255, 255, 0.06);

    /* Borders */
    --color-border:       rgba(255, 255, 255, 0.06);
    --color-border-strong: rgba(255, 255, 255, 0.12);

    /* Text hierarchy */
    --color-text:           #f0f0f0;
    --color-text-secondary: rgba(255, 255, 255, 0.5);
    --color-text-tertiary:  rgba(255, 255, 255, 0.3);
    --color-text-muted:     rgba(255, 255, 255, 0.15);

    /* Semantic status */
    --color-green:   #10b981;
    --color-red:     #ef4444;
    --color-yellow:  #f59e0b;
    --color-blue:    #3b82f6;

    /* Typography */
    --font-heading: 'Space Grotesk', system-ui, sans-serif;
    --font-body:    'Inter', system-ui, -apple-system, sans-serif;
    --font-mono:    'JetBrains Mono', 'SF Mono', 'Cascadia Code', monospace;

    /* Layout */
    --nav-height: 56px;
}

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

/* ---- Base ---- */
body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    padding-bottom: calc(var(--nav-height) + 16px);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }

/* ---- Animations ---- */
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes pulseGlow {
    0%, 100% { opacity: 0.4; }
    50%       { opacity: 1; }
}
@keyframes priceFlash {
    0%   { background-color: rgba(16, 185, 129, 0.25); }
    100% { background-color: transparent; }
}

/* ---- Top nav ---- */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    height: var(--nav-height);
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.top-nav .brand {
    font-weight: 700;
    font-size: 15px;
    font-family: var(--font-heading);
    letter-spacing: -0.02em;
}

.top-nav-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ---- Bottom tab bar ---- */
.nav-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: rgba(10, 10, 11, 0.95);
    border-top: 1px solid var(--color-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    z-index: 100;
}

.nav-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    flex: 1;
    text-decoration: none;
    color: var(--color-text-tertiary);
    font-size: 10px;
    font-weight: 500;
    gap: 3px;
    letter-spacing: 0.04em;
    transition: color 0.2s ease;
}

.nav-tab .tab-icon { font-size: 20px; }
.nav-tab:hover, .nav-tab.active {
    color: var(--color-green);
    text-decoration: none;
}

/* ---- Page container ---- */
.page {
    padding: 24px 20px;
    max-width: 1200px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease both;
}

/* ---- Card grid ---- */
.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 20px 24px;
    transition: background 0.2s ease, border-color 0.2s ease;
    animation: fadeUp 0.35s ease both;
}

.card:hover {
    background: var(--color-card-hover);
    border-color: var(--color-border-strong);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.card-title {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-tertiary);
    font-family: var(--font-body);
}

.card-timestamp {
    font-size: 11px;
    color: var(--color-text-tertiary);
}

.card-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
    font-family: var(--font-heading);
    letter-spacing: -0.02em;
}

.card-label {
    font-size: 12px;
    color: var(--color-text-secondary);
}

.card-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 14px;
}

.card-row:last-child { border-bottom: none; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 20px;
    border: 1px solid var(--color-border-strong);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    font-family: var(--font-body);
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.05);
    white-space: nowrap;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.09);
    border-color: rgba(255, 255, 255, 0.2);
}

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

.btn-sm {
    min-height: 36px;
    padding: 6px 14px;
    font-size: 13px;
}

.btn-danger {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.35);
    color: var(--color-red);
}
.btn-danger:hover {
    background: rgba(239, 68, 68, 0.18);
    border-color: rgba(239, 68, 68, 0.65);
    box-shadow: 0 0 12px rgba(239, 68, 68, 0.12);
}

.btn-success {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.4);
    color: var(--color-green);
}
.btn-success:hover {
    background: rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.7);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.15);
}

.btn-warning {
    background: rgba(245, 158, 11, 0.1);
    border-color: rgba(245, 158, 11, 0.35);
    color: var(--color-yellow);
}
.btn-warning:hover {
    background: rgba(245, 158, 11, 0.18);
    border-color: rgba(245, 158, 11, 0.65);
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.12);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--color-border-strong);
    color: var(--color-text);
}
.btn-outline:hover {
    background: rgba(255, 255, 255, 0.06);
}

/* ---- Color utility classes ---- */
.text-green     { color: var(--color-green); }
.text-red       { color: var(--color-red); }
.text-yellow    { color: var(--color-yellow); }
.text-secondary { color: var(--color-text-secondary); }

/* ---- Badges ---- */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.badge-green  { background: rgba(16, 185, 129, 0.12); color: var(--color-green); }
.badge-red    { background: rgba(239, 68, 68, 0.12);  color: var(--color-red); }
.badge-yellow { background: rgba(245, 158, 11, 0.12); color: var(--color-yellow); }
.badge-gray   { background: rgba(255, 255, 255, 0.06); color: var(--color-text-secondary); }

/* ---- Status indicators ---- */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    flex-shrink: 0;
}

.status-dot.alive {
    background: var(--color-green);
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
    animation: pulseGlow 2.5s ease-in-out infinite;
}

.status-dot.dead {
    background: var(--color-red);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
}

/* ---- Tables ---- */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
    border-radius: 12px;
    border: 1px solid var(--color-border);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    background: rgba(255, 255, 255, 0.02);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-text-tertiary);
    border-bottom: 1px solid var(--color-border-strong);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    font-family: var(--font-body);
    transition: color 0.15s ease;
}

th:hover { color: var(--color-text-secondary); }
th .sort-arrow { margin-left: 4px; font-size: 10px; opacity: 0.6; }

td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    white-space: nowrap;
}

tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.02); }
tbody tr:hover { background: rgba(255, 255, 255, 0.04); }

.totals-row td {
    font-weight: 700;
    border-top: 1px solid var(--color-border-strong);
    background: rgba(255, 255, 255, 0.03);
}

/* ---- Countdown timers ---- */
.timer-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.timer-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
}

.timer-value {
    font-size: 22px;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: -0.02em;
}

.timer-label {
    font-size: 11px;
    color: var(--color-text-secondary);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 500;
}

.timer-last {
    font-size: 10px;
    color: var(--color-text-tertiary);
    margin-top: 2px;
}

/* ---- Price flash ---- */
.price-flash {
    animation: priceFlash 1s ease-out;
}

/* ---- Log stream ---- */
.log-container {
    background: #000;
    border: 1px solid var(--color-border);
    border-radius: 10px;
    height: calc(100vh - var(--nav-height) - 120px);
    overflow-y: auto;
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    line-height: 1.5;
}

.log-line { padding: 1px 4px; word-break: break-all; white-space: pre-wrap; }
.log-INFO  { color: var(--color-text); }
.log-WARN  { color: var(--color-yellow); }
.log-ERROR { color: var(--color-red); }
.log-DEBUG { color: var(--color-text-tertiary); }
.log-OTHER { color: var(--color-text); }

.log-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.log-filter {
    flex: 1;
    min-width: 200px;
    padding: 8px 12px;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-text);
    font-size: 14px;
    min-height: 44px;
}

.log-status {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--color-text-secondary);
}

/* ---- Forms and inputs ---- */
input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--color-border-strong);
    border-radius: 8px;
    padding: 10px 14px;
    color: var(--color-text);
    font-size: 14px;
    font-family: var(--font-body);
    width: 100%;
    min-height: 44px;
    transition: border-color 0.2s ease, background 0.2s ease;
}

input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--color-blue);
    outline-offset: 1px;
    border-color: transparent;
    background: rgba(255, 255, 255, 0.06);
}

.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.68rem;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

/* ---- Chips ---- */
.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    overflow-x: auto;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--color-border-strong);
    border-radius: 20px;
    font-size: 12px;
    font-family: var(--font-mono);
}

.chip .remove-btn {
    cursor: pointer;
    color: var(--color-red);
    font-weight: bold;
    min-width: 18px;
    min-height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.15s ease;
}

.chip .remove-btn:hover { opacity: 1; }

/* ---- Modal ---- */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
    background: #111113;
    border: 1px solid var(--color-border-strong);
    border-radius: 16px;
    padding: 28px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    animation: fadeUp 0.2s ease both;
}

.modal h3 { margin-bottom: 14px; font-size: 17px; font-family: var(--font-heading); letter-spacing: -0.01em; }
.modal-actions { display: flex; gap: 12px; justify-content: center; margin-top: 22px; }
.modal-actions .btn { flex: 1; }

/* ---- Connection banner ---- */
.connection-banner {
    display: none;
    background: rgba(239, 68, 68, 0.15);
    border-bottom: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--color-red);
    text-align: center;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
}

.connection-banner.active { display: block; }

/* ---- Pending command banner ---- */
.pending-banner {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    color: var(--color-yellow);
    margin-bottom: 14px;
}

/* ---- Filter bar ---- */
.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 14px;
    align-items: center;
}

.filter-bar select, .filter-bar input {
    flex: 1;
    min-width: 120px;
}

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

.login-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--color-border-strong);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    animation: fadeUp 0.4s ease both;
}

.login-card h1 {
    font-size: 26px;
    font-family: var(--font-heading);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 28px;
    text-align: center;
    color: var(--color-text);
}

.login-error {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: var(--color-red);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 18px;
    text-align: center;
}

/* ---- Pagination ---- */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
}

/* ---- Chart containers ---- */
.chart-container {
    position: relative;
    max-width: 100%;
    overflow-x: auto;
    margin-bottom: 16px;
}

.chart-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-secondary);
    font-size: 14px;
}

/* ---- Heatmap table ---- */
.heatmap td {
    text-align: center;
    min-width: 40px;
    padding: 6px 4px;
    font-size: 11px;
    font-weight: 600;
}

.heatmap-positive { background: rgba(16, 185, 129, 0.2);  color: var(--color-green); }
.heatmap-negative { background: rgba(239, 68, 68, 0.2);   color: var(--color-red); }
.heatmap-none     { background: rgba(255, 255, 255, 0.04); color: var(--color-text-secondary); }

/* ---- Section header ---- */
.section-header {
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-heading);
    letter-spacing: -0.01em;
    margin: 28px 0 14px 0;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-border);
}

/* ---- Activity log ---- */
.activity-table {
    font-size: 12px;
}

/* ---- Responsive ---- */
@media (min-width: 768px) {
    .card-grid    { grid-template-columns: repeat(2, 1fr); }
    .timer-grid   { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1280px) {
    .card-grid  { grid-template-columns: repeat(3, 1fr); }
    .page       { max-width: 1200px; }
}
