@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

:root {
    --win-bg:       #c0c0c0;
    --win-dark:     #808080;
    --win-darker:   #404040;
    --win-white:    #ffffff;
    --win-black:    #000000;
    --win-blue:     #000080;
    --win-blue-hi:  #1084d0;
    --win-yellow:   #ffff00;
    --positive:     #006600;
    --negative:     #cc0000;
    --accent:       #000080;
    --body-bg:      #008080;
}

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

/* ── Global font normalization ── */
body, input, select, textarea, button, table, th, td, label, p, h1, h2, h3, h4, h5, h6, span, div, a {
    font-family: 'MS Sans Serif', 'Segoe UI', Tahoma, sans-serif !important;
    font-size: 11px !important;
    line-height: 1.4 !important;
}

h2 { font-size: 13px !important; font-weight: bold !important; margin-bottom: 6px !important; }
h3 { font-size: 12px !important; font-weight: bold !important; margin-bottom: 4px !important; }
h4 { font-size: 11px !important; font-weight: bold !important; margin-bottom: 4px !important; }

.pixel-logo { font-family: 'Press Start 2P', monospace !important; font-size: 8px !important; }

/* All inputs/selects uniform */
input[type="text"], input[type="number"], input[type="email"], input[type="password"], select, textarea {
    padding: 2px 4px !important;
    font-size: 11px !important;
    font-family: 'MS Sans Serif', sans-serif !important;
    border-top: 2px solid #404040 !important;
    border-left: 2px solid #404040 !important;
    border-right: 2px solid #fff !important;
    border-bottom: 2px solid #fff !important;
    background: white !important;
    outline: none !important;
    border-radius: 0 !important;
}
input:focus, select:focus, textarea:focus {
    outline: 1px dotted #000 !important;
    outline-offset: -2px !important;
}

/* All buttons uniform */
button:not(.win-btn):not(.tb-btn):not(.menu-item):not(.watchlist-btn):not(.period-btn) {
    padding: 4px 12px !important;
    font-size: 11px !important;
    font-family: 'MS Sans Serif', sans-serif !important;
    background: var(--win-bg) !important;
    border-top: 2px solid #fff !important;
    border-left: 2px solid #fff !important;
    border-right: 2px solid #404040 !important;
    border-bottom: 2px solid #404040 !important;
    border-radius: 0 !important;
    cursor: default !important;
    color: #000 !important;
}
button:not(.win-btn):not(.tb-btn):not(.menu-item):not(.watchlist-btn):not(.period-btn):active {
    border-top: 2px solid #404040 !important;
    border-left: 2px solid #404040 !important;
    border-right: 2px solid #fff !important;
    border-bottom: 2px solid #fff !important;
}
button:not(.win-btn):not(.tb-btn):not(.menu-item):disabled {
    color: #808080 !important;
    text-shadow: 1px 1px 0 #ffffff !important;
    cursor: not-allowed !important;
}
.tb-btn:disabled {
    color: #808080 !important;
    text-shadow: 1px 1px 0 #ffffff !important;
    cursor: not-allowed !important;
}

::-webkit-scrollbar { width: 16px; height: 16px; }
::-webkit-scrollbar-track { background: var(--win-bg); }
::-webkit-scrollbar-thumb {
    background: var(--win-bg);
    border-top: 2px solid var(--win-white);
    border-left: 2px solid var(--win-white);
    border-right: 2px solid var(--win-darker);
    border-bottom: 2px solid var(--win-darker);
}

body {
    font-family: 'MS Sans Serif', 'Segoe UI', Tahoma, sans-serif;
    font-size: 11px;
    background: var(--body-bg);
    color: var(--win-black);
    min-height: 100vh;
    padding: 8px;
}

/* ── Window ── */
.window {
    background: var(--win-bg);
    border-top: 2px solid var(--win-white);
    border-left: 2px solid var(--win-white);
    border-right: 2px solid var(--win-darker);
    border-bottom: 2px solid var(--win-darker);
    box-shadow: 2px 2px 0 var(--win-black);
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 16px);
    height: calc(100vh - 16px);
}

/* ── Title bar ── */
.title-bar {
    background: linear-gradient(90deg, var(--win-blue) 0%, var(--win-blue-hi) 100%);
    color: white;
    padding: 1px 4px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: bold;
    font-size: 11px;
    user-select: none;
    flex-shrink: 0;
}

.title-bar-text {
    display: flex;
    align-items: center;
    gap: 6px;
}

