:root {
    --bg: #f4f7fb;
    --card: #ffffff;
    --text: #1e2a39;
    --muted: #6b7280;
    --line: #d9e0ea;
    --primary: #2b579a;
    --primary-soft: #e8eef8;
    --danger: #c0392b;
    --warning: #fff3cd;
    --success-bg: #ecfdf3;
    --success-text: #166534;
    --error-bg: #fef2f2;
    --error-text: #991b1b;
    --info-bg: #eff6ff;
    --info-text: #1d4ed8;
    --shadow: 0 8px 24px rgba(0,0,0,.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: "Malgun Gothic", "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
a { color: inherit; text-decoration: none; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 240px 1fr; }
.sidebar { background: #1f2937; color: white; padding: 20px 16px; }
.brand { margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,.12); }
.brand-title { font-size: 1.35rem; font-weight: 700; }
.brand-subtitle { font-size: .9rem; opacity: .7; margin-top: 4px; }
.nav-menu { display: flex; flex-direction: column; gap: 8px; }
.nav-link { display: block; padding: 10px 12px; border-radius: 12px; color: rgba(255,255,255,.85); }
.nav-link.active, .nav-link:hover { background: rgba(255,255,255,.12); color: white; }
.content { padding: 24px; }

.page-grid { display: grid; gap: 16px; }
.page-card, .summary-card, .form-card { background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 18px; }
.mini-card { padding: 16px; }
.page-card h1, .page-card h3, .page-card h4 { margin-top: 0; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 10px 0 16px; }
.toolbar-stack { gap: 8px; }
.toolbar-line { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.field-inline, .field-label { display: inline-flex; flex-direction: column; gap: 6px; font-weight: 600; }
.field-inline span { font-size: .95rem; }

.text-input, .text-area, select.text-input { width: 100%; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: white; font: inherit; }
.text-input:focus, .text-area:focus { outline: 2px solid rgba(43, 87, 154, .2); border-color: var(--primary); }
.text-right { text-align: right; }

.btn { border: none; border-radius: 10px; padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: #eef2f7; color: #1f2937; }
.btn-light { background: #f7f9fc; color: #1f2937; border: 1px solid var(--line); }
.btn-danger { background: var(--danger); color: white; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.notice { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; font-weight: 600; }
.notice.success { background: var(--success-bg); color: var(--success-text); }
.notice.error { background: var(--error-bg); color: var(--error-text); }
.notice.info { background: var(--info-bg); color: var(--info-text); }
.notice.warning { background: var(--warning); color: #8a6d3b; }

.summary-grid, .form-grid, .preset-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 16px; }
.summary-label { font-size: .9rem; color: var(--muted); }
.summary-value { font-size: 1.2rem; font-weight: 700; margin-top: 8px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 14px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 980px; }
.data-table th, .data-table td { border-bottom: 1px solid var(--line); padding: 10px; vertical-align: top; }
.data-table th { position: sticky; top: 0; background: #f7f9fc; z-index: 1; text-align: left; }
.data-table tbody tr:hover { background: #fbfdff; }
.warning-cell { background: var(--warning); color: #8a6d3b; font-weight: 700; }
.row-selected { background: #eef6ff; }
.row-empty { opacity: .75; }

.tab-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tab-button { border: 1px solid var(--line); background: white; padding: 10px 14px; border-radius: 999px; cursor: pointer; font: inherit; font-weight: 600; }
.tab-button.active { background: var(--primary-soft); border-color: #b9cae7; color: var(--primary); }

.link-button { background: none; border: none; padding: 0; color: var(--primary); cursor: pointer; font: inherit; font-weight: 600; text-align: left; }
.row-action-group { display: flex; gap: 6px; }

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; background: #f4f6f9; border: 1px solid var(--line); }
.chip-remove { border: none; background: transparent; color: #666; cursor: pointer; font-size: 1rem; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 1000; }
.modal-panel { position: fixed; z-index: 1001; inset: 5% 10%; background: white; border-radius: 20px; box-shadow: var(--shadow); padding: 18px; overflow: auto; }
.modal-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 12px; }

.muted { color: var(--muted); }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.error-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }

@media (max-width: 1100px) {
    .shell { grid-template-columns: 1fr; }
    .sidebar { position: sticky; top: 0; z-index: 5; }
    .content { padding: 14px; }
    .modal-panel { inset: 2%; }
}


.global-banner { margin-bottom: 1rem; }
.diagnostic-pre { white-space: pre-wrap; word-break: break-word; margin: 0; font-family: Consolas, monospace; }
.diagnostic-small { font-size: 0.95rem; line-height: 1.4; }
.notice.warning { background: #fff6db; color: #7a5a00; border: 1px solid #e8d38a; }
.notice.warning a { color: inherit; text-decoration: underline; }
