/* ===== Companies page ===== */
.co-page {
  background:
    radial-gradient(ellipse at 10% 0%, rgba(47, 107, 255, .18), transparent 50%),
    radial-gradient(ellipse at 95% 20%, rgba(255, 201, 74, .08), transparent 45%),
    var(--bg);
  min-height: 100vh;
}
.co-main { width: min(1320px, calc(100% - 28px)); margin: 0 auto; padding: 104px 0 60px; }
.gold-text { color: var(--gold); }

/* Header */
.co-head { display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: end; margin-bottom: 24px; }
.co-head h1 { font-family: var(--font-display); font-weight: 900; font-size: clamp(30px, 4vw, 52px); letter-spacing: -1px; margin: 10px 0 8px; }
.co-head p { color: var(--muted); font-size: 15px; }
.co-head p b { color: var(--text); }

.economy { border-radius: 18px; padding: 14px 16px; min-width: 360px; }
.eco-head { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.eco-head img { width: 26px; height: 26px; border-radius: 50%; }
.eco-head small { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 11.5px; }
.eco-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 10px; }
.eco-stats div { padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); }
.eco-stats small { display: block; color: var(--muted); font-size: 10.5px; letter-spacing: .5px; }
.eco-stats b { font-family: var(--font-mono); font-size: 14px; }
.eco-note { display: flex; gap: 8px; align-items: flex-start; color: var(--muted); font-size: 12px; line-height: 1.45; }
.eco-note i { color: var(--gold); font-size: 16px; flex-shrink: 0; }

/* Tabs */
.co-tabs { grid-template-columns: repeat(3, 1fr); max-width: 560px; margin-bottom: 22px; }
.co-tabs button { display: flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 0; font-size: 13px; }
.co-tabs button i { font-size: 17px; }
.co-tabs .seg-glider { width: calc((100% - 8px) / 3); }
.count { min-width: 20px; padding: 1px 6px; border-radius: 99px; background: rgba(255, 201, 74, .18); color: var(--gold); font-size: 11px; font-family: var(--font-mono); }

.tab-panel { display: none; animation: slideIn .35s both; }
.tab-panel.active { display: block; }

/* ===== Build tab ===== */
.co-build { display: grid; grid-template-columns: 1fr 400px; gap: 20px; align-items: start; }
.group-title { display: flex; align-items: baseline; gap: 10px; font-size: 14px; font-weight: 700; margin: 4px 0 12px; }
.group-title i { color: var(--cyan); font-size: 18px; align-self: center; }
.group-title small { color: var(--muted); font-weight: 500; font-size: 12px; }
.types { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 26px; }

.type-card {
  position: relative; text-align: left; padding: 14px; border-radius: 18px;
  background: linear-gradient(160deg, rgba(24, 31, 54, .9), rgba(10, 14, 26, .95));
  border: 1px solid var(--line); transition: transform .2s, border-color .2s, box-shadow .2s;
}
.type-card:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.type-card.active { border-color: rgba(255, 201, 74, .7); box-shadow: 0 0 0 1px rgba(255, 201, 74, .4), 0 12px 40px rgba(255, 201, 74, .15); }
.type-icon { font-size: 30px; line-height: 1; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .5)); }
.type-name { font-weight: 700; font-size: 14px; margin: 10px 0 4px; }
.type-recipe { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; color: var(--muted); font-size: 12px; }
.type-recipe i { font-size: 12px; }
.type-q {
  position: absolute; top: 12px; right: 12px; padding: 2px 7px; border-radius: 7px; font-size: 10px; font-weight: 800; letter-spacing: .5px;
  background: var(--grad); color: #1f1400;
}