.title-bar-icon {
    width: 16px; height: 16px;
    background: var(--win-yellow);
    border: 1px solid var(--win-black);
    display: flex; align-items: center; justify-content: center;
    font-size: 10px; font-weight: bold; color: var(--win-black);
}

.radar-logo-icon {
    width: 20px; height: 20px;
    display: block;
    flex-shrink: 0;
    border: 1px solid;
    border-color: #808080 #ffffff #ffffff #808080;
}

.pixel-logo {
    font-family: 'Press Start 2P', monospace;
    font-size: 8px;
    color: white;
    letter-spacing: 0.5px;
}

.title-bar-controls { display: flex; gap: 2px; }

.win-btn {
    width: 18px; height: 18px;
    background: var(--win-bg);
    border-top: 2px solid var(--win-white);
    border-left: 2px solid var(--win-white);
    border-right: 2px solid var(--win-darker);
    border-bottom: 2px solid var(--win-darker);
    box-shadow: 1px 1px 0 #000;
    font-size: 10px; cursor: default;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; color: var(--win-black);
    flex-shrink: 0;
}
.win-btn:active {
    border-top: 2px solid var(--win-darker);
    border-left: 2px solid var(--win-darker);
    border-right: 2px solid var(--win-white);
    border-bottom: 2px solid var(--win-white);
}

/* ── Menu bar (Win98 TabControl) ── */
.menu-bar {
    background: var(--win-bg);
    border-bottom: 2px solid var(--win-dark);
    padding: 2px 4px 0;
    display: flex;
    gap: 0;
    flex-shrink: 0;
    align-items: flex-end;
}

.menu-item {
    padding: 3px 10px;
    cursor: default;
    font-size: 11px;
    background: var(--win-bg);
    border-top: 2px solid var(--win-white);
    border-left: 2px solid var(--win-white);
    border-right: 2px solid var(--win-darker);
    border-bottom: none;
    text-decoration: none;
    color: var(--win-black);
    font-family: 'MS Sans Serif', 'Segoe UI', sans-serif;
    margin-right: 2px;
    margin-top: 3px;
    margin-bottom: -2px;
    position: relative;
}
.menu-item:hover {
    background: var(--win-blue);
    color: white;
}
.menu-item.active {
    background: #ffffff;
    border-top: 2px solid var(--win-white);
    border-left: 2px solid var(--win-white);
    border-right: 2px solid var(--win-darker);
    border-bottom: 2px solid #ffffff;
    color: var(--win-black);
    font-weight: bold;
    margin-top: 0;
    z-index: 1;
}

/* ── Toolbar ── */
.toolbar {
    background: var(--win-bg);
    border-bottom: 2px solid var(--win-dark);
    padding: 4px 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.toolbar-sep {
    width: 2px; height: 22px;
    border-left: 1px solid var(--win-dark);
    border-right: 1px solid var(--win-white);
    margin: 0 2px;
}

.tb-btn {
    padding: 3px 10px;
    background: var(--win-bg);
    border-top: 2px solid var(--win-white);
    border-left: 2px solid var(--win-white);
    border-right: 2px solid var(--win-darker);
    border-bottom: 2px solid var(--win-darker);
    font-size: 11px; cursor: default;
    font-family: 'MS Sans Serif', 'Segoe UI', sans-serif;
    white-space: nowrap;
}
.tb-btn:active {
    border-top: 2px solid var(--win-darker);
    border-left: 2px solid var(--win-darker);
    border-right: 2px solid var(--win-white);
    border-bottom: 2px solid var(--win-white);
    padding: 4px 9px 2px 11px;
}

.tb-input {
    padding: 2px 4px;
    border-top: 2px solid var(--win-darker);
    border-left: 2px solid var(--win-darker);
    border-right: 2px solid var(--win-white);
    border-bottom: 2px solid var(--win-white);
    background: white;
    font-family: 'MS Sans Serif', 'Segoe UI', sans-serif;
    font-size: 11px; outline: none;
}
.tb-input:focus { outline: 1px dotted var(--win-black); outline-offset: -2px; }

.tb-select {
    padding: 2px 4px;
    border-top: 2px solid var(--win-darker);
    border-left: 2px solid var(--win-darker);
    border-right: 2px solid var(--win-white);
    border-bottom: 2px solid var(--win-white);
    background: white;
    font-family: 'MS Sans Serif', 'Segoe UI', sans-serif;
    font-size: 11px; outline: none; cursor: pointer;
}

.tb-label {
    font-size: 11px;
    display: flex; align-items: center; gap: 4px;
    cursor: pointer; white-space: nowrap;
    font-family: 'MS Sans Serif', 'Segoe UI', sans-serif;
}
.tb-label input[type="checkbox"] { width: 13px; height: 13px; cursor: pointer; }

/* ── Content area ── */
.content-area {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 4px;
}

/* ── Inset panel (sunken box) ── */
.inset-panel {
    border-top: 2px solid var(--win-darker);
    border-left: 2px solid var(--win-darker);
    border-right: 2px solid var(--win-white);
    border-bottom: 2px solid var(--win-white);
    background: white;
    overflow: auto;
    flex: 1;
}

/* ── Table ── */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    font-family: 'MS Sans Serif', 'Segoe UI', sans-serif;
}

