:root {
  --bg: #0b0e12; --panel: #141920; --panel2: #1b222b; --line: #26303b;
  --text: #d8dee6; --muted: #7d8a99; --accent: #d9a441; --ok: #4fb37a; --bad: #d4574e; --alpha: #4a6a8a;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 6px; }
h2 { font-size: 15px; margin: 0 0 10px; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.r { text-align: right; }

.top { display: flex; align-items: center; gap: 20px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: #0f141a; }
.brand { font-weight: 700; color: var(--text); font-size: 16px; }
.top nav { display: flex; gap: 14px; align-items: center; flex: 1; }
.langs { color: var(--muted); font-size: 12px; }
main { max-width: 1180px; margin: 0 auto; padding: 18px 16px 40px; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; border-top: 1px solid var(--line); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; margin-bottom: 14px; }
.panel.narrow { max-width: 720px; margin-left: auto; margin-right: auto; }
.btn { display: inline-block; background: var(--accent); color: #111; border: 0; border-radius: 4px; padding: 7px 14px; font-weight: 600; cursor: pointer; font-size: 14px; white-space: nowrap; }
.btn:hover { text-decoration: none; filter: brightness(1.1); }
.btn.big { padding: 10px 18px; margin: 8px 0; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.danger { background: var(--bad); color: #fff; }
.row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }

input[type=text], input[type=search], textarea, select, input.copy {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 4px; padding: 7px 9px; font: inherit; width: 100%;
}
label { display: block; margin: 10px 0; color: var(--muted); }
label input, label textarea { margin-top: 4px; color: var(--text); }
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { width: auto; margin: 0; }
form button { margin-top: 6px; }

.filters { display: flex; gap: 10px; margin-bottom: 14px; }
.filters input { flex: 1; }
.filters select { width: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 10px; }
.card { display: flex; gap: 12px; align-items: center; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 10px; color: var(--text); }
.card:hover { border-color: var(--accent); text-decoration: none; }
.pt { width: 64px; height: 64px; border-radius: 4px; background: #222; flex: none; }
.ci { flex: 1; min-width: 0; }
.cn { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs { color: var(--accent); }
.cc { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.price { color: var(--ok); font-weight: 700; white-space: nowrap; }
.price.big { font-size: 20px; align-self: flex-start; }

.head { display: flex; gap: 18px; align-items: flex-start; }
.ptl { width: 128px; height: 128px; border-radius: 4px; background: #222; flex: none; }
.hi { flex: 1; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 8px; margin-top: 10px; }
.stats .k { display: block; color: var(--muted); font-size: 12px; }
.stats .v { font-size: 16px; font-weight: 600; }
.badges { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--panel2); border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.bad { color: var(--bad); border-color: var(--bad); }
.warn { background: #3a2a14; border: 1px solid #7a5a22; padding: 8px 12px; border-radius: 4px; }
.ok { color: var(--ok); }

.tabs { display: flex; gap: 2px; margin-bottom: 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }
.toolbar { margin-bottom: 10px; text-align: right; }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr)); gap: 14px; align-items: start; }
.cols3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); gap: 14px; align-items: start; }
.sgrid { columns: 3 340px; column-gap: 14px; }
.sg { break-inside: avoid; }
table { width: 100%; border-collapse: collapse; }
td { padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.note { white-space: pre-wrap; }

ul.skills, ul.plain { list-style: none; margin: 0; padding: 0; }
ul.skills li { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 3px 0; border-bottom: 1px dashed #1f2832; }
ul.skills li.untrained { color: #56616d; }
ul.plain li { padding: 3px 0; display: flex; gap: 8px; align-items: center; }
/* Skill and ship names wrap instead of being cut: the English names of Serenity-only items
   run long ("Solarflare Heavy Assault Missile Specialization Research"), and clipping them
   also swallowed the "Serenity only" badge that sits after the name. */
.sn { min-width: 0; padding-right: 8px; overflow-wrap: anywhere; }
.lv { display: inline-flex; gap: 2px; flex: none; }
.lv i { width: 9px; height: 9px; border: 1px solid #44505d; display: inline-block; }
.lv i.on { background: var(--accent); border-color: var(--accent); }
.lv i.alpha { background: var(--alpha); border-color: var(--alpha); }
.ico { vertical-align: middle; border-radius: 2px; }

ol.steps li { margin: 10px 0 16px; }
ol.steps form { display: flex; gap: 8px; margin-top: 8px; }
ol.steps form button { margin: 0; flex: none; }

/* Long values must not push a table wider than the phone. */
td, .note { overflow-wrap: anywhere; }

@media (max-width: 640px) {
  main { padding: 14px 12px 32px; }
  .top { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .brand { font-size: 14px; }
  /* The nav must not squeeze the button into two lines; the language switcher wraps instead. */
  .top nav { flex: none; }
  .langs { margin-left: auto; }
  h1 { font-size: 19px; }
  /* Portrait above the name instead of beside it, and smaller. */
  .head { flex-direction: column; gap: 12px; }
  .ptl { width: 88px; height: 88px; }
  /* Four stats fit as two rows of two rather than one long column. */
  .stats { grid-template-columns: 1fr 1fr; gap: 6px; }
  .stats .v { font-size: 15px; }
  /* Seven tabs have to wrap, so trim the padding to fit more per row. */
  .tabs a { padding: 8px 10px; }
  .sgrid { columns: 1; }
  .toolbar { text-align: left; }
  .filters { flex-wrap: wrap; }
  .panel { padding: 12px; }
}

.srn { font-size: 10px; color: #e07b4a; border: 1px solid #e07b4a; border-radius: 3px; padding: 0 4px; white-space: nowrap; vertical-align: 1px; }
.tn[title] { border-bottom: 1px dotted #44505d; cursor: help; }
.ign { font-size: 12px; color: var(--muted); margin: -2px 0 4px; }
.ign b { color: var(--text); font-weight: 600; }
details.orig { margin-top: 10px; color: var(--muted); font-size: 12px; }
details.orig summary { cursor: pointer; }
details.orig .note { margin-top: 6px; color: var(--muted); }
.sr { display: inline-flex; gap: 8px; align-items: center; flex: none; }
.mst { display: inline-flex; gap: 6px; align-items: center; cursor: help; }
.mst b { width: 22px; font-size: 12px; color: var(--accent); }
ul.ships li { padding: 3px 0; }
ul.ships .ico { margin-right: 4px; }
img.ship { border-radius: 3px; background: #161c24; }

/* Attribute rows: a flex line keeps icon and label on one baseline and the labels
   in a straight column, whatever the icon's own padding looks like. */
.attr, .ent { display: flex; align-items: center; gap: 8px; line-height: 1; }
.attr img, .ent img { flex: none; display: block; border-radius: 3px; }
.attrs td { height: 30px; }
/* Holds the logo's place when an entity has none, so names stay in one column. */
.nologo { flex: none; display: block; width: 20px; height: 20px; }
/* Skill group icon in the panel heading. */
.gico { vertical-align: -3px; margin-right: 6px; opacity: .85; }
