/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:       #0d0d1a;
    --bg2:      #141428;
    --bg3:      #1c1c38;
    --border:   #2a2a4a;
    --accent:   #4fc3f7;
    --accent2:  #7c4dff;
    --accent3:  #00e5ff;
    --text:     #e0e0f0;
    --text-dim: #7a7a9a;
    --green:    #00e676;
    --red:      #ff4444;
    --orange:   #ffab40;
    --magenta:  #ff4dff;
    --cyan:     #5AF7CE;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 14px;
    min-height: 100vh;
}

/* ===== HEADER ===== */
.site-header {
    background: linear-gradient(135deg, #0d0d2b 0%, #1a0a3a 100%);
    border-bottom: 1px solid var(--border);
    padding: 18px 30px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.site-header .logo { font-size: 28px; }
.site-header h1 {
    font-size: 22px;
    font-weight: 700;
    background: linear-gradient(90deg, var(--accent3), var(--accent2));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.site-header .sub {
    font-size: 12px;
    color: var(--text-dim);
    margin-left: auto;
}

/* ===== LAYOUT ===== */
.container { max-width: 1400px; margin: 0 auto; padding: 30px 20px; }

/* ===== UPLOAD ===== */
.upload-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px;
    max-width: 580px;
    margin: 60px auto;
    text-align: center;
}
.upload-card .icon { font-size: 56px; margin-bottom: 16px; }
.upload-card h2 { font-size: 20px; margin-bottom: 8px; color: var(--accent3); }
.upload-card p  { color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }

.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 30px 20px;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    position: relative;
    margin-bottom: 20px;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--accent);
    background: rgba(79,195,247,.05);
}
.drop-zone input[type=file] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.drop-zone .dz-label { font-size: 15px; color: var(--text-dim); pointer-events: none; }
.drop-zone .dz-label span { color: var(--accent); font-weight: 600; }
.drop-zone .dz-file-name { font-size: 13px; color: var(--green); margin-top: 8px; }

.format-badges {
    display: flex; gap: 10px; justify-content: center; margin-top: 20px;
}
.fmt-badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
}
.fmt-badge.cdt {
    background: rgba(0,229,255,.1); color: var(--accent3);
    border: 1px solid rgba(0,229,255,.3);
}
.fmt-badge.tzx {
    background: rgba(124,77,255,.1); color: var(--accent2);
    border: 1px solid rgba(124,77,255,.3);
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    background: linear-gradient(135deg, var(--accent2), var(--accent));
    color: #fff; border: none; border-radius: 8px;
    padding: 12px 28px; font-size: 15px; font-weight: 600;
    cursor: pointer; transition: opacity .2s, transform .1s;
}
.btn:hover { opacity: .9; transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: translateY(0); }
.btn-sm { padding: 7px 16px; font-size: 13px; }

.error-msg {
    background: rgba(255,68,68,.1); border: 1px solid var(--red);
    color: var(--red); border-radius: 8px; padding: 12px 16px;
    margin-bottom: 20px; font-size: 13px;
}