.data-table th {
    background: var(--win-bg);
    border-top: 2px solid var(--win-white);
    border-left: 2px solid var(--win-white);
    border-right: 2px solid var(--win-darker);
    border-bottom: 2px solid var(--win-darker);
    padding: 3px 8px;
    text-align: left;
    font-weight: bold;
    font-size: 11px;
    white-space: nowrap;
    position: sticky; top: 0; z-index: 10;
    cursor: pointer; user-select: none;
}
.data-table th:hover { background: #d4d4d4; }
.data-table th:active,
.data-table th.sorted {
    border-top: 2px solid var(--win-darker);
    border-left: 2px solid var(--win-darker);
    border-right: 2px solid var(--win-white);
    border-bottom: 2px solid var(--win-white);
    background: #b8b8b8;
}

.data-table td {
    padding: 2px 8px;
    border-bottom: 1px solid #c0c0c0;
    border-right: 1px solid #e0e0e0;
    white-space: nowrap;
}

.data-table tbody tr:nth-child(even) td { background: #ffffff; }
.data-table tbody tr:nth-child(odd) td { background: #f0f0f0; }
.data-table tbody tr:hover { background: var(--win-blue); }
.data-table tbody tr:hover td { background: var(--win-blue) !important; color: white !important; }
.data-table tbody tr:hover .rate-positive { color: #90ff90 !important; }
.data-table tbody tr:hover .rate-negative { color: #ffaaaa !important; }
.data-table tbody tr:hover .spread-cell   { color: var(--win-yellow) !important; }
.data-table tbody tr:hover .apy-cell      { color: var(--win-yellow) !important; }
.data-table tbody tr:hover .symbol-cell   { background: var(--win-blue) !important; color: white !important; }

.rate-positive { color: var(--positive); font-weight: bold; }
.rate-negative { color: var(--negative); }
.spread-cell   { font-weight: bold; color: var(--accent); }
.apy-cell      { font-weight: bold; color: var(--positive); }

.symbol-cell {
    font-weight: bold;
    position: sticky; left: 0;
    background: inherit; z-index: 5;
}

.arb-pair { font-size: 10px; color: #555; }
.symbol-link { color: inherit; text-decoration: none; }
.symbol-link:hover { text-decoration: underline; }
.hold-link { color: var(--accent); text-decoration: none; }
.hold-link:hover { text-decoration: underline; }
.exchange-col { min-width: 80px; }
.exchange-col.hidden { display: none; }

.watchlist-btn {
    background: var(--win-bg);
    border-top: 2px solid var(--win-white);
    border-left: 2px solid var(--win-white);
    border-right: 2px solid var(--win-darker);
    border-bottom: 2px solid var(--win-darker);
    outline: none; cursor: default;
    font-size: 13px; color: #bbb; padding: 0 3px;
    line-height: 1;
}
.watchlist-btn:focus { outline: none; }
.watchlist-btn:hover { color: #e8a000; }
.watchlist-btn.active { color: #ffd700; }

.loading { padding: 20px; text-align: center; font-size: 11px; color: #555; }
.error   { padding: 20px; text-align: center; font-size: 11px; color: var(--negative); }

/* ── Status bar ── */
.status-bar {
    border-top: 2px solid var(--win-dark);
    background: var(--win-bg);
    padding: 2px 4px;
    display: flex; gap: 4px; align-items: center;
    flex-shrink: 0;
}

.status-panel {
    border-top: 1px solid #808080;
    border-left: 1px solid #808080;
    border-right: 1px solid #ffffff;
    border-bottom: 1px solid #ffffff;
    padding: 1px 6px;
    font-size: 11px;
    min-width: 80px;
}
.status-panel.wide { flex: 1; }

.status-dot-retro {
    width: 8px; height: 8px;
    background: #00aa00;
    border: 1px solid var(--win-darker);
    display: inline-block;
    margin-right: 4px;
    vertical-align: middle;
}
.status-dot-retro.error { background: #cc0000; }

/* ── Group box (Win98 groove = fieldset style) ── */
.groupbox {
    border: 2px groove #808080;
    padding: 10px 8px 8px;
    margin: 8px 0 6px;
    position: relative;
}
.groupbox-label {
    position: absolute;
    top: -8px; left: 8px;
    background: var(--win-bg);
    padding: 0 4px;
    font-size: 11px; font-weight: bold;
}

/* ── Win98 flat label/badge ── */
.win98-label-badge {
    display: inline-block;
    border-top: 1px solid var(--win-darker);
    border-left: 1px solid var(--win-darker);
    border-right: 1px solid var(--win-white);
    border-bottom: 1px solid var(--win-white);
    background: var(--win-bg);
    padding: 1px 5px;
    font-size: 10px;
    font-weight: bold;
}

/* ── Language button (RU/EN) ── */
.lang-btn {
    padding: 2px 7px;
    background: var(--win-bg);
    border-top: 2px solid var(--win-white);
    border-left: 2px solid var(--win-white);
    border-right: 2px solid var(--win-darker);
    border-bottom: 2px solid var(--win-darker);
    font-size: 10px;
    font-weight: bold;
    cursor: pointer;
    align-self: center;
    margin-left: auto;
    flex-shrink: 0;
}
.lang-btn:active {
    border-top: 2px solid var(--win-darker);
    border-left: 2px solid var(--win-darker);
    border-right: 2px solid var(--win-white);
    border-bottom: 2px solid var(--win-white);
}

/* ── Raised panel (для карточек в Win98 стиле) ── */
.win98-panel {
    background: var(--win-bg);
    border-top: 2px solid var(--win-white);
    border-left: 2px solid var(--win-white);
    border-right: 2px solid var(--win-darker);
    border-bottom: 2px solid var(--win-darker);
}
/* Sunken/inset panel */
.win98-inset {
    border-top: 2px solid var(--win-darker);
    border-left: 2px solid var(--win-darker);
    border-right: 2px solid var(--win-white);
    border-bottom: 2px solid var(--win-white);
    background: white;
}

/* ── Buttons ── */
.btn-win {
    padding: 4px 16px;
    background: var(--win-bg);
    border-top: 2px solid var(--win-white);
    border-left: 2px solid var(--win-white);
    border-right: 2px solid var(--win-darker);
    border-bottom: 2px solid var(--win-darker);
    font-size: 11px; cursor: default;
    font-family: 'MS Sans Serif', 'Segoe UI', sans-serif;
    min-width: 80px;
}
.btn-win:active {
    border-top: 2px solid var(--win-darker);
    border-left: 2px solid var(--win-darker);
    border-right: 2px solid var(--win-white);
    border-bottom: 2px solid var(--win-white);
    padding: 5px 15px 3px 17px;
}
.btn-win:focus { outline: 1px dotted black; outline-offset: -4px; }
.btn-win.primary { font-weight: bold; }

/* ── Input fields ── */
.win-input {
    padding: 2px 4px;
    border-top: 2px solid var(--win-darker);
    border-left: 2px solid var(--win-darker);
    border-right: 2px solid var(--win-white);
    border-bottom: 2px solid var(--win-white);
    background: white;
    font-family: 'MS Sans Serif', 'Segoe UI', sans-serif;
    font-size: 11px; outline: none; width: 100%;
}
.win-input:focus { outline: 1px dotted var(--win-black); outline-offset: -2px; }

.win-label { font-size: 11px; margin-bottom: 2px; display: block; }

/* ── Progress bar ── */
.win-progress {
    border-top: 2px solid var(--win-darker);
    border-left: 2px solid var(--win-darker);
    border-right: 2px solid var(--win-white);
    border-bottom: 2px solid var(--win-white);
    background: white; height: 18px; overflow: hidden;
}
.win-progress-bar {
    height: 100%;
    background: repeating-linear-gradient(90deg, var(--win-blue) 0px, var(--win-blue) 14px, transparent 14px, transparent 16px);
    transition: width 0.3s;
}

/* ── Tabs ── */
.win-tabs {
    display: flex; gap: 0; margin-bottom: -1px; position: relative; z-index: 1;
}
.win-tab {
    padding: 4px 14px;
    background: var(--win-bg);
    border-top: 2px solid var(--win-white);
    border-left: 2px solid var(--win-white);
    border-right: 2px solid var(--win-darker);
    border-bottom: 1px solid var(--win-dark);
    cursor: pointer; font-size: 11px;
    margin-right: 2px;
    text-decoration: none; color: var(--win-black);
}
.win-tab.active {
    background: var(--win-bg);
    border-bottom: 2px solid var(--win-bg);
    padding-bottom: 5px;
    font-weight: bold;
}
.win-tab-content {
    border: 2px solid;
    border-top-color: var(--win-dark);
    border-left-color: var(--win-white);
    border-right-color: var(--win-darker);
    border-bottom-color: var(--win-darker);
    padding: 8px;
    background: var(--win-bg);
}


/* ── Footer as Win98 StatusBar ── */
.footer {
    border-top: 2px solid var(--win-dark);
    background: var(--win-bg);
    padding: 2px 8px;
    font-size: 10px;
    color: #555;
    flex-shrink: 0;
}
.footer p { margin: 0; padding: 1px 6px; border-top: 1px solid var(--win-dark); border-left: 1px solid var(--win-dark); border-right: 1px solid var(--win-white); border-bottom: 1px solid var(--win-white); display: inline-block; }

/* ── Period buttons (backtester) ── */
.period-btn {
    padding: 2px 8px;
    background: var(--win-bg);
    border-top: 2px solid var(--win-white);
    border-left: 2px solid var(--win-white);
    border-right: 2px solid var(--win-darker);
    border-bottom: 2px solid var(--win-darker);
    font-size: 11px; cursor: default;
    font-family: 'MS Sans Serif', sans-serif;
    white-space: nowrap;
}
.period-btn.active {
    border-top: 2px solid var(--win-darker);
    border-left: 2px solid var(--win-darker);
    border-right: 2px solid var(--win-white);
    border-bottom: 2px solid var(--win-white);
    background: #c0c0c0;
    font-weight: bold;
    box-shadow: inset 2px 2px 4px rgba(0,0,0,0.3);
    padding: 3px 7px 1px 9px;
}
.period-btn:active {
    border-top: 2px solid var(--win-darker);
    border-left: 2px solid var(--win-darker);
    border-right: 2px solid var(--win-white);
    border-bottom: 2px solid var(--win-white);
}

/* ── Stat cards (backtester results) ── */
.stat-card {
    background: var(--win-bg);
    border-top: 2px solid var(--win-white);
    border-left: 2px solid var(--win-white);
    border-right: 2px solid var(--win-darker);
    border-bottom: 2px solid var(--win-darker);
    padding: 5px 8px;
    min-width: 90px;
}
.stat-card .label { font-size: 10px; color: #555; }
.stat-card .value { font-size: 13px; font-weight: 700; margin-top: 2px; }
.stat-card .value.positive { color: var(--positive); }
.stat-card .value.negative { color: var(--negative); }

/* ── MessageBox (Win98 info box) ── */
.win98-msgbox {
    background: var(--win-bg);
    border-top: 2px solid var(--win-white);
    border-left: 2px solid var(--win-white);
    border-right: 2px solid var(--win-darker);
    border-bottom: 2px solid var(--win-darker);
    padding: 16px 20px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    max-width: 420px;
    margin: 40px auto;
}
.win98-msgbox-icon { font-size: 28px; flex-shrink: 0; }
.win98-msgbox-text { font-size: 11px; line-height: 1.7; }

/* ── Mobile base (all pages) ── */
@media (max-width: 768px) {
    body { padding: 2px; overflow-x: hidden; -webkit-overflow-scrolling: touch; }
    .window { height: auto !important; min-height: calc(100vh - 4px); }

    /* Prevent iOS auto-zoom on input focus */
    input[type="text"], input[type="number"], input[type="email"],
    input[type="password"], select, textarea { font-size: 16px !important; }

    /* Title bar */
    .title-bar-controls { display: none; }
    .pixel-logo { font-size: 6px !important; letter-spacing: 0 !important; }

    /* Menu: horizontal scroll, no scrollbar */
    .menu-bar { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch;
                scrollbar-width: none; }
    .menu-bar::-webkit-scrollbar { display: none; }
    .menu-item { white-space: nowrap; flex-shrink: 0; min-height: 28px;
                 padding: 4px 10px; font-size: 12px !important; }

    /* Toolbar */
    .toolbar { flex-wrap: wrap; gap: 4px; padding: 4px; }
    .tb-btn { min-height: 28px; font-size: 12px !important; }
    .tb-input { min-height: 28px; font-size: 16px !important; }
    .tb-select { min-height: 28px; font-size: 16px !important; }

    /* Status bar — hide on mobile */
    .status-bar { display: none; }

    /* Scrollable content */
    .content-area, main { -webkit-overflow-scrolling: touch; }

    /* Native scrollbar (prettier on mobile) */
    ::-webkit-scrollbar { width: 0; height: 0; }
}
