/* ── Reset & global ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', sans-serif;
    background: #07101a;
    color: #c8dce8;
    margin: 0;
    padding-top: 56px; /* room for fixed nav */
}

a { color: #7ab3d3; text-decoration: none; }
a:hover { color: #c8dce8; }

h1, h2, h3 { color: #e8f0f8; margin: 0.4em 0; }

/* ── Page layout ─────────────────────────────────────────────────────────── */
.page-center {
    max-width: 720px;
    margin: 0 auto;
    padding: 32px 16px;
    text-align: center;
}

/* ── Asset page — wider layout ────────────────────────────────────────────── */
body.wide .page-center { max-width: 1200px; }

/* ── Top navigation bar ──────────────────────────────────────────────────── */
.site-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 52px;
    background: #0e1a28;
    border-top: 3px solid #c47a1e;
    border-bottom: 1px solid #1e3044;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 20px;
    z-index: 100;
}

.site-title {
    font-size: 14px;
    font-weight: 700;
    color: #e8f0f8;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
    flex: 1;
}

.site-header .nav-links {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
}

.site-header .nav-links a {
    color: #7a9ab5;
    padding: 4px 0;
    border-bottom: 1px solid transparent;
    transition: color 0.12s, border-color 0.12s;
}

.site-header .nav-links a:hover {
    color: #c8dce8;
    border-bottom-color: #2a4a6a;
}

.character-switcher {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.character-switcher label {
    color: #7a9ab5;
    font-size: 12px;
    white-space: nowrap;
}

.character-switcher select {
    min-width: 180px;
    padding: 5px 8px;
    background: #0e1a28;
    color: #c8dce8;
    border: 1px solid #2a4a6a;
    border-radius: 3px;
    font-size: 12px;
    font-family: inherit;
}

.character-switcher select:focus {
    outline: none;
    border-color: #4a7aa0;
}

/* ── Character card ──────────────────────────────────────────────────────── */
.character { margin: 24px 0 16px; }

.portrait {
    border-radius: 50%;
    width: 96px; height: 96px;
    border: 2px solid #2a4a6a;
    display: block;
    margin: 0 auto 10px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 9px 20px;
    background: #0e1e30;
    color: #9ab8cc;
    text-decoration: none;
    border: 1px solid #2a4a6a;
    border-radius: 3px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.btn:hover {
    background: #152840;
    color: #c8dce8;
    border-color: #3a6080;
}

/* Primary CTA — EVE orange */
.btn-primary {
    background: #9a5e10;
    color: #f0d8b8;
    border-color: #c47a1e;
}

.btn-primary:hover {
    background: #b06a14;
    color: #fff8ee;
    border-color: #d88a2a;
}

/* Logout — muted red ghost */
.btn-logout {
    background: transparent;
    color: #c07070;
    border-color: #5a2828;
}

.btn-logout:hover {
    background: #2a1010;
    color: #e08c8c;
    border-color: #8a3030;
}

.btn-danger {
    background: #4b1d1d;
    color: #f0c4c4;
    border-color: #8a3030;
}

.btn-danger:hover {
    background: #5d2424;
    color: #ffe0e0;
    border-color: #b44444;
}

/* SSO image button */
.btn-sso {
    display: inline-block;
    border: 1px solid #c47a1e;
    border-radius: 3px;
    padding: 3px;
    background: #0e1e30;
    transition: border-color 0.12s, background 0.12s;
}

.btn-sso:hover {
    background: #1a2e40;
    border-color: #d88a2a;
}

/* ── Forms / sync controls ───────────────────────────────────────────────── */
.sync-controls {
    margin: 16px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.sync-info { font-size: 12px; color: #7a9ab5; }

/* ── Sync progress bar ──────────────────────────────────────────────────── */
.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

#sync-progress {
    margin: 4px 0 12px;
    text-align: center;
}

.sync-status-text {
    display: block;
    font-size: 12px;
    color: #7a9ab5;
    margin-bottom: 6px;
}

.sync-progress-bar {
    width: 100%;
    max-width: 340px;
    height: 4px;
    background: #0e1e30;
    border-radius: 2px;
    overflow: hidden;
    margin: 0 auto;
}

.sync-progress-fill {
    height: 100%;
    width: 45%;
    background: #c47a1e;
    border-radius: 2px;
    animation: sync-slide 1.4s ease-in-out infinite;
}

@keyframes sync-slide {
    0%   { transform: translateX(-222%); }
    100% { transform: translateX(444%); }
}

/* ── Status messages ─────────────────────────────────────────────────────── */
.error, .success {
    display: block;
    margin: 12px auto;
    max-width: 900px;
    padding: 10px 16px;
    border-radius: 3px;
    font-size: 13px;
    text-align: left;
    border-left: 3px solid;
}

.error   { background: #1a0e10; color: #e08c8c; border-left-color: #8a3030; }
.success { background: #0e1a16; color: #80c8a0; border-left-color: #306050; }

/* ── Sign-in intro text ──────────────────────────────────────────────────── */
.signin-intro { color: #7a9ab5; font-size: 15px; margin-bottom: 20px; }

/* ── Asset table ──────────────────────────────────────────────────────────── */
.asset-summary { text-align: left; font-size: 13px; color: #7a9ab5; margin: 8px 0 4px; }

.assets-table { width: 100%; border-collapse: collapse; font-size: 13px; text-align: left; }

.assets-table col.col-name  { width: 35%; }
.assets-table col.col-group { width: 22%; }
.assets-table col.col-qty   { width:  8%; }
.assets-table col.col-flag  { width: 20%; }
.assets-table col.col-bpc   { width:  8%; }

.assets-table thead th {
    padding: 7px 10px; background: #111d28; color: #aac;
    border-bottom: 2px solid #2a3a4a; font-weight: 600; white-space: nowrap;
}
.assets-table thead th.col-qty { text-align: right; }

/* Location group header rows */
.loc-row { cursor: pointer; user-select: none; }
.loc-row td {
    padding: 7px 10px; background: #1a2a3a; color: #cde; font-weight: bold;
    border-top: 2px solid #2a3a4a; border-bottom: 1px solid #253545;
}
.loc-row:hover td { background: #1f3248; }

.loc-arrow {
    display: inline-block; font-size: 10px; margin-right: 7px;
    color: #7a9ab5; transition: transform 0.12s ease; vertical-align: middle;
}
.loc-row.open .loc-arrow { transform: rotate(90deg); }
.loc-count { font-weight: normal; font-size: 12px; color: #6a8a9f; margin-left: 6px; }

/* Item rows */
.asset-row td { padding: 4px 10px; border-bottom: 1px solid #1a2535; color: #bcd; }
.asset-row td.col-qty { text-align: right; }
.asset-row:hover td { background: #162030; }

/* Ship / container sub-header rows */
.container-row { cursor: pointer; user-select: none; }
.container-row td {
    padding: 5px 10px; background: #141e2c; color: #abc; font-weight: 600;
    border-top: 1px solid #1e3044; border-bottom: 1px solid #1a2535;
}
.container-row:hover td { background: #182438; }
.loc-row.open .loc-arrow, .container-row.open .loc-arrow { transform: rotate(90deg); }

/* Nesting indentation — depth classes used by renderAssetLevel() */
.assets-table td.indent-1  { padding-left:  20px; }
.assets-table td.indent-2  { padding-left:  40px; }
.assets-table td.indent-3  { padding-left:  60px; }
.assets-table td.indent-4  { padding-left:  80px; }
.assets-table td.indent-5  { padding-left: 100px; }
.assets-table td.indent-6  { padding-left: 120px; }
.assets-table td.indent-7  { padding-left: 140px; }
.assets-table td.indent-8  { padding-left: 160px; }
.assets-table td.indent-9  { padding-left: 180px; }
.assets-table td.indent-10 { padding-left: 200px; }

/* ── Asset search bar ─────────────────────────────────────────────────────── */
.asset-search-bar {
    margin: 10px 0 6px;
    display: flex;
}

#asset-search {
    width: 100%;
    padding: 7px 12px;
    background: #0e1a28;
    color: #c8dce8;
    border: 1px solid #2a4a6a;
    border-radius: 3px;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.12s;
}

#asset-search:focus { border-color: #4a7aa0; }
#asset-search::placeholder { color: #4a6a80; }

/* Clear button inside search (browser native) */
#asset-search::-webkit-search-cancel-button { cursor: pointer; }

/* ── Sort arrows on thead ─────────────────────────────────────────────────── */
.assets-table thead th.sortable {
    cursor: pointer;
    user-select: none;
}

.assets-table thead th.sortable:hover { color: #c8dce8; }

.sort-arrow { font-size: 9px; margin-left: 4px; color: #4a6a80; }
.assets-table thead th.active-sort .sort-arrow { color: #c47a1e; }
.assets-table thead th.sort-asc  .sort-arrow::after { content: '▲'; }
.assets-table thead th.sort-desc .sort-arrow::after { content: '▼'; }
.assets-table thead th.sortable:not(.active-sort) .sort-arrow::after { content: '⇅'; font-size: 10px; }

/* ── Search results table — extra Location column ────────────────────────── */
.assets-table-search col.col-name     { width: 22%; }
.assets-table-search col.col-group    { width: 14%; }
.assets-table-search col.col-qty      { width:  6%; }
.assets-table-search col.col-flag     { width: 13%; }
.assets-table-search col.col-bpc      { width:  6%; }
.assets-table-search col.col-location { width: 39%; }

.assets-table-search .asset-row td { color: #bcd; }

.col-location { text-align: left; font-size: 12px; color: #7a9ab5; }

.search-empty-row td {
    padding: 14px 10px;
    color: #4a6a80;
    font-style: italic;
    text-align: center;
}

/* ── Header logout button — compact variant ──────────────────────────────── */
.site-header .btn-logout {
    padding: 5px 12px;
    font-size: 12px;
}

/* ── Sync-controls forms — transparent to flex layout ───────────────────── */
.sync-controls form { display: contents; }

/* ── Index page — character meta & nav ──────────────────────────────────── */
.character-id {
    color: #7a9ab5;
    font-size: 13px;
}

.character-nav {
    margin: 20px 0;
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: center;
}

.warning-note {
    margin: 0 auto 14px;
    max-width: 900px;
    text-align: left;
    font-size: 13px;
    color: #d9c08a;
    background: #241b0f;
    border-left: 3px solid #9d772c;
    border-radius: 3px;
    padding: 10px 14px;
}

.manage-characters-list {
    display: grid;
    gap: 12px;
    text-align: left;
}

.character-manage-card {
    border: 1px solid #2a3e52;
    border-radius: 4px;
    background: #0e1a28;
    padding: 12px;
}

.character-manage-card-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.active-pill {
    font-size: 11px;
    color: #72bd96;
    border: 1px solid #3e8562;
    background: #11261d;
    border-radius: 999px;
    padding: 2px 8px;
}

.confirm-delete-row {
    margin: 10px 0;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    font-size: 12px;
    color: #c8dce8;
}

.confirm-delete-row input {
    margin-top: 2px;
}

.confirm-name-row {
    display: block;
    font-size: 12px;
    color: #d7c297;
    margin: 6px 0 4px;
}

.confirm-name-input {
    width: 100%;
    max-width: 360px;
    padding: 7px 10px;
    margin-bottom: 10px;
    background: #0e1a28;
    color: #c8dce8;
    border: 1px solid #744040;
    border-radius: 3px;
    font-size: 13px;
    font-family: inherit;
}

.confirm-name-input:focus {
    outline: none;
    border-color: #b44444;
}

/* ── Production chain page ──────────────────────────────────────────────── */
.pc-controls {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 160px minmax(420px, 1.2fr);
    gap: 12px;
    align-items: start;
    margin: 12px 0 10px;
}

.pc-search-wrap,
.pc-qty-wrap,
.pc-actions-wrap {
    text-align: left;
}

.pc-actions-wrap {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: end;
    gap: 8px;
}

.pc-actions-wrap .btn {
    width: 100%;
}

.pc-cart-wrap {
    margin: 14px 0 18px;
}

.pc-cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.pc-cart-header h3 {
    margin: 0;
}

.pc-cart-actions {
    display: flex;
    gap: 8px;
}

.pc-cart-status {
    margin-bottom: 12px;
}

.pc-cart-remove {
    min-width: 74px;
}

.pc-controls label {
    display: block;
    font-size: 12px;
    color: #7a9ab5;
    margin-bottom: 6px;
}

#pc-search,
#pc-quantity {
    width: 100%;
    padding: 7px 12px;
    background: #0e1a28;
    color: #c8dce8;
    border: 1px solid #2a4a6a;
    border-radius: 3px;
    font-size: 13px;
    font-family: inherit;
}

#pc-search:focus,
#pc-quantity:focus {
    outline: none;
    border-color: #4a7aa0;
}

.pc-search-results {
    margin-top: 6px;
    border: 1px solid #22364d;
    border-radius: 3px;
    background: #0b1420;
    overflow: hidden;
}

.pc-search-result {
    width: 100%;
    text-align: left;
    display: block;
    border: 0;
    background: transparent;
    color: #bcd;
    padding: 8px 10px;
    cursor: pointer;
    font-size: 13px;
}

.pc-search-result:hover {
    background: #1a2a3a;
    color: #d8e8f5;
}

.pc-search-empty {
    color: #7a9ab5;
    font-size: 12px;
    padding: 8px 10px;
}

.pc-status {
    margin: 10px 0;
    padding: 9px 12px;
    border: 1px solid #26445f;
    border-radius: 3px;
    background: #0e1a28;
    color: #87a9be;
    text-align: left;
    font-size: 12px;
}

.pc-status.pc-error {
    border-color: #6a2a2a;
    color: #d08a8a;
    background: #1a1013;
}

.pc-table-wrap {
    overflow: auto;
}

.pc-table th,
.pc-table td {
    white-space: nowrap;
}

.pc-table td {
    vertical-align: top;
}

.moon-section {
    margin: 14px 0 18px;
    text-align: left;
}

.moon-upload-form {
    display: grid;
    gap: 8px;
}

.moon-upload-form label {
    font-size: 12px;
    color: #7a9ab5;
}

.moon-upload-form textarea {
    width: 100%;
    min-height: 170px;
    resize: vertical;
    padding: 9px 12px;
    background: #0e1a28;
    color: #c8dce8;
    border: 1px solid #2a4a6a;
    border-radius: 3px;
    font-size: 13px;
    font-family: Consolas, Monaco, 'Courier New', monospace;
}

.moon-upload-form textarea:focus {
    outline: none;
    border-color: #4a7aa0;
}

.pc-group-row td {
    padding: 7px 10px;
    background: #162536;
    color: #d7e6f2;
    font-weight: 700;
    border-top: 1px solid #28415c;
    border-bottom: 1px solid #22384f;
}

.pc-material-covered td {
    color: #7f95a7;
    opacity: 0.7;
}

.pc-table .pc-num {
    text-align: right;
}

.pc-me-input {
    width: 68px;
    padding: 4px 6px;
    background: #0b1623;
    color: #c8dce8;
    border: 1px solid #2f4e69;
    border-radius: 3px;
}

.pc-me-editor {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
}

.pc-me-hint {
    font-size: 11px;
    color: #6f8aa0;
    line-height: 1.1;
    min-height: 12px;
}

.pc-me-editor.is-dirty .pc-me-hint {
    color: #9bb6ca;
}

.pc-me-editor.is-saving .pc-me-hint {
    color: #d3b46c;
}

.pc-me-editor.is-saving .pc-me-input {
    border-color: #a77e2c;
}

.pc-me-editor.is-saved .pc-me-hint {
    color: #72bd96;
}

.pc-me-editor.is-saved .pc-me-input {
    border-color: #3e8562;
}

.pc-me-editor.is-error .pc-me-hint,
.pc-me-editor.is-invalid .pc-me-hint {
    color: #d08a8a;
}

.pc-me-editor.is-error .pc-me-input,
.pc-me-editor.is-invalid .pc-me-input {
    border-color: #8b3d3d;
}

.pc-indent {
    display: inline-block;
}

.pc-type-id {
    color: #6d8aa0;
    font-size: 11px;
}

@media (max-width: 860px) {
    .site-header {
        height: auto;
        min-height: 52px;
        flex-wrap: wrap;
        padding-top: 6px;
        padding-bottom: 6px;
        row-gap: 6px;
    }

    .site-title {
        flex: 1 1 100%;
    }

    .character-switcher {
        width: 100%;
        justify-content: space-between;
        margin-left: 0;
    }

    .character-switcher select {
        min-width: 0;
        width: 100%;
        max-width: 280px;
    }

    .site-header .nav-links {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 10px;
    }

    .pc-controls {
        grid-template-columns: 1fr;
    }

    .pc-actions-wrap {
        grid-template-columns: 1fr;
    }

    .pc-cart-header {
        flex-direction: column;
        align-items: stretch;
    }

    .pc-cart-actions {
        flex-direction: column;
    }

    .pc-table {
        font-size: 12px;
    }

    .character-manage-card-top {
        flex-direction: column;
        align-items: flex-start;
    }
}