/* ===== TAPE BANNER ===== */
.tape-banner {
    background: linear-gradient(135deg, var(--bg3), var(--bg2));
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px 22px;
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.tape-banner .tape-icon { font-size: 36px; }
.tape-banner .tape-title { font-size: 16px; font-weight: 700; color: var(--accent3); }
.tape-banner .tape-meta  { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.tape-banner .tape-stats { margin-left: auto; display: flex; gap: 16px; flex-wrap: wrap; }
.stat-badge {
    text-align: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    min-width: 80px;
}
.stat-badge .val { font-size: 18px; font-weight: 700; color: var(--accent); }
.stat-badge .lbl { font-size: 10px; color: var(--text-dim); text-transform: uppercase; }
.new-upload-btn { margin-left: 8px; }

/* ===== TABS ===== */
.tabs-wrapper { margin-bottom: 0; }
.tabs-nav {
    display: flex; gap: 4px;
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
}
.tab-btn {
    background: var(--bg2); color: var(--text-dim);
    border: 1px solid var(--border); border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 10px 22px; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: background .2s, color .2s;
    text-transform: uppercase; letter-spacing: .5px;
    display: flex; align-items: center; gap: 6px;
}
.tab-btn:hover { background: var(--bg3); color: var(--text); }
.tab-btn.active {
    background: var(--bg3); color: var(--accent3);
    border-color: var(--border);
    border-bottom: 2px solid var(--bg3);
    margin-bottom: -2px;
}
.tab-panel {
    display: none;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 10px 10px;
    padding: 24px;
}
.tab-panel.active { display: block; }

/* ===== TABLES ===== */
.data-table {
    width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table th {
    background: var(--bg); color: var(--accent);
    padding: 10px 12px; text-align: left;
    font-weight: 600; border-bottom: 2px solid var(--border);
    text-transform: uppercase; font-size: 11px; letter-spacing: .5px;
}
.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:nth-child(even) td { background: rgba(255,255,255,.02); }
.data-table tr:hover td { background: rgba(79,195,247,.05); }
.data-table td.center { text-align: center; }
.data-table td.right  { text-align: right; }
.data-table td.mono   { font-family: monospace; font-size: 12px; }
.data-table .total-row td {
    background: var(--bg3);
    font-weight: 700;
    color: var(--accent3);
    border-top: 2px solid var(--border);
}

/* ===== BLOCK TYPE COLORS (matching CPC-Power palette) ===== */
.block-type-dot {
    display: inline-block;
    width: 10px; height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    flex-shrink: 0;
    vertical-align: middle;
}
.type16  .block-type-dot, .block-type-dot.type16  { background: #CABEFF; }
.type17  .block-type-dot, .block-type-dot.type17  { background: #BDFFD6; }
.type18  .block-type-dot, .block-type-dot.type18  { background: #5AF7CE; }
.type19  .block-type-dot, .block-type-dot.type19  { background: #5AF3F7; }
.type20  .block-type-dot, .block-type-dot.type20  { background: #C6F75A; }
.type21  .block-type-dot, .block-type-dot.type21  { background: #00C54B; }
.type24  .block-type-dot, .block-type-dot.type24  { background: #E0A878; }
.type25  .block-type-dot, .block-type-dot.type25  { background: #E3DCC8; }
.type32  .block-type-dot, .block-type-dot.type32  { background: #FFFFBD; }
.type33  .block-type-dot, .block-type-dot.type33  { background: #F7B25A; }
.type34  .block-type-dot, .block-type-dot.type34  { background: #F7B25A; }
.type43  .block-type-dot, .block-type-dot.type43  { background: #A0CCA0; }
.type48  .block-type-dot, .block-type-dot.type48  { background: #FFFFFF; }
.type49  .block-type-dot, .block-type-dot.type49  { background: #F6DDFD; }
.type50  .block-type-dot, .block-type-dot.type50  { background: #FF8080; }
.type51  .block-type-dot, .block-type-dot.type51  { background: #FFFF80; }

/* Colored row tints */
.type16-row td { background: rgba(202,190,255,.04); }
.type17-row td { background: rgba(189,255,214,.04); }
.type32-row td { background: rgba(255,255,189,.04); }
.type48-row td { background: rgba(255,255,255,.02); }

/* ===== SPEC CARD ===== */
.spec-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.spec-card .card-title {
    display: block;
    background: var(--bg3);
    padding: 10px 16px;
    font-size: 13px; font-weight: 700; color: var(--accent3);
    text-transform: uppercase; letter-spacing: .5px;
    border-bottom: 1px solid var(--border);
}

/* ===== CHECKDATA ===== */
.checkdata-summary {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.cd-total {
    display: flex; align-items: center; justify-content: space-between;
}
.cd-label { font-size: 13px; color: var(--text-dim); }
.cd-value {
    font-size: 20px; font-weight: 700; color: var(--accent3);
    font-family: monospace;
}
.accent-val { color: var(--accent); font-weight: 600; }
.orange-val { color: var(--orange); font-weight: 600; }

/* ===== BLOCK INFO CELLS ===== */
.block-info-cell { font-size: 12px; }
.info-badge {
    display: inline-block;
    padding: 2px 8px; border-radius: 4px;
    font-size: 11px; font-weight: 600;
}
.header-badge {
    background: rgba(0,230,118,.12); color: var(--green);
    border: 1px solid rgba(0,230,118,.3);
}
.data-badge {
    background: rgba(79,195,247,.1); color: var(--accent);
    border: 1px solid rgba(79,195,247,.3);
}
.info-muted { color: var(--text-dim); font-family: monospace; }

.block-link {
    color: var(--accent); font-family: monospace; font-size: 12px;
    text-decoration: none;
}
.block-link:hover { color: var(--accent3); text-decoration: underline; }

/* ===== CATALOGUE ===== */
.cat-entry {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 20px;
}
.cat-header-bar {
    background: var(--bg3);
    padding: 12px 18px;
    display: flex; align-items: center; gap: 12px;
    border-bottom: 1px solid var(--border);
}
.cat-icon { font-size: 20px; }
.cat-filename {
    font-size: 16px; font-weight: 700; color: var(--accent3);
    font-family: monospace;
}
.cat-platform {
    font-size: 11px; color: var(--text-dim); text-transform: uppercase;
    letter-spacing: .5px; margin-left: auto;
}
.cat-type-badge {
    background: rgba(124,77,255,.15); color: var(--accent2);
    border: 1px solid rgba(124,77,255,.3);
    padding: 2px 10px; border-radius: 12px; font-size: 11px; font-weight: 600;
}
.cat-body { padding: 16px 18px; }
.cat-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}
.cat-section { }
.cat-section-title {
    font-size: 11px; font-weight: 700; color: var(--accent);
    text-transform: uppercase; letter-spacing: .5px;
    margin-bottom: 8px;
}
.cat-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.cat-table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.cat-table td:first-child { color: var(--text-dim); width: 55%; }
.cat-table td:last-child  { color: var(--text); font-weight: 500; }
.cat-table tr:last-child td { border-bottom: none; }
.cat-table .mono { font-family: monospace; font-size: 12px; }
.addr-highlight { color: var(--accent3) !important; font-size: 13px !important; }
.bytes-hint { color: var(--text-dim); font-size: 11px; margin-left: 4px; }

/* ===== DATA TAB ===== */
.sdata-toolbar {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 16px; flex-wrap: wrap;
}
.sdata-label { font-size: 13px; color: var(--text-dim); white-space: nowrap; }
#sdata-select {
    background: var(--bg); color: var(--text);
    border: 1px solid var(--border); border-radius: 6px;
    padding: 6px 10px; font-size: 13px; font-family: monospace;
    flex: 1; min-width: 280px; max-width: 600px; cursor: pointer;
}
#sdata-select:focus { outline: 1px solid var(--accent); }

.sdata-panel { display: none !important; }
.sdata-panel.active { display: block !important; }

/* Block meta bar */
.block-meta-bar {
    display: flex; flex-wrap: wrap; gap: 0;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 8px 8px 0 0; border-bottom: none;
    margin-bottom: 0;
    overflow: hidden;
}
.bm-cell {
    flex: 1; min-width: 140px;
    padding: 8px 14px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.bm-cell:last-child { border-right: none; }
.bm-label { font-size: 10px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .3px; display: block; }
.bm-value { font-size: 13px; color: var(--text); font-weight: 500; }

.sdata-warning {
    background: rgba(255,171,64,.1);
    border: 1px solid rgba(255,171,64,.4);
    color: var(--orange);
    padding: 8px 14px; font-size: 12px;
    border-radius: 0;
    border-top: none; border-bottom: none;
}

.hex-dump {
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px; color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    padding: 14px 16px;
    overflow-x: auto; white-space: pre; line-height: 1.55;
}

/* ===== INFOS TAB ===== */
.info-section {
    background: var(--bg);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent2);
    border-radius: 0 8px 8px 0;
    padding: 16px 20px;
    margin-bottom: 16px;
}
.info-section h3 {
    font-size: 14px; color: var(--accent3);
    margin-bottom: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .5px;
}
.info-section p, .info-section li {
    font-size: 13px; color: var(--text-dim); line-height: 1.6;
}
.info-section ul { padding-left: 18px; margin-top: 6px; }
.info-section code {
    background: var(--bg3); color: var(--accent3);
    padding: 1px 6px; border-radius: 3px;
    font-family: monospace; font-size: 12px;
}

/* FDC-style grid for infos */
.fdc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; }
@media (max-width: 800px) { .fdc-grid { grid-template-columns: 1fr; } }
.fdc-title {
    font-size: 12px; font-weight: 700; color: var(--accent3);
    margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px;
}
.fdc-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.fdc-table td {
    padding: 4px 8px; border-bottom: 1px solid var(--border);
    color: var(--text-dim); vertical-align: top;
}
.fdc-table td:first-child { color: var(--accent2); font-family: monospace; white-space: nowrap; }
.fdc-table td:nth-child(2) { color: var(--text); font-weight: 700; white-space: nowrap; }
.fdc-table tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.badge {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-size: 11px; font-weight: 600;
}
.badge-yes    { background: rgba(0,230,118,.15); color: var(--green); border: 1px solid var(--green); }
.badge-no     { background: rgba(122,122,154,.1); color: var(--text-dim); }

/* ===== MISC ===== */
.table-scroll { overflow-x: auto; }

.empty-state {
    text-align: center; padding: 40px; color: var(--text-dim); font-size: 13px;
}
.empty-state .es-icon { font-size: 40px; margin-bottom: 10px; }