:root {
  --bg: #edf2f7;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --surface-3: #e9eef5;
  --ink: #172033;
  --muted: #667085;
  --line: #d5dde7;
  --line-strong: #aeb9c8;
  --navy: #172a46;
  --navy-2: #203a60;
  --accent: #f3b51b;
  --accent-ink: #3d2a00;
  --success: #18794e;
  --danger: #b42318;
  --warning: #a15c00;
  --info: #216ba5;
  --shadow: 0 18px 54px rgba(28, 45, 70, .13);
  --radius: 14px;
  --row-h: 42px;
  --timeline-header-h: 78px;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at 10% -10%, rgba(75,119,176,.18), transparent 34%), linear-gradient(180deg, #f4f7fb 0%, var(--bg) 100%);
  overflow: hidden;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
input, select, textarea { color: var(--ink); }
input[type="checkbox"] { accent-color: var(--navy-2); }

.app-shell { width: 100%; height: 100%; display: flex; flex-direction: column; min-height: 0; }
.topbar {
  height: 58px;
  flex: 0 0 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  color: #fff;
  background: linear-gradient(135deg, #172a46, #203d66);
  box-shadow: 0 3px 14px rgba(20,35,58,.18);
  z-index: 60;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; font-size: 15px; font-weight: 850; letter-spacing: -.2px; }
.brand-button { padding: 0; border: 0; background: transparent; text-align: left; }
.brand small { display: block; margin-top: 2px; color: #b9c8da; font-size: 9px; font-weight: 600; letter-spacing: .2px; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--accent-ink); background: var(--accent); font-size: 13px; font-weight: 950; box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }
.brand-mark.large { width: 54px; height: 54px; border-radius: 16px; font-size: 20px; }
.topbar-title { max-width: 44vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #e9eff7; font-size: 12px; }
.topbar-spacer, .spacer { flex: 1; }
.workspace-badge { padding: 5px 9px; border-radius: 999px; background: rgba(255,255,255,.1); color: #dce7f3; font-size: 10px; white-space: nowrap; }
.workspace-badge.online { color: #c8f0dd; }
.workspace-badge.offline { color: #ffe0a6; }

.btn {
  min-height: 35px;
  white-space: nowrap;
  word-break: keep-all;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-size: 11px;
  font-weight: 750;
  transition: background .12s, border-color .12s, transform .08s, box-shadow .12s;
}
.btn:hover { background: #f8fafc; border-color: #b5c1d0; }
.btn:active { transform: translateY(1px); }
.btn-primary { color: var(--accent-ink); background: var(--accent); border-color: #dda108; }
.btn-primary:hover { background: #ffc73d; }
.btn-dark { color: #fff; background: var(--navy-2); border-color: var(--navy-2); }
.btn-dark:hover { background: #294d7d; }
.btn-danger { color: var(--danger); background: #fff5f4; border-color: #f0c2bd; }
.btn-ghost { color: inherit; background: transparent; border-color: transparent; }
.btn-icon { width: 34px; min-width: 34px; padding: 0; }
.btn-small { min-height: 29px; padding: 4px 8px; border-radius: 7px; font-size: 10px; }

/* Loading / unlock */
.center-screen, .unlock-page { width: 100%; height: 100%; display: grid; place-items: center; padding: 24px; }
.loading-card, .unlock-card { width: min(520px, 100%); padding: 30px; border: 1px solid rgba(205,216,230,.9); border-radius: 22px; background: rgba(255,255,255,.94); box-shadow: var(--shadow); }
.loading-card { text-align: center; }
.loading-card h1 { margin: 16px 0 5px; }
.loading-card p { margin: 0; color: var(--muted); }
.loader { width: 38px; height: 38px; margin: auto; border: 4px solid #dce5ef; border-top-color: var(--navy-2); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.unlock-page { background: radial-gradient(circle at 20% 0%, rgba(243,181,27,.22), transparent 35%), linear-gradient(145deg, #172a46, #0e1c30); }
.unlock-card { color: var(--ink); }
.unlock-brand { display: flex; align-items: center; gap: 15px; margin-bottom: 26px; }
.unlock-brand h1 { margin: 0; font-size: 25px; }
.unlock-brand p { margin: 4px 0 0; color: var(--muted); }
.unlock-copy h2 { margin: 0 0 8px; }
.unlock-copy p { margin: 0 0 22px; color: var(--muted); line-height: 1.65; font-size: 12px; }
.unlock-card form label { display: block; margin-bottom: 7px; font-size: 11px; font-weight: 800; }
.unlock-input-row { display: flex; gap: 8px; }
.unlock-input-row input { flex: 1; min-width: 0; height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; outline: none; }
.unlock-input-row input:focus { border-color: #557cae; box-shadow: 0 0 0 3px rgba(85,124,174,.14); }
.unlock-foot { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 1.55; }

/* Dashboard */
.page { flex: 1; min-height: 0; overflow: auto; }
.dashboard-page { padding: 26px clamp(16px, 3vw, 42px); }
.hero { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(310px, .65fr); gap: 20px; margin: 0 auto 22px; max-width: 1520px; }
.hero-main, .hero-side { position: relative; overflow: hidden; padding: 28px; border: 1px solid rgba(207,217,230,.88); border-radius: 20px; background: rgba(255,255,255,.92); box-shadow: var(--shadow); backdrop-filter: blur(18px); }
.hero-main::after { content: ""; position: absolute; right: -80px; top: -100px; width: 310px; height: 310px; border-radius: 50%; background: radial-gradient(circle, rgba(243,181,27,.34), rgba(243,181,27,0) 68%); }
.hero-kicker { position: relative; z-index: 1; color: var(--warning); font-size: 11px; font-weight: 900; letter-spacing: 1.25px; }
.hero h1 { position: relative; z-index: 1; max-width: 760px; margin: 8px 0 13px; font-size: clamp(28px, 3.3vw, 44px); line-height: 1.17; letter-spacing: -1.8px; }
.hero p { position: relative; z-index: 1; max-width: 790px; margin: 0; color: var(--muted); line-height: 1.72; font-size: 13px; }
.hero-actions { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 9px; margin-top: 22px; }
.hero-side { display: flex; flex-direction: column; justify-content: space-between; color: #fff; background: linear-gradient(145deg, #1d3558, #12243d); }
.hero-side h3 { margin: 0 0 10px; font-size: 17px; }
.hero-side p { color: #c8d6e7; font-size: 12px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 20px; }
.stat { padding: 12px 8px; text-align: center; border: 1px solid rgba(255,255,255,.09); border-radius: 10px; background: rgba(255,255,255,.08); }
.stat strong { display: block; font-size: 20px; }
.stat span { display: block; margin-top: 3px; color: #b2c2d4; font-size: 9px; }
.section-head { max-width: 1520px; margin: 18px auto 11px; display: flex; align-items: center; gap: 10px; }
.section-head h2 { margin: 0; font-size: 18px; }
.count { padding: 2px 7px; border-radius: 999px; color: var(--muted); background: var(--surface-3); font-size: 10px; }
.schedule-grid { max-width: 1520px; margin: auto; padding-bottom: 40px; display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.schedule-card { min-height: 225px; padding: 18px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.94); box-shadow: 0 8px 24px rgba(27,43,69,.07); transition: transform .15s, box-shadow .15s, border-color .15s; }
.schedule-card:hover { transform: translateY(-2px); border-color: #b6c6da; box-shadow: 0 14px 34px rgba(27,43,69,.12); }
.card-top { display: flex; align-items: flex-start; gap: 11px; }
.type-icon { width: 42px; height: 42px; flex: 0 0 42px; display: grid; place-items: center; border-radius: 12px; color: var(--navy-2); background: #edf3fa; font-size: 19px; }
.card-title { min-width: 0; }
.card-title h3 { margin: 1px 0 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 16px; }
.card-title p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.card-top > .btn { margin-left: auto; }
.card-meta { margin: 17px 0 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.meta-box { padding: 9px 10px; border-radius: 9px; background: var(--surface-2); }
.meta-box label { display: block; color: var(--muted); font-size: 9px; }
.meta-box strong { display: block; margin-top: 4px; font-size: 11px; }
.card-issues { width: max-content; padding: 4px 7px; border-radius: 6px; font-size: 9px; font-weight: 800; }
.card-issues.ok { color: var(--success); background: #eaf7f1; }
.card-issues.warning { color: var(--warning); background: #fff3d9; }
.card-issues.error { color: var(--danger); background: #fff0ee; }
.card-foot { margin-top: auto; display: flex; align-items: center; gap: 8px; }
.updated { color: var(--muted); font-size: 9px; }
.empty-state { max-width: 1520px; margin: auto; padding: 48px 24px; text-align: center; border: 1px dashed var(--line-strong); border-radius: 16px; background: rgba(255,255,255,.84); }
.empty-icon { font-size: 36px; }
.empty-state h3 { margin: 8px 0; }
.empty-state p { color: var(--muted); }

/* Editor */
.editor-page { height: calc(100% - 58px); display: flex; flex-direction: column; min-height: 0; background: #fff; }
.editor-toolbar { flex: 0 0 auto; display: flex; align-items: center; flex-wrap: wrap; gap: 7px; min-height: 51px; padding: 8px 11px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.98); box-shadow: 0 2px 12px rgba(29,45,69,.05); z-index: 40; }
.toolbar-group { display: flex; align-items: center; gap: 4px; padding-right: 7px; margin-right: 1px; border-right: 1px solid var(--line); }
.toolbar-group:last-of-type { border-right: 0; }
.toolbar-label { color: var(--muted); font-size: 9px; font-weight: 800; }
.mode-switch, .zoom-switch { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--surface-3); }
.mode-switch button, .zoom-switch button { min-height: 27px; padding: 4px 8px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 800; }
.mode-switch button.active, .zoom-switch button.active { color: var(--navy); background: #fff; box-shadow: 0 1px 5px rgba(20,35,58,.16); }
.toolbar-month { width: 126px; height: 31px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 7px; }
.save-status { display: inline-flex; align-items: center; gap: 6px; min-width: 120px; color: var(--muted); font-size: 9px; white-space: nowrap; }
.save-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }
.save-status.saving .save-dot, .save-status.loading .save-dot { background: var(--accent); animation: pulse 1s infinite; }
.save-status.offline .save-dot, .save-status.conflict .save-dot { background: var(--warning); }
.save-status.error .save-dot, .save-status.locked .save-dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }
.editor-summary { flex: 0 0 auto; min-height: 39px; display: flex; align-items: center; gap: 14px; padding: 6px 13px; border-bottom: 1px solid var(--line); color: var(--muted); background: #f4f7fb; font-size: 10px; }
.editor-summary strong { color: var(--ink); }
.editor-summary .ok { color: var(--success); }
.editor-summary .issue { color: var(--danger); }
.summary-issue { border: 0; border-radius: 6px; padding: 4px 7px; font-size: 9px; font-weight: 800; }
.summary-issue.ok { color: var(--success); background: #eaf7f1; }
.summary-issue.warning { color: var(--warning); background: #fff3d9; }
.summary-issue.error { color: var(--danger); background: #fff0ee; }
.summary-filter { margin-left: auto; display: flex; align-items: center; gap: 5px; }
.summary-filter input[type="search"] { width: 180px; }
.summary-filter input[type="search"], .summary-filter select { height: 28px; padding: 3px 7px; border: 1px solid var(--line); border-radius: 7px; background: #fff; font-size: 9px; }
.summary-filter label { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.editor-main { flex: 1; min-height: 0; display: flex; }
.editor-center { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.editor-workspace { flex: 1; min-height: 0; display: flex; background: #fff; }
.data-pane { width: var(--data-pane-w); min-width: 460px; max-width: 1100px; flex: 0 0 auto; display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line-strong); background: #fff; }
.pane-resizer { width: 7px; flex: 0 0 7px; margin-left: -4px; cursor: col-resize; z-index: 20; }
.timeline-pane { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; background: #fff; }
.data-header-viewport { height: var(--timeline-header-h); flex: 0 0 var(--timeline-header-h); overflow: hidden; border-bottom: 1px solid var(--line-strong); background: #e9eef5; }
.data-header { height: 100%; display: grid; align-items: stretch; background: #e9eef5; font-size: 9px; font-weight: 850; will-change: transform; }
.data-header > div { min-width: 0; display: grid; place-items: center; padding: 3px; text-align: center; border-right: 1px solid var(--line); }
.column-head { position: relative; overflow: visible; }
.column-head > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; }
.column-resizer { position: absolute; top: 0; right: -5px; width: 10px; height: 100%; z-index: 5; padding: 0; border: 0; background: transparent; cursor: col-resize; touch-action: none; }
.column-resizer::after { content: ''; position: absolute; top: 8px; bottom: 8px; left: 4px; width: 1px; background: transparent; }
.column-resizer:hover::after, body.resizing-column .column-resizer::after { background: #6683a8; }
body.resizing-column, body.resizing-column * { cursor: col-resize !important; user-select: none !important; }
.data-body { flex: 1; min-height: 0; overflow: auto; scrollbar-gutter: stable; }
.data-row { height: var(--row-h); display: grid; border-bottom: 1px solid #e6ebf1; background: #fff; }
.data-row:hover { background: #f8fbff; }
.data-row.selected { background: #fff6dc; }
.data-row.selected:hover { background: #fff2c9; }
.data-row.summary-row { background: #f2f5f9; }
.data-row.summary-row.selected { background: #fff1c6; }
.data-row.has-issue { box-shadow: inset 3px 0 0 #d28a16; }
.data-cell { min-width: 0; display: flex; align-items: center; padding: 3px 5px; border-right: 1px solid #edf0f4; overflow: hidden; }
.data-cell.center { justify-content: center; }
.row-control { gap: 3px; }
.row-index { color: var(--muted); font-size: 9px; }
.drag-handle { width: 18px; padding: 0; border: 0; color: #8c98a8; background: transparent; cursor: grab; }
.drag-handle:active { cursor: grabbing; }
.row-issue { min-width: 15px; height: 15px; display: grid; place-items: center; border-radius: 50%; color: #fff; background: var(--warning); font-size: 8px; }
.cell-input, .cell-select { width: 100%; height: 31px; min-width: 0; padding: 4px 6px; border: 1px solid transparent; border-radius: 6px; color: var(--ink); background: transparent; outline: none; font-size: 10px; }
.cell-input:hover, .cell-select:hover { border-color: #d3dce7; background: rgba(255,255,255,.9); }
.cell-input:focus, .cell-select:focus { border-color: #557cae; background: #fff; box-shadow: 0 0 0 2px rgba(85,124,174,.15); }
.cell-input[type="number"] { text-align: right; }
.cell-text { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 10px; }
.cell-text.summary, .task-name-input.summary { font-weight: 850; }
.auto-value { color: var(--info); font-weight: 750; }
.task-name-cell { padding-left: calc(4px + var(--depth) * 15px); }
.collapse-button { width: 20px; flex: 0 0 20px; border: 0; color: var(--navy-2); background: transparent; }
.collapse-spacer { width: 20px; flex: 0 0 20px; }
.summary-icon { margin-right: 3px; color: var(--info); font-size: 9px; font-weight: 900; }
.cell-button { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 5px 6px; border: 1px solid transparent; border-radius: 6px; color: var(--info); background: transparent; text-align: left; font-size: 9px; }
.cell-button:hover { border-color: #cbd9e9; background: #f5f9fd; }
.quick-row { color: var(--muted); background: #f7f9fc; }
.quick-copy { font-size: 10px; }
.data-row.drop-before { box-shadow: inset 0 3px 0 var(--info); }
.data-row.drop-after { box-shadow: inset 0 -3px 0 var(--info); }
.timeline-scroll { flex: 1; min-height: 0; overflow: auto; position: relative; }
.timeline-header-wrap { height: var(--timeline-header-h); position: sticky; top: 0; z-index: 15; border-bottom: 1px solid var(--line-strong); background: #e9eef5; }
.timeline-header { position: relative; height: 100%; overflow: hidden; }
.year-block, .month-block, .tick-block { position: absolute; display: grid; place-items: center; overflow: hidden; white-space: nowrap; border-right: 1px solid var(--line-strong); }
.year-block { top: 0; height: 23px; color: #fff; background: #71839a; font-size: 9px; font-weight: 850; }
.month-block { top: 23px; height: 25px; background: #dce5ef; border-bottom: 1px solid var(--line-strong); font-size: 9px; font-weight: 850; }
.tick-block { top: 48px; height: 30px; color: #536175; background: #edf1f6; font-size: 8px; }
.tick-block b { font-size: 9px; }
.tick-block small { font-size: 7px; }
.tick-block.sunday { color: #aa332d; background: #f6e3e1; }
.tick-block.saturday { color: #31608c; background: #e6eef8; }
.timeline-canvas { position: relative; }
.timeline-grid { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.weekend-band { position: absolute; top: 0; bottom: 0; background: rgba(79,123,177,.055); }
.weekend-band.sunday { background: rgba(192,63,53,.07); }
.grid-line { position: absolute; top: 0; bottom: 0; width: 1px; background: #e4e9ef; }
.grid-line.major { background: #aeb9c8; }
.today-line { position: absolute; top: 0; bottom: 0; width: 2px; background: #d13f37; z-index: 5; }
.today-line span { position: sticky; top: 2px; display: inline-block; transform: translateX(-50%); padding: 2px 4px; border-radius: 4px; color: #fff; background: #d13f37; font-size: 7px; }
.timeline-rows { position: relative; z-index: 4; }
.timeline-row { height: var(--row-h); position: relative; border-bottom: 1px solid #e6ebf1; }
.timeline-row:hover { background: rgba(56,108,165,.035); }
.timeline-row.selected { background: rgba(243,181,27,.12); }
.timeline-row.summary-row { background: rgba(51,72,96,.035); }
.task-bar { --bar-color: #6b778c; position: absolute; top: 7px; height: calc(var(--row-h) - 14px); min-width: 7px; display: flex; align-items: center; overflow: visible; border-radius: 5px; color: #fff; background: var(--bar-color); box-shadow: 0 2px 6px rgba(20,35,58,.18); cursor: grab; touch-action: none; user-select: none; }
.task-bar:active { cursor: grabbing; }
.task-bar.critical { box-shadow: 0 0 0 2px #c7362f, 0 2px 6px rgba(20,35,58,.18); }
.task-bar.summary { top: 13px; height: 7px; border-radius: 0; box-shadow: none; background: var(--bar-color); }
.task-bar.summary::before, .task-bar.summary::after { content: ""; position: absolute; top: 0; width: 4px; height: 13px; background: var(--bar-color); }
.task-bar.summary::before { left: 0; }
.task-bar.summary::after { right: 0; }
.bar-progress { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: rgba(14,28,47,.27); pointer-events: none; }
.bar-label { position: relative; z-index: 2; width: 100%; padding: 0 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; font-weight: 800; text-shadow: 0 1px 2px rgba(0,0,0,.25); pointer-events: none; }
.task-bar.summary .bar-label { position: absolute; top: -12px; color: var(--ink); text-shadow: none; font-size: 8px; }
.resize-handle { position: absolute; top: -2px; bottom: -2px; width: 9px; z-index: 4; cursor: ew-resize; }
.resize-handle.left { left: -3px; }
.resize-handle.right { right: -3px; }
.resize-handle::after { content: ""; position: absolute; top: 30%; bottom: 30%; left: 3px; width: 2px; border-radius: 2px; background: rgba(255,255,255,.8); opacity: 0; }
.task-bar:hover .resize-handle::after { opacity: 1; }
.baseline-bar { position: absolute; top: calc(var(--row-h) - 7px); height: 3px; border-radius: 2px; background: #34465a; opacity: .72; }
.empty-row-note { position: absolute; left: 8px; top: 13px; color: #9ba6b3; font-size: 8px; }
.quick-timeline-row { display: flex; align-items: center; padding-left: 10px; color: var(--muted); background: #f7f9fc; font-size: 9px; cursor: crosshair; }
.quick-ghost { position: absolute; top: 8px; height: calc(var(--row-h) - 16px); display: none; border: 1px dashed var(--info); border-radius: 5px; background: rgba(42,111,169,.19); }
.dependency-overlay { position: absolute; inset: 0; z-index: 6; overflow: visible; pointer-events: none; }
.dependency-path { fill: none; stroke: #71849a; stroke-width: 1.3; opacity: .78; }
.dependency-path.critical { stroke: #c7362f; stroke-width: 2.1; }
#dep-arrow path { fill: #71849a; }
#dep-arrow-critical path { fill: #c7362f; }
.drag-tooltip { position: fixed; z-index: 1000; padding: 6px 8px; border-radius: 7px; color: #fff; background: #172a46; box-shadow: 0 7px 20px rgba(0,0,0,.23); font-size: 10px; pointer-events: none; }
.is-dragging, .is-dragging * { cursor: grabbing !important; }
.curve-panel { height: 145px; flex: 0 0 145px; display: flex; border-top: 1px solid var(--line-strong); background: #fff; }
.curve-label { width: var(--data-pane-w); min-width: 460px; flex: 0 0 auto; padding: 16px 18px; border-right: 1px solid var(--line-strong); background: #f4f7fa; }
.curve-label h4 { margin: 0 0 7px; font-size: 12px; }
.curve-label p { margin: 0; color: var(--muted); font-size: 9px; line-height: 1.55; }
.legend { width: 16px; height: 3px; display: inline-block; margin: 0 3px 2px 8px; }
.legend.plan { background: #c72f29; }
.legend.actual { border-top: 2px dashed #1f6fb2; }
.curve-scroll { flex: 1; overflow: hidden; }
.curve-canvas { height: 100%; }
.curve-canvas svg line { stroke: #dbe2ea; stroke-width: 1; }
.curve-canvas svg text { fill: #7c899a; font-size: 8px; font-family: inherit; }
.curve-plan, .curve-actual { fill: none; stroke-linejoin: round; stroke-linecap: round; }
.curve-plan { stroke: #c7362f; stroke-width: 3; }
.curve-actual { stroke: #1f6fb2; stroke-width: 2.3; stroke-dasharray: 7 4; }
.status-bar { height: 28px; flex: 0 0 28px; display: flex; align-items: center; gap: 15px; padding: 0 12px; border-top: 1px solid var(--line); color: var(--muted); background: #f3f6fa; font-size: 8px; }

/* Detail panel */
.detail-panel { width: 344px; flex: 0 0 344px; min-height: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line-strong); background: #f8fafc; box-shadow: -8px 0 20px rgba(25,42,66,.06); z-index: 20; }
.detail-head { flex: 0 0 auto; display: flex; align-items: flex-start; gap: 8px; padding: 14px 15px; border-bottom: 1px solid var(--line); background: #fff; }
.detail-head h3 { margin: 2px 0 0; max-width: 265px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.detail-head > button { margin-left: auto; width: 26px; height: 26px; border: 0; color: var(--muted); background: transparent; }
.detail-kicker { color: var(--info); font-size: 8px; font-weight: 850; letter-spacing: .8px; }
.detail-body { flex: 1; min-height: 0; overflow: auto; padding: 13px; }
.detail-body > label, .detail-grid label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 11px; color: #4f5f71; font-size: 9px; font-weight: 800; }
.detail-body input, .detail-body select, .detail-body textarea, .detail-button { width: 100%; min-height: 34px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; color: var(--ink); background: #fff; outline: none; font-size: 10px; font-weight: 500; }
.detail-body input:focus, .detail-body select:focus, .detail-body textarea:focus { border-color: #557cae; box-shadow: 0 0 0 2px rgba(85,124,174,.13); }
.detail-body textarea { min-height: 88px; resize: vertical; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.detail-button { text-align: left; cursor: pointer; }
.toggle-line { flex-direction: row !important; align-items: center; gap: 7px !important; }
.toggle-line input[type="checkbox"] { width: auto; min-height: 0; }
.toggle-line.compact { margin-top: 20px; }
.derived-box { margin: -5px 0 12px; padding: 8px; border-radius: 7px; color: var(--info); background: #eaf3fa; font-size: 9px; line-height: 1.5; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 6px; }
.detail-empty { padding: 30px 18px; color: var(--muted); line-height: 1.6; font-size: 11px; }
.detail-issues { padding: 8px 12px 0; }
.detail-issues button { width: 100%; margin-bottom: 4px; padding: 6px 7px; border: 0; border-radius: 6px; text-align: left; font-size: 8px; }
.detail-issues .error { color: var(--danger); background: #fff0ee; }
.detail-issues .warning { color: var(--warning); background: #fff3d9; }
.batch-shift { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-bottom: 13px; }

/* Review */
.issue-panel { flex: 0 0 auto; max-height: 150px; display: flex; border-bottom: 1px solid var(--line); background: #fffaf1; }
.issue-panel.empty { align-items: center; gap: 12px; padding: 10px 14px; color: var(--success); background: #f0faf5; }
.issue-panel.empty span { color: var(--muted); font-size: 9px; }
.issue-panel-head { width: 210px; flex: 0 0 210px; padding: 12px 14px; border-right: 1px solid var(--line); }
.issue-panel-head strong { display: block; font-size: 11px; }
.issue-panel-head span { display: block; margin-top: 5px; color: var(--muted); font-size: 8px; line-height: 1.45; }
.issue-list { flex: 1; overflow: auto; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 5px; padding: 8px; }
.issue-item { max-width: 340px; display: flex; align-items: center; gap: 7px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; text-align: left; font-size: 8px; }
.issue-item span { padding: 2px 4px; border-radius: 4px; font-weight: 850; }
.issue-item.error span { color: var(--danger); background: #fff0ee; }
.issue-item.warning span { color: var(--warning); background: #fff3d9; }
.issue-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode-review .cell-button, .mode-review .task-bar { cursor: default; }

/* Print mode */
.print-mode { flex: 1; min-height: 0; display: flex; flex-direction: column; background: #d8dde4; }
.print-controls { flex: 0 0 auto; min-height: 48px; display: flex; align-items: center; gap: 7px; padding: 7px 12px; border-bottom: 1px solid #bfc7d1; background: #fff; }
.type-tabs { display: flex; gap: 4px; }
.type-tabs button { min-height: 31px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); background: #fff; font-size: 9px; font-weight: 750; }
.type-tabs button.active { color: var(--navy); border-color: #8096b0; background: #edf3fa; }
.print-controls input { height: 32px; padding: 4px 7px; border: 1px solid var(--line); border-radius: 7px; }
.paper-stage { flex: 1; min-height: 0; overflow: auto; padding: 26px; }
.paper-sheet { margin: 0 auto; padding: 10px; background: #fff; box-shadow: 0 8px 30px rgba(0,0,0,.24); }
.paper-sheet.landscape { width: min(1500px, 100%); }
.paper-sheet.portrait { width: min(920px, 100%); }
.paper-sheet svg { display: block; width: 100%; height: auto; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px; background: rgba(12,23,38,.58); backdrop-filter: blur(4px); }
.modal { width: min(650px, 100%); max-height: min(860px, 94vh); display: flex; flex-direction: column; overflow: hidden; border: 1px solid rgba(255,255,255,.4); border-radius: 17px; background: #fff; box-shadow: 0 26px 80px rgba(0,0,0,.32); }
.modal.wide { width: min(1050px, 100%); }
.modal-head { min-height: 58px; flex: 0 0 auto; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-body { flex: 1; min-height: 0; overflow: auto; padding: 17px; }
.modal-body > p { color: var(--muted); font-size: 11px; line-height: 1.65; }
.modal-foot { min-height: 56px; flex: 0 0 auto; display: flex; align-items: center; justify-content: flex-end; gap: 7px; padding: 10px 16px; border-top: 1px solid var(--line); background: #f8fafc; }
.modal-foot > div { display: flex; gap: 7px; }
.step-label { margin: 3px 0 9px; color: var(--navy-2); font-size: 10px; font-weight: 900; }
.step-label:not(:first-child) { margin-top: 18px; }
.type-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.type-card { position: relative; min-height: 145px; padding: 14px; display: flex; flex-direction: column; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); background: #fff; text-align: left; }
.type-card:hover, .type-card.selected { border-color: #547ba9; background: #f2f7fc; box-shadow: 0 0 0 2px rgba(84,123,169,.11); }
.type-card .icon { font-size: 25px; }
.type-card strong { margin-top: 11px; font-size: 11px; }
.type-card p { margin: 6px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.template-card { min-height: 58px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; color: var(--ink); background: #fff; font-weight: 750; }
.template-card.selected { border-color: #547ba9; background: #edf4fb; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-grid label, .modal-body > label { display: flex; flex-direction: column; gap: 5px; color: #4d5c6f; font-size: 9px; font-weight: 800; }
.form-grid label.full { grid-column: 1 / -1; }
.form-grid input, .form-grid select, .form-grid textarea, .modal-body > label input, .modal-body > label select, .modal-body > label textarea { min-height: 36px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: #fff; outline: none; font-size: 10px; }
.form-grid textarea { min-height: 100px; resize: vertical; }
.validation { min-height: 18px; margin-top: 8px; color: var(--danger); font-size: 10px; }
.help-box { padding: 10px; border-radius: 8px; color: #536477; background: #eef3f8; font-size: 9px; line-height: 1.6; }
.column-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.column-list label { display: flex; align-items: center; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 10px; }
.dependency-list { max-height: 420px; overflow: auto; display: grid; gap: 4px; margin-bottom: 13px; }
.dependency-list label { display: grid; grid-template-columns: 24px 55px minmax(150px,1fr) 145px; align-items: center; gap: 7px; padding: 7px; border: 1px solid #e3e8ef; border-radius: 7px; font-size: 9px; }
.dependency-list small { color: var(--muted); }
.version-create { display: grid; grid-template-columns: 1fr 1.2fr auto; gap: 7px; margin-bottom: 12px; }
.version-create input { height: 36px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; }
.version-list { display: grid; gap: 7px; }
.version-item { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.version-item strong { font-size: 11px; }
.version-item p { margin: 4px 0; color: var(--muted); font-size: 8px; }
.version-item small { color: #7e8998; }
.version-item button { margin-left: auto; }
.loading-inline, .empty-inline { padding: 28px; text-align: center; color: var(--muted); }
.large-textarea { width: 100%; min-height: 330px; padding: 10px; border: 1px solid var(--line); border-radius: 9px; font-family: Consolas, monospace; font-size: 10px; resize: vertical; }
.import-meta { display: flex; gap: 10px; margin-bottom: 12px; }
.import-meta span { color: var(--muted); font-size: 9px; }
.mapping-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.mapping-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 8px; font-weight: 800; }
.mapping-grid select { min-height: 32px; border: 1px solid var(--line); border-radius: 6px; font-size: 9px; }
.import-preview { margin-top: 14px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.import-preview table { border-collapse: collapse; min-width: 100%; font-size: 8px; }
.import-preview th, .import-preview td { min-width: 80px; max-width: 190px; padding: 5px 7px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.import-preview th { position: sticky; top: 0; background: #e9eef5; }
.conflict-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.option-card { padding: 18px; display: flex; flex-direction: column; gap: 8px; border: 1px solid #9fb2c8; border-radius: 11px; background: #f4f8fc; text-align: left; }
.option-card.warning { border-color: #e2b26a; background: #fff8e8; }
.option-card span { color: var(--muted); font-size: 9px; line-height: 1.55; }
.context-menu { position: fixed; z-index: 90; width: 170px; padding: 5px; border: 1px solid var(--line); border-radius: 9px; background: #fff; box-shadow: 0 12px 34px rgba(0,0,0,.2); }
.context-menu button { width: 100%; padding: 8px; border: 0; border-radius: 6px; background: transparent; text-align: left; font-size: 10px; }
.context-menu button:hover { background: #f0f4f8; }
.context-menu button.danger { color: var(--danger); }

/* Toast */
#toast-root { position: fixed; right: 16px; bottom: 18px; z-index: 200; display: grid; gap: 7px; }
.toast { max-width: 380px; padding: 10px 13px; border: 1px solid #bcc8d6; border-radius: 9px; color: #fff; background: #253b58; box-shadow: 0 10px 26px rgba(0,0,0,.22); font-size: 10px; }
.toast.success { background: #18794e; }
.toast.error { background: #a62a22; }
.toast.warning { background: #9a5a09; }
.mobile-pane-switch { display: none; }

@media (max-width: 1250px) {
  .editor-toolbar { gap: 5px; }
  .toolbar-group { padding-right: 4px; }
  .btn { padding-left: 8px; padding-right: 8px; }
  .summary-filter input[type="search"] { width: 130px; }
  .detail-panel { width: 310px; flex-basis: 310px; }
}

@media (max-width: 900px) {
  .topbar { height: 52px; flex-basis: 52px; padding: 0 10px; }
  .editor-page { height: calc(100% - 52px); }
  .topbar-title, .workspace-badge { display: none; }
  .hero { grid-template-columns: 1fr; }
  .hero-side { min-height: 230px; }
  .dashboard-page { padding: 14px; }
  .editor-toolbar { max-height: 66px; overflow-x: auto; overflow-y: hidden; flex-wrap: nowrap; scrollbar-width: thin; }
  .editor-toolbar > *, .editor-toolbar .toolbar-group { flex: 0 0 auto; }
  .editor-toolbar button { white-space: nowrap; word-break: keep-all; }
  .editor-toolbar .toolbar-group:nth-of-type(4), .editor-toolbar .toolbar-group:nth-of-type(5) { display: none; }
  .editor-summary { overflow-x: auto; white-space: nowrap; }
  .summary-filter { display: none; }
  .mobile-pane-switch { height: 36px; flex: 0 0 36px; display: flex; border-bottom: 1px solid var(--line); background: #f7f9fc; }
  .mobile-pane-switch button { flex: 1; border: 0; color: var(--muted); background: transparent; font-size: 10px; font-weight: 800; }
  .mobile-pane-switch button.active { color: var(--navy); background: #fff; box-shadow: inset 0 -2px 0 var(--accent); }
  .editor-main { position: relative; }
  .editor-workspace { width: 100%; }
  .data-pane { width: 100% !important; min-width: 100%; border-right: 0; }
  .pane-resizer { display: none; }
  .timeline-pane { width: 100%; }
  .editor-workspace.mobile-table .timeline-pane { display: none; }
  .editor-workspace.mobile-timeline .data-pane { display: none; }
  .detail-panel { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: min(62vh, 540px); z-index: 60; border-left: 0; border-top: 1px solid var(--line-strong); box-shadow: 0 -12px 35px rgba(20,35,58,.18); }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .curve-panel { display: none; }
  .status-bar { gap: 8px; overflow-x: auto; white-space: nowrap; }
  .type-grid { grid-template-columns: 1fr 1fr; }
  .mapping-grid { grid-template-columns: 1fr 1fr; }
  .version-create { grid-template-columns: 1fr; }
  .print-controls { overflow-x: auto; }
  .type-tabs { min-width: max-content; }
  .paper-stage { padding: 10px; }
}

@media (max-width: 560px) {
  .brand small { display: none; }
  .topbar .btn-ghost { display: none; }
  .hero-main, .hero-side { padding: 20px; }
  .hero h1 { font-size: 28px; }
  .schedule-grid { grid-template-columns: 1fr; }
  .unlock-input-row { flex-direction: column; }
  .type-grid, .template-grid, .form-grid, .column-list, .mapping-grid, .conflict-options { grid-template-columns: 1fr; }
  .type-card { min-height: 115px; }
  .modal-backdrop { padding: 6px; }
  .modal { max-height: 98vh; border-radius: 12px; }
  .dependency-list label { grid-template-columns: 22px 48px minmax(130px,1fr); }
  .dependency-list small { display: none; }
  .editor-toolbar .toolbar-group:nth-of-type(3) .btn:not(.btn-icon):nth-of-type(n+3) { display: none; }
}

/* Version comparison */
.version-info { min-width: 0; flex: 1; }
.version-actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
.version-item .version-actions button { margin-left: 0; }
.compare-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; padding: 11px 13px; border-radius: 9px; background: #edf4fb; border: 1px solid #d6e3f1; margin-bottom: 14px; }
.compare-summary strong { font-size: 13px; }
.compare-summary span { color: var(--muted); font-size: 10px; }
.compare-section { margin-top: 14px; }
.compare-section h3 { margin: 0 0 8px; font-size: 12px; }
.version-diff-list { display: grid; gap: 9px; max-height: 58vh; overflow: auto; padding-right: 3px; }
.version-diff { border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #fff; }
.version-diff > header { display: flex; align-items: center; gap: 8px; padding: 9px 11px; background: #f6f8fb; border-bottom: 1px solid var(--line); }
.version-diff > header strong { flex: 1; min-width: 0; }
.version-diff > header > span:last-child { color: var(--muted); font-size: 9px; }
.version-diff.added { border-left: 4px solid #159455; }
.version-diff.removed { border-left: 4px solid #d92d20; }
.version-diff.changed { border-left: 4px solid #d89b00; }
.diff-status { min-width: 36px; padding: 3px 6px; border-radius: 999px; text-align: center; font-size: 9px; font-weight: 700; background: #e8edf3; }
.version-diff.added .diff-status { background: #dff6e9; color: #08783f; }
.version-diff.removed .diff-status { background: #fde5e2; color: #b42318; }
.version-diff.changed .diff-status { background: #fff0c2; color: #8a5b00; }
.compare-table { display: grid; }
.compare-row { display: grid; grid-template-columns: minmax(85px,.55fr) minmax(150px,1fr) minmax(150px,1fr); border-top: 1px solid #edf0f4; }
.compare-row:first-child { border-top: 0; }
.compare-row > * { padding: 7px 9px; min-width: 0; overflow-wrap: anywhere; }
.compare-row > * + * { border-left: 1px solid #edf0f4; }
.compare-row.head { background: #f6f8fb; color: var(--muted); font-size: 9px; font-weight: 700; }
.compare-row:not(.head) span:last-child { background: #fffbea; }
@media (max-width: 700px) {
  .version-item { align-items: flex-start; }
  .version-actions { width: 100%; justify-content: flex-start; margin-left: 0; }
  .compare-row { grid-template-columns: 72px minmax(120px,1fr) minmax(120px,1fr); min-width: 430px; }
  .compare-table { overflow-x: auto; }
}
