:root {
  color-scheme: dark;
  --bg: #101317;
  --panel: #171b20;
  --panel-2: #1c2228;
  --panel-3: #232b32;
  --line: #2a333a;
  --muted: #91a0a7;
  --text: #edf2ef;
  --teal: #63d6c7;
  --teal-dim: #123b39;
  --gold: #e5bd74;
  --red: #ec7c79;
  --green: #8ad8a2;
  --mono: Consolas, 'Courier New', monospace;
  font-family: 'Segoe UI', Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); min-width: 320px; }
button, input, select { color: inherit; font: inherit; }
button { cursor: pointer; }
a { color: var(--teal); text-decoration: none; }
.hidden { display: none !important; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }
.eyebrow { color: var(--teal); font: 500 11px var(--mono); letter-spacing: .12em; text-transform: uppercase; }

.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, .9fr) 1.1fr; background: radial-gradient(ellipse at 15% 20%, #193334 0, transparent 38%), var(--bg); }
.login-copy { padding: clamp(32px, 7vw, 100px); display: flex; flex-direction: column; justify-content: center; max-width: 760px; }
.brand-mark { display: inline-grid; place-items: center; width: 42px; height: 42px; border: 1px solid #3b645f; border-radius: 13px; color: var(--teal); font-size: 24px; font-weight: 700; }
.brand { display: flex; gap: 13px; align-items: center; }
.brand-title { font-size: 15px; font-weight: 700; letter-spacing: .03em; }
.brand-subtitle { color: var(--muted); font: 11px var(--mono); margin-top: 2px; }
.login-copy h1 { font-size: clamp(42px, 6vw, 76px); line-height: .98; letter-spacing: -.055em; margin: 72px 0 24px; max-width: 660px; }
.login-copy h1 span { color: var(--teal); }
.login-copy p { color: #b1bdc0; line-height: 1.7; max-width: 550px; font-size: 16px; }
.login-features { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; margin-top: 36px; max-width: 590px; }
.feature-chip { background: #ffffff08; border: 1px solid var(--line); color: #c3cfcd; border-radius: 10px; padding: 13px 15px; font-size: 13px; }
.feature-chip b { display: block; color: var(--text); margin-bottom: 3px; }
.login-art { border-left: 1px solid #263239; margin: 8vh 0; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; background: radial-gradient(ellipse at 50% 54%, #162829, transparent 58%); }
.orbit { position: absolute; border: 1px solid #28403f; border-radius: 50%; transform: rotate(-21deg); }
.orbit.one { width: min(66vw, 680px); height: min(38vw, 390px); }
.orbit.two { width: min(54vw, 560px); height: min(58vw, 600px); transform: rotate(38deg); }
.orbit.three { width: min(40vw, 410px); height: min(72vw, 730px); transform: rotate(82deg); }
.planet { width: 180px; height: 180px; border-radius: 50%; background: radial-gradient(circle at 32% 28%, #66cbb7, #226e6c 35%, #16383d 71%, #0e1d26 100%); box-shadow: 0 0 70px #36b9a53d, inset -18px -15px 35px #080e16; position: relative; }
.planet::before { content: ''; position: absolute; inset: 42% -22%; border: 9px solid #87c5b84f; border-radius: 50%; transform: rotate(-19deg); filter: blur(.4px); }
.art-label { position: absolute; left: 12%; bottom: 11%; color: #76878b; font: 11px var(--mono); line-height: 1.8; }
.login-action { margin-top: 32px; }
.login-note { margin-top: 12px; color: #76858a; font-size: 11px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); border-radius: 8px; padding: 9px 14px; font-size: 13px; font-weight: 600; transition: background .15s, border-color .15s, transform .15s; }
.btn:hover { border-color: #48605e; background: #263137; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #0c1c1b; }
.btn.primary:hover { background: #7ce6d7; }
.btn.quiet { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn.danger { color: var(--red); }

.app-shell { display: grid; grid-template-columns: 224px minmax(0,1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 14px; background: #14181c; border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 4; }
.sidebar .brand { padding: 0 10px 27px; border-bottom: 1px solid var(--line); }
.sidebar .brand-mark { width: 36px; height: 36px; font-size: 20px; border-radius: 11px; }
.nav-label { color: #637178; font: 500 10px var(--mono); letter-spacing: .12em; margin: 25px 10px 9px; text-transform: uppercase; }
.nav-list { display: grid; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 12px; text-align: left; width: 100%; padding: 11px 12px; border: 1px solid transparent; border-radius: 8px; background: transparent; color: #a1afb0; font-size: 13px; }
.nav-item:hover { background: #ffffff08; color: var(--text); }
.nav-item.active { background: var(--teal-dim); color: var(--teal); border-color: #24544f; }
.nav-icon { width: 18px; text-align: center; font-size: 15px; }
.linked-character-list { display: grid; gap: 2px; margin: 0 0 8px 7px; padding-left: 9px; border-left: 1px solid #304044; }
.linked-character { width: 100%; min-width: 0; display: flex; align-items: center; gap: 8px; border: 0; border-radius: 6px; padding: 7px 7px; background: transparent; color: #9daaa9; text-align: left; }
.linked-character:hover, .linked-character.selected { background: #20292d; color: var(--text); }
.linked-character.selected .character-dot { background: var(--teal); box-shadow: 0 0 8px #63d6c7a0; }
.character-dot { flex: 0 0 auto; width: 6px; height: 6px; border-radius: 50%; background: #526166; }
.linked-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.character-role { color: #697a7e; font: 9px var(--mono); }
.main-character .character-role { color: var(--gold); }
.sidebar-footer { margin-top: auto; padding: 12px 10px 0; color: #69787d; font: 10px var(--mono); line-height: 1.7; }
.main-area { min-width: 0; }
.topbar { height: 72px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 0 30px; background: #12161a; position: sticky; top: 0; z-index: 3; }
.topbar-title { display: flex; align-items: baseline; gap: 11px; min-width: 0; }
.topbar-title strong { font-size: 15px; letter-spacing: .01em; }
.topbar-title span { color: var(--muted); font: 11px var(--mono); }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.character-select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 31px 8px 11px; max-width: 200px; font-size: 12px; }
.page-content { padding: 29px 30px 55px; max-width: 1500px; margin: 0 auto; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 3px 0 23px; }
.page-heading h1 { font-size: 27px; letter-spacing: -.04em; margin: 5px 0 3px; }
.page-heading p { margin: 0; color: var(--muted); font-size: 13px; }
.heading-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 14px; }
.stat-grid { grid-template-columns: repeat(4, minmax(0,1fr)); margin-bottom: 18px; }
.stat-card, .panel { border: 1px solid var(--line); background: linear-gradient(145deg, #1a1f24, #151a1e); border-radius: 11px; }
.stat-card { padding: 17px 18px; min-height: 112px; }
.stat-label { color: #8c9b9e; text-transform: uppercase; letter-spacing: .08em; font: 10px var(--mono); }
.stat-value { font: 500 21px var(--mono); margin: 14px 0 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-foot { color: #6f7e83; font-size: 11px; }
.panel { padding: 18px; min-width: 0; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.panel-heading h2 { margin: 0; font-size: 15px; }
.panel-heading p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.overview-grid { grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr); }
.progress-track { height: 5px; background: #293237; border-radius: 8px; overflow: hidden; margin-top: 10px; }
.progress-track span { display: block; height: 100%; background: var(--teal); border-radius: inherit; }
.queue-row { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 15px; border-bottom: 1px solid #283137; padding: 13px 0; }
.queue-row:last-child { border-bottom: 0; }
.queue-row strong { font-size: 12px; }
.queue-row small { display: block; color: var(--muted); margin-top: 4px; font-size: 10px; }
.queue-time { color: var(--gold); font: 11px var(--mono); white-space: nowrap; }
.quick-links { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
.quick-link { padding: 12px; background: #20272c; border: 1px solid #2a373c; border-radius: 8px; text-align: left; color: #c9d1ce; }
.quick-link:hover { border-color: #4b7770; }
.quick-link b { display: block; font-size: 12px; margin-bottom: 4px; }
.quick-link small { color: var(--muted); font-size: 10px; }

.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin-bottom: 13px; }
.input, .select { background: #111619; border: 1px solid #303b41; border-radius: 7px; padding: 9px 11px; outline: none; font-size: 12px; }
.input:focus, .select:focus { border-color: #4b8c80; box-shadow: 0 0 0 2px #3cc6ad1a; }
.input.search { width: min(100%, 340px); }
.select { padding-right: 30px; }
.toolbar .spacer { flex: 1; }
.table-wrap { border: 1px solid #283238; border-radius: 8px; overflow: auto; background: #12171a; }
table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 680px; }
th { color: #849398; font: 10px var(--mono); letter-spacing: .055em; text-align: left; text-transform: uppercase; padding: 11px 13px; background: #1b2125; position: sticky; top: 0; z-index: 1; white-space: nowrap; }
td { padding: 11px 13px; border-top: 1px solid #242d32; color: #d5ddda; vertical-align: middle; }
tr:hover td { background: #ffffff05; }
td.num, th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.type-cell { display: flex; align-items: center; gap: 9px; min-width: 210px; }
.type-icon { width: 27px; height: 27px; border-radius: 6px; background: #253238; border: 1px solid #34464b; color: var(--teal); display: grid; place-items: center; font: 10px var(--mono); }
.type-name { font-weight: 600; }
.type-meta { color: #78878c; display: block; font: 10px var(--mono); margin-top: 3px; }
.tag { display: inline-flex; align-items: center; border: 1px solid #354247; background: #20282c; color: #aebbb8; border-radius: 20px; padding: 3px 7px; font: 10px var(--mono); white-space: nowrap; }
.tag.teal { background: #143531; border-color: #25534e; color: var(--teal); }
.tag.gold { background: #342b1e; border-color: #5a482e; color: var(--gold); }
.empty { text-align: center; padding: 44px 20px; color: #879599; }
.empty b { display: block; color: #d5dedb; font-size: 14px; margin-bottom: 7px; }
.empty code { color: var(--teal); }
.skeleton { height: 65px; margin: 0 0 10px; border-radius: 9px; background: linear-gradient(90deg,#1b2024,#252d31,#1b2024); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.industry-layout { display: grid; grid-template-columns: minmax(380px, .95fr) minmax(430px, 1.05fr); gap: 14px; align-items: start; }
.industry-list-panel { padding: 15px; }
.industry-list { max-height: 68vh; overflow: auto; border: 1px solid #283238; border-radius: 8px; }
.product-row { width: 100%; text-align: left; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 11px 12px; background: #12171a; border: 0; border-bottom: 1px solid #242d32; }
.product-row:hover { background: #1b2528; }
.product-row.selected { background: #14312f; box-shadow: inset 2px 0 var(--teal); }
.product-row:last-child { border-bottom: 0; }
.product-row strong { display: block; font-size: 12px; }
.product-row small { color: var(--muted); display: block; margin-top: 4px; font: 10px var(--mono); }
.recipe-count { color: #a9b5b2; font: 10px var(--mono); white-space: nowrap; }
.industry-settings { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; padding: 13px; background: #12171a; border: 1px solid #293338; border-radius: 8px; margin-bottom: 14px; }
.field { min-width: 0; display: grid; gap: 5px; }
.field label { color: #8d9a9e; font: 10px var(--mono); text-transform: uppercase; letter-spacing: .06em; }
.field .input, .field .select { width: 100%; }
.recipe-card { padding: 12px 13px; border: 1px solid #2a383d; background: #141b1e; border-radius: 8px; margin: 12px 0; }
.recipe-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.recipe-title strong { font-size: 12px; }
.recipe-title small { color: var(--muted); font: 10px var(--mono); }
.profit-banner { background: linear-gradient(105deg,#143d37,#182925 75%); border: 1px solid #2e665e; border-radius: 9px; padding: 15px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 12px 0; }
.profit-banner.loss { background: linear-gradient(105deg,#3b2525,#241b1d); border-color: #663d3b; }
.profit-banner .label { color: #acd2c7; font-size: 11px; }
.profit-banner .amount { color: var(--green); font: 500 20px var(--mono); margin-top: 4px; }
.profit-banner.loss .amount { color: var(--red); }
.profit-banner .return { color: #bbcfca; font: 11px var(--mono); text-align: right; }
.material-table table { min-width: 550px; }
.material-table select { max-width: 134px; padding: 5px 24px 5px 7px; font-size: 10px; }
.quote-footnote { color: #738287; font-size: 10px; line-height: 1.55; margin-top: 12px; }
.warning-box { padding: 11px 13px; border: 1px solid #5b4a30; background: #322a1f; border-radius: 8px; color: #dbc696; font-size: 11px; line-height: 1.5; margin: 10px 0; }
.skill-check { display: flex; flex-wrap: wrap; gap: 6px; margin: 9px 0; }

.toast { position: fixed; right: 22px; bottom: 20px; z-index: 10; max-width: min(440px,calc(100vw - 30px)); padding: 12px 15px; border-radius: 8px; background: #283137; border: 1px solid #405056; box-shadow: 0 12px 32px #0008; font-size: 12px; }
.toast.error { color: #ffd1cf; border-color: #76504e; background: #382526; }
.toast.success { color: #c8f3dd; border-color: #3f685a; background: #1b322a; }
.mobile-menu { display: none; }
.footer-note { margin-top: 22px; color: #6d7b80; font-size: 10px; line-height: 1.6; }
.data-age { color: #708087; font: 10px var(--mono); }

@media (max-width: 1050px) {
  .industry-layout { grid-template-columns: minmax(300px,.8fr) minmax(390px,1.2fr); }
  .stat-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .page-content { padding-inline: 20px; }
  .topbar { padding-inline: 20px; }
}
@media (max-width: 760px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-copy { padding: 34px 25px 55px; }
  .login-copy h1 { margin-top: 52px; }
  .login-art { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 245px; transform: translateX(-101%); transition: transform .18s ease; box-shadow: 18px 0 45px #0008; }
  .sidebar.open { transform: translateX(0); }
  .mobile-menu { display: inline-flex; }
  .topbar { height: 62px; padding-inline: 12px; }
  .topbar-title span { display: none; }
  .character-select { max-width: 132px; }
  .topbar-actions .connect-label, .topbar-actions .logout-label { display: none; }
  .page-content { padding: 22px 13px 45px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .overview-grid, .industry-layout { grid-template-columns: 1fr; }
  .industry-list { max-height: 42vh; }
  .industry-settings { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 460px) {
  .stat-grid { gap: 8px; }
  .stat-card { padding: 13px; min-height: 98px; }
  .stat-value { font-size: 16px; }
  .panel { padding: 13px; }
  .industry-settings { grid-template-columns: 1fr; }
  .topbar-title strong { font-size: 12px; }
  .character-select { max-width: 112px; font-size: 10px; }
}

.sync-panel { margin-bottom: 18px; }
.sync-progress { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 15px; border: 1px solid #29383b; border-radius: 8px; background: #12191c; }
.sync-progress strong { display: block; color: var(--teal); font: 15px var(--mono); }
.sync-progress small { display: block; color: var(--muted); margin-top: 5px; font-size: 11px; }
.sync-search, .sync-errors { margin-top: 13px; padding: 11px 13px; border: 1px solid #293338; border-radius: 8px; background: #12171a; color: #c4d0cd; font-size: 12px; }
.sync-search summary, .sync-errors summary { cursor: pointer; color: var(--teal); font-weight: 600; }
.sync-search p { color: var(--muted); font-size: 11px; }
.sync-errors ul { margin-bottom: 0; padding-left: 18px; color: #d5bb8e; line-height: 1.7; overflow-wrap: anywhere; }
.checkbox-label { display: inline-flex; align-items: center; gap: 7px; color: #aab7b4; font-size: 11px; white-space: nowrap; }
.checkbox-label input { accent-color: var(--teal); }
.planner-progress { color: var(--gold); font: 10px var(--mono); margin: 0 0 11px; }
.planner-table table { min-width: 1060px; }
.sort-header { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: inherit; text-transform: inherit; letter-spacing: inherit; }
.sort-header:hover { color: var(--teal); }
.min-profit { width: 145px; }
.planner-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 13px; color: var(--muted); font: 10px var(--mono); }
.planner-pagination > div { display: flex; align-items: center; gap: 10px; }
.asset-location { border: 1px solid #2a3539; border-radius: 8px; background: #121719; margin: 8px 0; overflow: hidden; }
.asset-location summary { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 15px; cursor: pointer; list-style: none; }
.asset-location summary::-webkit-details-marker { display: none; }
.asset-location summary::before { content: "›"; color: var(--teal); font: 18px var(--mono); transition: transform .12s; }
.asset-location[open] summary::before { transform: rotate(90deg); }
.asset-location summary > span:first-of-type { flex: 1; min-width: 0; }
.asset-location summary b { display: block; color: #d9e1dd; font-size: 12px; }
.asset-location summary small { display: block; color: var(--muted); margin-top: 4px; font: 10px var(--mono); }
.asset-stats { color: var(--teal); font: 10px var(--mono); white-space: nowrap; }
.asset-location .table-wrap { margin: 0 9px 9px; }
.asset-location table { min-width: 720px; }
.asset-location .toolbar { justify-content: center; margin: 8px; }
@media (max-width: 760px) {
  .sync-progress, .planner-pagination { align-items: flex-start; flex-direction: column; }
  .planner-pagination > div { width: 100%; justify-content: space-between; }
  .asset-location summary { align-items: flex-start; }
  .asset-stats { white-space: normal; text-align: right; }
}