@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@400;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg-color:        #121212;
    --primary-color:   #1e1e1e;
    --secondary-color: #2a2a2a;
    --text-color:      #e0e0e0;
    --text-subtle:     #aaa;
    --accent-color:    #e8d900;
    --accent-hover:    #f5e53b;
    --header-font:     'Titillium Web', sans-serif;

    --safe:   #4caf50;
    --mod:    #ffc107;
    --high:   #f44336;
    --sb:     #ce93d8;
    --bub:    #4fc3f7;
    --avoid:  #777;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--header-font);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
header {
    text-align: center;
    padding: 3rem 1rem 2rem;
}

.logo { max-width: 120px; margin-bottom: 1.5rem; }

header h1 {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 0.4rem;
    color: #fff;
}
header h1 span { color: var(--accent-color); }
header .subtitle { font-size: 1.1rem; color: var(--text-subtle); }

.back-link {
    position: absolute;
    top: 20px;
    left: 20px;
    color: var(--text-subtle);
    text-decoration: none;
    font-size: 1rem;
    transition: color 0.2s;
}
.back-link:hover { color: var(--accent-color); }

/* ── Form card ──────────────────────────────────────────────────────────── */
.form-card {
    background-color: var(--primary-color);
    border: 1px solid var(--secondary-color);
    border-radius: 8px;
    padding: 24px;
    margin-bottom: 16px;
}

.form-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 130px; }
.field.short { flex: 0 0 130px; }
.avoid-field { margin-top: 14px; }

label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    font-weight: 600;
}

input, select {
    background-color: var(--secondary-color);
    border: 1px solid #3a3a3a;
    border-radius: 5px;
    color: var(--text-color);
    padding: 9px 12px;
    font-size: 14px;
    font-family: var(--header-font);
    outline: none;
    width: 100%;
    transition: border-color 0.2s;
}
input:focus, select:focus { border-color: var(--accent-color); }
select option { background: var(--secondary-color); }

button {
    background-color: var(--accent-color);
    color: #111;
    border: none;
    border-radius: 5px;
    padding: 10px 26px;
    font-size: 15px;
    font-weight: 700;
    font-family: var(--header-font);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    align-self: flex-end;
    transition: background-color 0.2s, transform 0.15s;
}
button:hover { background-color: var(--accent-hover); transform: translateY(-1px); }
button:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.spinner {
    width: 14px; height: 14px;
    border: 2px solid rgba(0,0,0,0.25);
    border-top-color: #111;
    border-radius: 50%;
    animation: spin 0.65s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

.error {
    margin-top: 12px;
    color: var(--high);
    font-size: 13px;
    padding: 8px 12px;
    background: rgba(244,67,54,0.1);
    border: 1px solid rgba(244,67,54,0.3);
    border-radius: 5px;
}

/* ── Legend ─────────────────────────────────────────────────────────────── */
section.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    padding: 12px 0;
    border-top: 1px solid var(--secondary-color);
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-subtle);
}
.leg-item { display: flex; align-items: center; gap: 7px; }
.dot {
    width: 13px; height: 13px;
    border-radius: 3px;
    flex-shrink: 0;
}
.dot.safe      { background: var(--safe); }
.dot.moderate  { background: var(--mod); }
.dot.high      { background: var(--high); }
.dot.smartbomb { background: #9c27b0; }
.dot.bubble    { background: #0277bd; }
.dot.avoided   { background: #555; }

section.icon-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    margin: -8px 0 16px;
    font-size: 13px;
    color: var(--text-subtle);
}

.emoji {
    width: 18px;
    text-align: center;
    display: inline-block;
}

/* ── Summary ────────────────────────────────────────────────────────────── */
.summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.sum-box {
    background-color: var(--primary-color);
    border: 1px solid var(--secondary-color);
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}
.sum-val   { font-size: 28px; font-weight: 700; color: #fff; }
.sum-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    margin-top: 4px;
}

/* ── Results table ──────────────────────────────────────────────────────── */
.results {
    background-color: var(--primary-color);
    border: 1px solid var(--secondary-color);
    border-radius: 8px;
    overflow: hidden;
}

.results-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 16px;
    border-bottom: 1px solid var(--secondary-color);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
}
.eve-time { font-variant-numeric: tabular-nums; color: var(--accent-color); }

.route-head {
    display: grid;
    grid-template-columns: 36px 1fr 60px 60px 100px 110px 64px;
    padding: 8px 16px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    border-bottom: 1px solid var(--secondary-color);
    gap: 8px;
}

.route-row {
    display: grid;
    grid-template-columns: 36px 1fr 60px 60px 100px 110px 64px;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--secondary-color);
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: background-color 0.1s;
}
.route-row:last-child { border-bottom: none; }
.route-row:hover { background-color: var(--secondary-color); }

