/* ============================================
   Job List Editor - Styles
   ============================================ */

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

:root {
    --bg-primary: #0f172a;
    --bg-surface: #1e293b;
    --bg-elevated: #273548;
    --bg-input: #16233a;
    --accent: #fbbf24;
    --accent-solid: #f59e0b;
    --accent-deep: #b45309;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-dim: #64748b;
    --border: rgba(255, 255, 255, 0.08);
    --border-light: rgba(255, 255, 255, 0.14);
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --error: #f87171;
    --error-bg: rgba(248, 113, 113, 0.12);
    --warn: #fbbf24;
    --warn-bg: rgba(250, 204, 21, 0.12);
    --info: #60a5fa;
    --ok: #4ade80;
    --mono: 'SF Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
}

[hidden] { display: none !important; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

code { font-family: var(--mono); font-size: 0.9em; }

/* ---- header ---- */
.header { background: var(--bg-surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.header-inner {
    max-width: 1500px; margin: 0 auto; padding: 0.85rem 1.5rem;
    display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
}
.header-left { display: flex; align-items: center; gap: 0.9rem; }
.logo {
    width: 42px; height: 42px; flex: none; border-radius: var(--radius);
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--accent-solid), var(--accent-deep)); color: #1a1205;
}
.header-title { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; }
.header-subtitle { font-size: 0.83rem; color: var(--text-secondary); }
.header-subtitle code { color: var(--accent); }
.header-right { display: flex; gap: 0.5rem; align-items: center; }

/* ---- buttons ---- */
.btn {
    display: inline-flex; align-items: center; gap: 0.45rem;
    padding: 0.5rem 0.85rem; border-radius: var(--radius-sm); border: 1px solid var(--border-light);
    background: var(--bg-elevated); color: var(--text-primary);
    font-family: inherit; font-size: 0.84rem; font-weight: 500; cursor: pointer;
    transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover:not(:disabled) { background: #31415a; border-color: var(--accent-solid); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-ghost { background: transparent; }
.btn-primary { background: var(--accent-solid); border-color: var(--accent-solid); color: #1a1205; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); }
.btn-check { border-color: var(--accent-solid); color: var(--accent); }
.btn-sm { padding: 0.32rem 0.6rem; font-size: 0.78rem; }
.btn-add { padding: 0.28rem 0.6rem; font-size: 0.74rem; align-self: flex-start; }

/* ---- options bar ---- */
.options-bar { background: var(--bg-primary); border-bottom: 1px solid var(--border); position: sticky; top: 71px; z-index: 30; }
.options-inner {
    max-width: 1500px; margin: 0 auto; padding: 0.6rem 1.5rem;
    display: flex; align-items: center; gap: 1.6rem; flex-wrap: wrap;
}
.opt-group { display: flex; align-items: center; gap: 0.5rem; }
.push-right { margin-left: auto; }
.opt-label { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); font-weight: 600; }
.file-name { font-family: var(--mono); font-size: 0.82rem; color: var(--text-secondary); }
.file-name.is-dirty { color: var(--accent); }

/* ---- layout ---- */
.main { max-width: 1500px; margin: 0 auto; padding: 1.5rem; }

.empty { display: grid; place-items: center; padding: 4rem 1rem; }
.empty-inner { max-width: 560px; text-align: center; }
.empty-inner h2 { font-size: 1.4rem; margin-bottom: 0.7rem; }
.empty-inner p { color: var(--text-secondary); margin-bottom: 0.7rem; }
.empty-inner code { color: var(--accent); }
.empty-note { font-size: 0.85rem; color: var(--text-dim); }

.workspace { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 1.25rem; align-items: start; }

/* ---- sidebar ---- */
.sidebar { position: sticky; top: 130px; display: flex; flex-direction: column; gap: 1rem; max-height: calc(100vh - 150px); }
.side-block { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.75rem; }
.side-grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-title { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); font-weight: 700; margin-bottom: 0.5rem; }
.side-hint { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text-dim); opacity: 0.75; }

.entry-list, .section-list { list-style: none; overflow-y: auto; }
.entry-list { max-height: 170px; }
.section-list { flex: 1; min-height: 0; }
.entry-item, .section-item {
    padding: 0.38rem 0.55rem; border-radius: var(--radius-sm); cursor: pointer;
    font-size: 0.85rem; color: var(--text-secondary); transition: background 0.12s, color 0.12s;
}
.entry-item:hover, .section-item:hover { background: var(--bg-elevated); color: var(--text-primary); }
.entry-item.active, .section-item.active { background: var(--accent-solid); color: #1a1205; font-weight: 600; }
.entry-item { display: flex; gap: 0.5rem; }
.entry-index { font-family: var(--mono); opacity: 0.7; }
.entry-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- fields ---- */
.panel { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; min-height: 60vh; }
.section-note {
    font-size: 0.83rem; color: var(--text-secondary); background: var(--bg-input);
    border-left: 3px solid var(--accent-solid); border-radius: var(--radius-sm);
    padding: 0.6rem 0.8rem; margin-bottom: 1.1rem;
}
.fields { display: flex; flex-direction: column; }

.row {
    display: grid; grid-template-columns: 300px minmax(0, 1fr);
    gap: 0.25rem 1rem; padding: 0.7rem 0; border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: none; }
.row-label { display: flex; flex-direction: column; }
.row-name { font-weight: 600; font-size: 0.9rem; }
.row-key { color: var(--text-dim); font-size: 0.76rem; }
.row-field { display: flex; align-items: flex-start; gap: 0.6rem; flex-wrap: wrap; }
.row-help { grid-column: 2; font-size: 0.8rem; color: var(--text-dim); }
.row.is-absent .row-name { color: var(--text-dim); }
.row.is-obsolete .row-name { text-decoration: line-through; opacity: 0.7; }

/* ---- controls ---- */
.ctl-text, .ctl-number, .ctl-select {
    background: var(--bg-input); border: 1px solid var(--border-light); border-radius: var(--radius-sm);
    color: var(--text-primary); font-family: inherit; font-size: 0.86rem; padding: 0.4rem 0.6rem;
}
.ctl-text { width: min(100%, 460px); }
.ctl-path { font-family: var(--mono); font-size: 0.8rem; }
.ctl-number { width: 170px; font-family: var(--mono); }
.ctl-select { min-width: 300px; max-width: 100%; }
.ctl-text:focus, .ctl-number:focus, .ctl-select:focus { outline: 2px solid var(--accent-solid); outline-offset: -1px; }
.ctl-text:disabled, .ctl-number:disabled, .ctl-select:disabled { opacity: 0.45; }
.ctl-check { width: 17px; height: 17px; accent-color: var(--accent-solid); margin-top: 0.35rem; cursor: pointer; }
.ctl-flags {
    display: flex; flex-direction: column; gap: 0.15rem; max-height: 190px; overflow-y: auto;
    background: var(--bg-input); border: 1px solid var(--border-light); border-radius: var(--radius-sm);
    padding: 0.45rem 0.6rem; min-width: 320px;
}
.ctl-flags label { display: flex; align-items: center; gap: 0.45rem; font-size: 0.82rem; color: var(--text-secondary); cursor: pointer; }
.ctl-flags input { accent-color: var(--accent-solid); cursor: pointer; }

/* ---- advanced grid ---- */
.raw-grid { width: 100%; border-collapse: collapse; }
.raw-grid th {
    text-align: left; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-dim); padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border-light);
}
.raw-grid td { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.raw-grid td code { color: var(--accent); }
.raw-grid .ctl-text { width: 100%; }

/* ---- explainer ---- */
.explain { margin-top: 2.5rem; }
.explain-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.9rem; }
.explain-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 1rem; }
.explain-card { background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; }
.explain-card h3 { font-size: 0.92rem; font-weight: 600; margin-bottom: 0.45rem; display: flex; align-items: center; gap: 0.5rem; }
.explain-card p { font-size: 0.85rem; color: var(--text-secondary); }
.explain-card code { color: var(--accent); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.dot-keep { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-check { background: var(--info); }
.dot-priv { background: var(--accent-solid); }

/* ---- modal ---- */
.modal { position: fixed; inset: 0; background: rgba(2, 6, 23, 0.72); display: grid; place-items: center; z-index: 200; padding: 1.5rem; }
.modal-card {
    background: var(--bg-surface); border: 1px solid var(--border-light); border-radius: var(--radius-lg);
    width: min(980px, 100%); max-height: 85vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-head h2 { font-size: 1rem; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-secondary); font-size: 1.6rem; line-height: 1; cursor: pointer; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { overflow-y: auto; padding: 0.5rem 1.25rem 1rem; }
.modal-foot { padding: 0.85rem 1.25rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }

.issues { width: 100%; border-collapse: collapse; }
.issues td { padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--border); font-size: 0.85rem; vertical-align: top; }
.issue-level { text-transform: uppercase; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em; width: 74px; white-space: nowrap; }
.issue-key { width: 190px; }
.issue-key code { color: var(--accent); }
.lvl-error .issue-level { color: var(--error); }
.lvl-warning .issue-level { color: var(--warn); }
.lvl-info .issue-level { color: var(--info); }
.lvl-error { background: var(--error-bg); }
.lvl-warning { background: var(--warn-bg); }

/* ---- toast + drop veil ---- */
.toast {
    position: fixed; bottom: 1.3rem; left: 50%; transform: translate(-50%, 1.5rem);
    background: var(--bg-elevated); border: 1px solid var(--border-light); border-radius: var(--radius);
    padding: 0.6rem 1rem; font-size: 0.85rem; opacity: 0; pointer-events: none;
    transition: opacity 0.2s, transform 0.2s; z-index: 300; max-width: min(90vw, 620px);
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { border-color: var(--error); color: var(--error); }

.drop-veil {
    position: fixed; inset: 0; display: none; place-items: center; z-index: 250;
    background: rgba(15, 23, 42, 0.86); border: 3px dashed var(--accent-solid);
    font-size: 1.15rem; font-weight: 600; color: var(--accent);
}
.drop-veil.on { display: grid; }

/* ---- responsive ---- */
@media (max-width: 980px) {
    .workspace { grid-template-columns: 1fr; }
    .sidebar { position: static; max-height: none; flex-direction: row; flex-wrap: wrap; }
    .side-block { flex: 1 1 240px; }
    .section-list { max-height: 210px; }
    .row { grid-template-columns: 1fr; }
    .row-help { grid-column: 1; }
}
@media (max-width: 640px) {
    .header-inner, .options-inner, .main { padding-left: 1rem; padding-right: 1rem; }
    .options-bar { position: static; }
    .sidebar { position: static; }
}