/* Builder */
/* The panel follows you down the page; on short screens it scrolls inside itself so the Build button is always reachable */
.builder { position: sticky; top: 96px; max-height: calc(100vh - 112px); overflow-y: auto; overscroll-behavior: contain; border-radius: 22px; padding: 22px; background: var(--glass-strong); }
.builder::-webkit-scrollbar { width: 8px; }
.builder::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-radius: 8px; }
.bd-top { display: flex; gap: 14px; align-items: center; }
.bd-icon {
  width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; font-size: 34px;
  background: radial-gradient(circle at 30% 30%, rgba(255, 201, 74, .25), rgba(47, 107, 255, .15));
  border: 1px solid var(--line-strong);
}
.bd-name { font-family: var(--font-display); font-weight: 900; font-size: 22px; line-height: 1.1; }
.bd-tag { display: inline-flex; margin-top: 6px; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.bd-tag.q { background: rgba(255, 201, 74, .15); color: var(--gold); }
.bd-tag.raw { background: rgba(255, 255, 255, .07); color: var(--muted); }

.recipe { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; margin: 16px 0 6px; padding: 12px; border-radius: 16px; background: rgba(0, 0, 0, .25); border: 1px solid var(--line); }
.res-chip { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; min-width: 70px; padding: 8px 10px; border-radius: 12px; background: rgba(255, 255, 255, .05); }
.res-chip span { font-size: 22px; }
.res-chip small { font-size: 11px; font-weight: 600; }
.res-chip em { font-style: normal; font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }
.res-chip.out { background: rgba(255, 201, 74, .1); box-shadow: inset 0 0 0 1px rgba(255, 201, 74, .35); }
.recipe .arrow { color: var(--muted); font-size: 18px; }
.recipe-note { text-align: center; color: var(--muted); font-size: 12px; margin-bottom: 16px; }

.levels { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.levels th { text-align: left; color: var(--muted); font-weight: 600; font-size: 10.5px; letter-spacing: 1px; padding: 0 6px 6px; }
.levels td { padding: 7px 6px; border-top: 1px solid var(--line); }
.levels td:last-child, .levels th:last-child { text-align: right; }
.levels .q-cell { font-family: var(--font-display); font-weight: 700; }
.levels .mono { font-size: 12px; }
.levels tr.first td { color: var(--text); }
/* the quality stars in the table — a different thing from the starfield layer in style.css */
.levels .q-stars { color: var(--gold); font-size: 9px; letter-spacing: 1px; margin-left: 4px; }

.bd-use { display: flex; gap: 8px; margin: 16px 0; padding: 10px 12px; border-radius: 12px; background: rgba(34, 211, 255, .06); color: #bfe9ff; font-size: 12.5px; }
.bd-use.state { background: rgba(255, 201, 74, .08); color: #ffe3a1; }
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field label { font-size: 11px; letter-spacing: 1px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.field input {
  height: 44px; padding: 0 14px; border-radius: 12px; outline: none;
  background: rgba(0, 0, 0, .3); border: 1px solid var(--line); transition: border-color .2s;
}
.field input:focus { border-color: var(--gold); }
.bd-where { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; margin-bottom: 14px; }
.bd-where img { width: 18px; height: 18px; border-radius: 50%; }
.btn .gold-cost { display: inline-flex; align-items: center; gap: 4px; }

/* ===== My companies ===== */
.my-grid, .market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.co-card {
  position: relative; padding: 20px; border-radius: 22px;
  background: linear-gradient(160deg, rgba(24, 31, 54, .92), rgba(10, 14, 26, .96));
  border: 1px solid var(--line);
}
.co-card.fresh { animation: fresh 1.6s ease-out; }
@keyframes fresh { 0% { box-shadow: 0 0 0 3px rgba(255, 201, 74, .9), 0 0 60px rgba(255, 201, 74, .5); } 100% { box-shadow: none; } }
.cc-head { display: flex; gap: 12px; align-items: center; }
.cc-icon { width: 50px; height: 50px; border-radius: 15px; display: grid; place-items: center; font-size: 26px; background: rgba(255, 255, 255, .05); border: 1px solid var(--line); }
.cc-name { font-weight: 800; font-size: 16px; }
.cc-type { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.cc-type img { width: 14px; height: 14px; border-radius: 50%; }
.cc-q { margin-left: auto; text-align: right; }
.cc-q b { display: block; font-family: var(--font-display); font-size: 20px; }
.cc-q span { color: var(--gold); font-size: 10px; letter-spacing: 1px; }
.cc-q span i { color: rgba(255, 255, 255, .15); font-style: normal; }

.cc-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 14px 0; padding: 10px 12px; border-radius: 12px; background: rgba(0, 0, 0, .25); font-size: 12.5px; }
.cc-line b { font-family: var(--font-mono); }
.cc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cc-stats div { padding: 9px 10px; border-radius: 12px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); }
.cc-stats small { display: block; color: var(--muted); font-size: 10.5px; }
.cc-stats b { font-family: var(--font-mono); font-size: 13.5px; }
.cc-stats b.warn { color: var(--red); }
.cc-tax { margin-top: 10px; color: var(--muted); font-size: 11.5px; display: flex; gap: 6px; align-items: flex-start; line-height: 1.4; }
.cc-tax i { color: var(--gold); }

.cc-forms { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.mini-form { display: flex; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: rgba(0, 0, 0, .3); }
.mini-form input { flex: 1; min-width: 0; height: 38px; padding: 0 10px; border: none; background: none; outline: none; font-family: var(--font-mono); font-size: 12.5px; }
.mini-form button { padding: 0 10px; font-size: 11.5px; font-weight: 700; background: rgba(255, 255, 255, .08); white-space: nowrap; }
.mini-form button:hover { background: rgba(255, 255, 255, .15); }
.cc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.cc-actions .btn { height: 40px; font-size: 13px; }
.state-note { margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: rgba(255, 201, 74, .08); color: #ffe3a1; font-size: 12px; display: flex; gap: 6px; }

.empty-state { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 22px; }
.empty-state span { font-size: 42px; display: block; margin-bottom: 10px; }

/* ===== Market ===== */
.mk-card .cc-seller { color: var(--muted); font-size: 12px; margin: 12px 0; display: flex; gap: 6px; align-items: center; }
.mk-price { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mk-price .price { font-family: var(--font-display); font-weight: 900; font-size: 24px; display: flex; align-items: center; gap: 8px; }
.mk-price .price i { color: var(--gold); }
.mk-price .btn { width: auto; min-width: 150px; }
.mine-tag { position: absolute; top: 16px; right: 16px; padding: 3px 8px; border-radius: 8px; background: rgba(34, 211, 255, .15); color: var(--cyan); font-size: 10.5px; font-weight: 800; letter-spacing: 1px; }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
  .co-build { grid-template-columns: 1fr; }
  .builder { position: static; }
  .co-head { grid-template-columns: 1fr; }
  .economy { min-width: 0; }
}
@media (max-width: 600px) {
  .co-main { padding-top: 84px; }
  .my-grid, .market-grid { grid-template-columns: 1fr; }
  .co-tabs button { font-size: 11.5px; gap: 4px; }
  .co-tabs button i { display: none; }
  .cc-forms, .cc-actions { grid-template-columns: 1fr; }
  .eco-stats { grid-template-columns: 1fr 1fr; }
}

/* ===== Regions (build location) ===== */
.regions { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; max-height: 330px; overflow-y: auto; padding: 2px; margin-bottom: 26px; scrollbar-width: thin; }
.region-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px 12px; border-radius: 14px; text-align: left;
  background: rgba(255, 255, 255, .04); border: 1px solid var(--line); transition: border-color .2s, background .2s;
}
.region-card:hover { background: rgba(255, 255, 255, .07); }
.region-card.active { border-color: rgba(255, 201, 74, .7); background: rgba(255, 201, 74, .08); }
.region-card b { font-size: 13px; }
.region-card span { font-size: 12px; display: flex; align-items: center; gap: 6px; }
.muted { color: var(--muted); }
.rich-badge {
  display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: 10.5px; font-weight: 700; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
}
.bd-rich { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, .04); font-size: 13px; font-weight: 600; }

/* Company cards that link to their page */
.co-link { display: block; transition: transform .2s, border-color .2s; }
.co-link:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.cc-open { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 14px; color: var(--gold); font-weight: 700; font-size: 13px; }

/* ===== Shared page pieces (company / market / jobs) ===== */
.page-main { width: min(1320px, calc(100% - 28px)); margin: 0 auto; padding: 100px 0 60px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; margin-bottom: 14px; }
.back-link:hover { color: var(--text); }
.panel-card { padding: 20px; border-radius: 22px; background: linear-gradient(160deg, rgba(24, 31, 54, .92), rgba(10, 14, 26, .96)); border: 1px solid var(--line); }
.panel-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; margin-bottom: 14px; }
.panel-title i { color: var(--cyan); font-size: 20px; }
.panel-title .right { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 500; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.kv:last-child { border-bottom: none; }
.kv span { color: var(--muted); }
.kv b { font-family: var(--font-mono); font-weight: 600; text-align: right; }
.form-row { display: flex; gap: 8px; margin-top: 10px; }
.form-row input, .form-row select {
  flex: 1; min-width: 0; height: 42px; padding: 0 12px; border-radius: 12px; outline: none;
  background: rgba(0, 0, 0, .3); border: 1px solid var(--line); font-family: var(--font-mono); font-size: 13px;
}
.form-row select { font-family: var(--font-body); }
.form-row input:focus, .form-row select:focus { border-color: var(--gold); }
.form-row .btn { width: auto; height: 42px; padding: 0 16px; font-size: 13px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 8px; line-height: 1.45; }
.hint a { color: var(--gold); }
.progress { height: 10px; border-radius: 10px; background: rgba(255, 255, 255, .06); overflow: hidden; margin: 8px 0 4px; }
.progress div { height: 100%; border-radius: 10px; background: var(--grad); box-shadow: 0 0 14px rgba(255, 201, 74, .4); }
select option { background: #0e1322; color: var(--text); }
.co-tabs.two { grid-template-columns: repeat(2, 1fr); max-width: 400px; }
.co-tabs.two .seg-glider { width: calc((100% - 8px) / 2); }

/* Live weather */
.wx-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; background: rgba(255, 255, 255, .06); color: var(--muted); white-space: nowrap; }
.wx-badge.wet { background: rgba(56, 189, 248, .14); color: #8fdcff; }
.wx-badge.dry { background: rgba(255, 138, 92, .14); color: #ffb08f; }
.bd-wx { margin: -6px 0 14px; }
.wx-badge.war { background: rgba(255, 77, 109, .14); color: #ff9aae; }
.kv > span:last-child .wx-badge { margin-left: 4px; }
.type-q.state { background: rgba(255, 201, 74, .15); color: var(--gold); border: 1px solid rgba(255, 201, 74, .4); }

/* The build panel: the cost column stays on one line, and the parts breathe */
.levels td:last-child, .levels th:last-child { white-space: nowrap; }
.levels td { padding: 9px 6px; }
.levels th { padding-bottom: 8px; }
.recipe { padding: 14px 12px; }
.bd-rich { margin-top: 4px; }
.bd-use { margin: 18px 0; }

/* One product and nothing to feed it: a slim row instead of a tall, mostly empty box */
.recipe.single { padding: 8px 10px; }
.recipe.single .res-chip { flex-direction: row; align-items: center; gap: 10px; width: 100%; justify-content: center; padding: 6px 10px; }
.recipe.single .res-chip span { font-size: 20px; line-height: 1; }
.recipe.single .res-chip em { margin-left: 2px; }

/* The level table: steady columns, headers sitting on their own column */
.levels { table-layout: fixed; }
.levels th { vertical-align: bottom; white-space: nowrap; }
.levels th:first-child, .levels td:first-child { width: 92px; } /* room for Q5 and its five stars */
.levels th:last-child, .levels td:last-child { width: 104px; }

/* Less of the page's colour bleeds through the panel, so the text stays crisp */
.builder.glass { background: rgba(12, 17, 30, .94); backdrop-filter: blur(22px) saturate(1.05); }
