:root {
  --bg: #080b10;
  --panel: #0f151d;
  --panel-2: #131b25;
  --side: #0d1219;
  --line: #1e2632;
  --line-2: #253040;
  --text: #e6edf3;
  --text-2: #c5ced9;
  --muted: #8b96a5;
  --accent: #f0b429;
  --accent-2: #7fd4e3;
  --danger: #ff7b72;
  --ok: #56d27a;
  --mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 "IBM Plex Sans KR", "Pretendard", "Malgun Gothic", system-ui, sans-serif;
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .75rem; color: var(--accent); }
.card h2 { margin-top: 0; }

/* 화면 뼈대: 왼쪽 메뉴 + 본문 (좁은 화면에서는 메뉴가 위로) */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.sidebar {
  flex: 1 1 232px; max-width: 100%; background: var(--side); border-right: 1px solid var(--line);
  padding: 1.5rem 1rem; display: flex; flex-direction: column; gap: 1.5rem;
}
.main-col { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: .6rem; padding: 0 .5rem; color: var(--accent); font-weight: 700; font-size: 1.1rem; letter-spacing: .08em; }
.brand:hover { text-decoration: none; }
.side-nav { display: flex; flex-direction: column; gap: 1.2rem; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: .7rem; font-weight: 600; letter-spacing: .12em; color: var(--muted); padding: 0 .6rem .35rem; }
.side-nav a {
  display: flex; align-items: center; justify-content: space-between; min-height: 36px;
  padding: 0 .6rem; border-radius: 6px; color: var(--text-2);
}
.side-nav a:hover { background: #151d29; color: var(--text); text-decoration: none; }
.side-nav a.active { background: #1a2230; color: var(--accent); font-weight: 600; }
.nav-badge { font-size: .7rem; font-weight: 600; background: #3a2a0a; color: var(--accent); border-radius: 10px; padding: 0 .5rem; }

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 1rem;
  padding: .9rem 2rem; background: #0b0f15; border-bottom: 1px solid var(--line);
}
.top-search {
  flex: 1 1 260px; display: flex; align-items: center; gap: .5rem; height: 40px; padding: 0 .9rem;
  border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); color: var(--muted); margin: 0;
}
.top-search input[type=search] { flex: 1; min-width: 0; border: 0; background: transparent; padding: 0; outline: none; }
.clocks { display: flex; gap: 1.2rem; font-family: var(--mono); font-size: .85rem; }
.who { display: flex; align-items: center; gap: .75rem; }
.who form { margin: 0; }
.who-chip { display: flex; align-items: center; gap: .5rem; color: var(--text); padding: 2px .75rem 2px 2px; border: 1px solid var(--line-2); border-radius: 22px; background: var(--panel); }
.who-chip:hover { text-decoration: none; border-color: var(--muted); }
.who-chip .avatar { border-radius: 50%; }

.container { max-width: 1200px; width: 100%; padding: 2rem; }
.shell.guest .container { margin: 0 auto; }
.footer { margin-top: auto; color: var(--muted); font-size: .8rem; padding: 1.5rem 2rem; border-top: 1px solid var(--line); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem; }
.login-card { max-width: 420px; margin: 4rem auto; text-align: center; }

.btn {
  display: inline-block; padding: .5rem 1rem; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: #18202b; color: var(--text); font: inherit;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1a1300; font-weight: 600; }
.btn-danger { color: var(--danger); }
.btn-small { padding: .2rem .6rem; font-size: .85rem; }
.btn-link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; }

.alert { padding: .75rem 1rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid var(--line); background: var(--panel); }
.alert-success { border-color: var(--ok); }
.alert-error { border-color: var(--danger); }
.alert-warning { border-color: var(--accent); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: .6rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 500; font-size: .85rem; }
.actions { display: flex; gap: .4rem; justify-content: flex-end; }
.actions form { margin: 0; }

.avatar { width: 32px; height: 32px; border-radius: 4px; vertical-align: middle; }
.portrait { width: 96px; height: 96px; border-radius: 6px; }
.char { display: flex; gap: 1rem; align-items: center; margin-bottom: 1rem; }
.char-name { font-size: 1.2rem; font-weight: 600; }
.org { display: flex; align-items: center; gap: .4rem; color: var(--muted); }
.org img { width: 24px; height: 24px; }
.state { font-size: 1.4rem; font-weight: 700; color: var(--accent); margin: 0 0 .25rem; }
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; background: #222c3a; font-size: .75rem; }
.tags { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.tags li { background: #18202b; border: 1px solid var(--line); border-radius: 999px; padding: .1rem .7rem; font-size: .85rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* 2단계: 시장·캐릭터 */
.search { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.search input { flex: 1; min-width: 200px; }
input[type=search], input[type=number], textarea {
  background: #0b1017; color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: .5rem .7rem; font: inherit;
}
textarea { width: 100%; margin-bottom: .75rem; font-family: ui-monospace, Consolas, monospace; font-size: .9rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: .75rem; }
.inline-form input[type=number] { width: 6rem; padding: .25rem .4rem; }
.num-table td:not(:first-child), .num-table th:not(:first-child), td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.item-head { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.item-head h1 { margin: 0; }
.item-head .btn { margin-left: auto; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .5rem 1rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }
.chart-box { position: relative; height: 320px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .75rem; }
.stats { margin-bottom: 1rem; }
.big { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.pos { color: var(--ok); }
.neg { color: var(--danger); }
.warn { color: var(--accent); }
.fold { margin-bottom: .5rem; padding: .75rem 1rem; }
.fold summary { cursor: pointer; }
.fold .table { margin-top: .5rem; }

/* 3단계: 코퍼레이션 */
select { background: #0b1017; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: .25rem .4rem; font: inherit; }
tr.selected td { background: #1c2230; }
.fuel { font-weight: 600; }
.fuel-ok { color: var(--ok); }
.fuel-warning { color: var(--accent); }
.fuel-critical, .fuel-expired { color: var(--danger); }
.fuel-none { color: var(--muted); }

/* 4단계: 작전 */
.form-card { max-width: 640px; }
.field { margin-bottom: .9rem; display: flex; flex-direction: column; gap: .25rem; }
.field label { color: var(--muted); font-size: .9rem; }
.field input[type=text], .field input[type=number], .field input[type=datetime-local], .field select, .field textarea,
input[type=text] {
  background: #0b1017; color: var(--text); border: 1px solid var(--line); border-radius: 6px; padding: .45rem .6rem; font: inherit;
}
.field ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
.check { display: block; padding: .3rem 0; }
[data-time].soon { color: var(--accent); font-weight: 600; }
[data-time].past { color: var(--muted); }
.imp-badge-important { background: #5a3d00; }
.imp-badge-cta { background: #6e1b1b; }
tr.imp-cta td { background: rgba(229, 83, 75, .07); }
.side-friendly .side-label { color: var(--accent-2); }
.side-hostile .side-label { color: var(--danger); }
.side-neutral .side-label { color: var(--muted); }
.srp-form { display: flex; flex-direction: column; gap: .3rem; min-width: 220px; }
.srp-form input { padding: .25rem .4rem; }
.srp-pending { color: var(--accent); }
.srp-approved { color: var(--accent-2); }
.srp-paid { color: var(--ok); }
.srp-rejected { color: var(--danger); }

/* 언어 선택 */
.lang-form { margin: 0; }
.lang-form select { padding: .15rem .3rem; font-size: .85rem; }

/* 대시보드 */
.hero {
  display: flex; flex-wrap: wrap; align-items: center; gap: 1.5rem; padding: 1.5rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; margin-bottom: 1.5rem;
}
.hero .portrait { width: 88px; height: 88px; border-radius: 10px; border: 1px solid #2b5366; }
.hero-main { flex: 1 1 260px; display: flex; flex-direction: column; gap: .2rem; }
.hero-main h1 { margin: 0; font-size: 1.6rem; }
.eyebrow { font-size: .75rem; color: var(--muted); letter-spacing: .1em; }
.hero .org { color: var(--text-2); }
.hero-side { display: flex; flex-direction: column; align-items: flex-end; gap: .6rem; }
.hero-side form { margin: 0; }
.pills { display: flex; flex-wrap: wrap; gap: .5rem; }
.pill { padding: .3rem .75rem; border-radius: 999px; background: #18202b; color: var(--text-2); font-size: .82rem; }
.pill-ok { background: #10301c; color: var(--ok); font-weight: 600; }
.pill-warn { background: #3a2a0a; color: var(--accent); font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.25rem; display: flex; flex-direction: column; gap: .3rem; }
.kpi-label { font-size: .82rem; color: var(--muted); }
.kpi-value { font-family: var(--mono); font-size: 1.75rem; font-weight: 600; color: var(--accent); line-height: 1.2; }
.kpi-sub { font-size: .75rem; color: var(--muted); }
.panels { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin-bottom: .9rem; }
.panel-head h2 { margin: 0; font-size: 1rem; color: var(--text); font-weight: 600; }
.panel-head a { font-size: .85rem; }
.bars { height: 160px; display: flex; align-items: flex-end; gap: 3px; border-bottom: 1px solid var(--line-2); padding-bottom: 2px; }
.bars span { flex: 1; min-height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; opacity: .8; }
.bars span:last-child { opacity: 1; }
.bars-axis { display: flex; justify-content: space-between; font-family: var(--mono); font-size: .7rem; color: var(--muted); margin-top: .35rem; }
.op-row { display: flex; align-items: center; gap: .9rem; padding: .7rem .8rem; border-radius: 8px; background: var(--panel-2); margin-bottom: .5rem; color: var(--text); }
.op-row:hover { text-decoration: none; background: #18222f; }
.op-time { width: 60px; text-align: center; font-family: var(--mono); }
.op-time strong { display: block; font-size: 1rem; }
.op-time small { font-size: .7rem; color: var(--muted); }
.op-body { flex: 1; min-width: 0; }
.op-body strong { display: block; }
.op-left { font-size: .8rem; font-weight: 600; color: var(--accent-2); white-space: nowrap; }
.timer-row { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid #1a2230; }
.timer-row:last-child { border-bottom: 0; }
.timer-left { font-family: var(--mono); font-size: .85rem; white-space: nowrap; }
.ttag { font-size: .7rem; font-weight: 600; padding: .1rem .5rem; border-radius: 4px; background: #13283a; color: var(--accent-2); white-space: nowrap; }
.ttag-armor { background: #3a2a0a; color: var(--accent); }
.ttag-hull { background: #3a1414; color: var(--danger); }

/* 로그인 */
.login-page { display: flex; flex-wrap: wrap; min-height: 100vh; }
.login-hero {
  flex: 1 1 520px; position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between;
  gap: 2rem; padding: 3rem; background: #0b1119; border-right: 1px solid var(--line); min-height: 420px;
}
.login-hero > svg.orbit { position: absolute; inset: 0; width: 100%; height: 100%; }
.login-hero > *:not(.orbit) { position: relative; }
.login-hero h1 { font-size: 2.6rem; line-height: 1.2; margin: 0 0 1rem; max-width: 30rem; }
.login-hero p { color: var(--text-2); margin: 0; max-width: 28rem; font-size: 1.05rem; }
.login-side { flex: 1 1 440px; display: flex; align-items: center; justify-content: center; padding: 3rem 1.5rem; }
.login-box { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 1.6rem; }
.login-box h2 { color: var(--text); font-size: 1.6rem; margin: 0 0 .3rem; }
.btn-sso {
  display: flex; align-items: center; justify-content: center; gap: .75rem; height: 56px; border-radius: 10px;
  background: var(--accent); color: #1a1300; font-size: 1.05rem; font-weight: 700;
}
.btn-sso:hover { text-decoration: none; background: #ffc24a; }
.checklist { margin: 0; padding: 1.2rem; list-style: none; display: flex; flex-direction: column; gap: .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--text-2); font-size: .92rem; }
.checklist li { display: flex; gap: .6rem; }
.checklist li::before { content: "✓"; color: var(--ok); }
.login-foot { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; }

/* 로컬 분석: 성향 태그·위험도 */
.alert-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .75rem; }
.alert-tile { display: flex; flex-direction: column; gap: .3rem; padding: .8rem; border-radius: 8px; background: var(--panel-2); }
.alert-tile .ptag { align-self: flex-start; }
.ptags { display: flex; flex-wrap: wrap; gap: .3rem; }
.ptag { font-size: .72rem; font-weight: 600; padding: .1rem .5rem; border-radius: 4px; background: #18202b; color: var(--text-2); white-space: nowrap; }
.ptag-cyno, .ptag-covert_cyno, .ptag-industrial_cyno { background: #4a1414; color: #ffb4ae; }
.ptag-blops, .ptag-super { background: #3a1430; color: #f2a7e0; }
.ptag-recon, .ptag-covert_cyno_possible { background: #3a2a0a; color: var(--accent); }
.ptag-capital { background: #2c1f4a; color: #c9b5ff; }
.ptag-dictor, .ptag-covert { background: #13283a; color: var(--accent-2); }
.ptag-solo, .ptag-large_fleet { background: #18202b; color: var(--text-2); border: 1px solid var(--line-2); }
.danger { display: flex; align-items: center; gap: .5rem; white-space: nowrap; font-size: .85rem; }
.danger-bar { width: 56px; height: 6px; border-radius: 3px; background: #1a2230; overflow: hidden; }
.danger-bar span { display: block; height: 100%; }
.danger-high .danger-bar span { background: var(--danger); }
.danger-mid .danger-bar span { background: var(--accent); }
.danger-low .danger-bar span { background: var(--ok); }
.danger-high { color: var(--danger); }
.row-friendly td { background: rgba(86, 210, 122, .05); }