.route-row.row-safe     { border-left-color: var(--safe); }
.route-row.row-moderate { border-left-color: var(--mod); }
.route-row.row-high     { border-left-color: var(--high); }
.route-row.row-extreme  { border-left-color: var(--sb); }
.route-row.row-avoided  { border-left-color: #555; opacity: 0.55; }

.hop { color: var(--text-subtle); font-size: 12px; text-align: center; }

.sys-name { font-weight: 700; color: #fff; font-size: 14px; }
.sys-name.avoided { text-decoration: line-through; color: var(--text-subtle); }

.sec {
    font-size: 12px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    text-align: center;
}
.sec.hs { background: rgba(76,175,80,0.15);  color: var(--safe); }
.sec.ls { background: rgba(255,193,7,0.15);  color: var(--mod); }
.sec.ns { background: rgba(244,67,54,0.15);  color: var(--high); }

.kills {
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    padding: 2px 6px;
    border-radius: 4px;
}
.kills.k0   { color: var(--text-subtle); }
.kills.k12  { background: rgba(255,193,7,0.12);  color: var(--mod); }
.kills.k3   { background: rgba(244,67,54,0.12);  color: var(--high); }
.kills.ksb  { background: rgba(156,39,176,0.15); color: var(--sb); }
.kills.kbub { background: rgba(2,119,189,0.15);  color: var(--bub); }

.hazard-icons { font-size: 15px; letter-spacing: 3px; }

.status-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 4px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.status-badge.safe     { background: rgba(76,175,80,0.15);  color: var(--safe); }
.status-badge.moderate { background: rgba(255,193,7,0.15);  color: var(--mod); }
.status-badge.high     { background: rgba(244,67,54,0.15);  color: var(--high); }
.status-badge.extreme  { background: rgba(156,39,176,0.15); color: var(--sb); }
.status-badge.avoided  { background: rgba(85,85,85,0.2);    color: var(--avoid); }

.zkill-btn {
    font-size: 11px;
    color: var(--accent-color);
    text-decoration: none;
    padding: 3px 8px;
    border: 1px solid rgba(232,217,0,0.25);
    border-radius: 4px;
    white-space: nowrap;
    transition: background-color 0.15s;
}
.zkill-btn:hover { background-color: rgba(232,217,0,0.08); }

.detail-row {
    display: none;
    padding: 6px 16px 12px 60px;
    border-bottom: 1px solid var(--secondary-color);
    flex-wrap: wrap;
    gap: 6px;
}
.detail-row.open { display: flex; }
.detail-tag {
    font-size: 11px;
    padding: 2px 9px;
    border-radius: 4px;
    background: var(--secondary-color);
    border: 1px solid #3a3a3a;
    color: var(--text-subtle);
}
.detail-tag.warn {
    border-color: rgba(244,67,54,0.35);
    color: var(--high);
    background: rgba(244,67,54,0.08);
}

/* ── Footer ─────────────────────────────────────────────────────────────── */
footer {
    text-align: center;
    padding: 2rem;
    margin-top: 2rem;
    border-top: 1px solid var(--secondary-color);
    color: #777;
    font-size: 13px;
}
footer a { color: var(--accent-color); text-decoration: none; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    header h1 { font-size: 2rem; }
    .route-head, .route-row { grid-template-columns: 28px 1fr 50px 50px 80px; }
    .route-head > *:nth-child(n+6),
    .route-row  > *:nth-child(n+6) { display: none; }
    .summary { grid-template-columns: repeat(2, 1fr); }
    .form-row { flex-direction: column; }
    .field.short { flex: 1; }
    .back-link { position: static; display: block; text-align: center; margin-bottom: 1rem; }
}

/* ── Autocomplete ───────────────────────────────────────────────────────── */
.ac-wrap { position: relative; }

.ac-box {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--primary-color);
    border: 1px solid var(--accent-color);
    border-radius: 5px;
    z-index: 100;
    max-height: 220px;
    overflow-y: auto;
}

.ac-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-color);
    border-bottom: 1px solid var(--secondary-color);
}
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.active {
    background: var(--secondary-color);
    color: var(--accent-color);
}
.ac-match {
    color: var(--accent-color);
    font-weight: 700;
}

/* ── Gate names ─────────────────────────────────────────────────────────── */
.gate-names {
    font-size: 11px;
    color: var(--text-subtle);
    margin-top: 2px;
    font-style: italic;
}
