:root {
    color-scheme: light;
    --ui-bg: #f3f5f6;
    --ui-surface: #ffffff;
    --ui-surface-subtle: #f8faf9;
    --ui-surface-raised: #ffffff;
    --ui-text: #18211f;
    --ui-text-soft: #53605d;
    --ui-text-faint: #74807d;
    --ui-line: #dce3e0;
    --ui-line-strong: #c8d2ce;
    --ui-brand: #276957;
    --ui-brand-strong: #184f41;
    --ui-brand-soft: #e6f1ed;
    --ui-navy: #244b5a;
    --ui-navy-soft: #e8f0f3;
    --ui-amber: #a66516;
    --ui-amber-soft: #fff3dc;
    --ui-danger: #b33a3a;
    --ui-danger-soft: #fbeaea;
    --ui-success: #26734f;
    --ui-success-soft: #e5f4ec;
    --ui-info: #356aa0;
    --ui-info-soft: #e8f1fa;
    --ui-focus: #2b7a67;
    --ui-shadow-sm: 0 1px 2px rgba(24, 33, 31, 0.05);
    --ui-shadow-md: 0 8px 24px rgba(24, 33, 31, 0.08);
    --ui-shadow-lg: 0 18px 44px rgba(24, 33, 31, 0.14);
    --ui-radius-sm: 4px;
    --ui-radius: 6px;
    --ui-radius-lg: 8px;
    --ui-sidebar-width: 248px;
    --ui-topbar-height: 68px;
    --ui-content-max: 1560px;
    --ui-space-1: 4px;
    --ui-space-2: 8px;
    --ui-space-3: 12px;
    --ui-space-4: 16px;
    --ui-space-5: 20px;
    --ui-space-6: 24px;
    --ui-space-8: 32px;
}

.empty-state {
    min-height: 150px;
    padding: 24px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    color: var(--ui-text-soft);
    text-align: center;
}

.empty-state-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius);
    background: var(--ui-surface-subtle);
    color: var(--ui-brand);
}

.empty-state-icon .lucide {
    width: 20px;
    height: 20px;
}

body.layout-root .empty-state strong {
    color: var(--ui-text);
    font-size: 14px;
}

body.layout-root .empty-state p {
    max-width: 420px;
    margin: 0;
    color: var(--ui-text-faint) !important;
    font-size: 13px;
    line-height: 1.55;
}

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

html {
    min-width: 320px;
    background: var(--ui-bg);
    text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}

body,
body.layout-root {
    min-height: 100vh;
    margin: 0;
    color: var(--ui-text) !important;
    background: var(--ui-bg) !important;
    font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", Arial, sans-serif !important;
    font-size: 14px;
    line-height: 1.5;
    letter-spacing: 0 !important;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body.layout-root p,
body.layout-root .meta,
body.layout-root .hint,
body.layout-root .item-meta,
body.layout-root .meta-row,
body.layout-root .backup-meta {
    color: var(--ui-text-soft);
}

button,
input,
select,
textarea {
    font: inherit;
    letter-spacing: 0;
}

button,
a,
input,
select,
textarea,
[tabindex] {
    outline: none;
}

:where(button, a, input, select, textarea, [tabindex]):focus-visible {
    outline: 3px solid color-mix(in srgb, var(--ui-focus) 30%, transparent) !important;
    outline-offset: 2px;
}

a {
    color: inherit;
    text-underline-offset: 2px;
}

::selection {
    color: #fff;
    background: var(--ui-brand);
}

[hidden] {
    display: none !important;
}

.lucide {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    stroke-width: 1.9;
}

.layout-root .app-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--ui-sidebar-width) minmax(0, 1fr);
    background: var(--ui-bg);
}

.layout-root .main {
    min-width: 0;
    background: transparent;
}

.layout-root .content {
    width: 100%;
    max-width: var(--ui-content-max);
    margin: 0 auto;
    padding: 24px 28px 40px;
}

body.layout-root h1,
body.layout-root h2,
body.layout-root h3,
body.layout-root h4,
body.layout-root strong {
    color: var(--ui-text);
    letter-spacing: 0 !important;
}

body.layout-root h1 {
    margin: 0;
    font-size: 28px;
    line-height: 1.25;
    font-weight: 760;
}

body.layout-root h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.35;
    font-weight: 740;
}

body.layout-root h3 {
    margin: 0;
    font-size: 16px;
    line-height: 1.4;
    font-weight: 720;
}

body.layout-root small,
body.layout-root .small,
body.layout-root .meta,
body.layout-root .hint {
    font-size: 12px;
    line-height: 1.45;
}

body.layout-root .eyebrow,
body.layout-root .section-kicker,
body.layout-root .topbar-kicker,
body.layout-root .help-panel-kicker {
    color: var(--ui-brand) !important;
    font-size: 11px;
    font-weight: 750;
    line-height: 1.2;
    letter-spacing: 0 !important;
    text-transform: none;
}

body.layout-root :where(.card, .panel, .section, .form-card, .dashboard-card, .dashboard-panel, .summary-card, .filter-card, .backup-card) {
    color: var(--ui-text);
    border: 1px solid var(--ui-line) !important;
    border-radius: var(--ui-radius-lg) !important;
    background: var(--ui-surface) !important;
    box-shadow: var(--ui-shadow-sm) !important;
}

body.layout-root :where(.card, .panel, .form-card, .dashboard-card, .dashboard-panel, .summary-card, .filter-card) {
    padding: 20px;
}

body.layout-root :where(.card, .panel, .dashboard-card, .summary-card):hover {
    border-color: var(--ui-line-strong) !important;
}

body.layout-root .soft-panel,
body.layout-root .sub-panel,
body.layout-root .inset-panel {
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius);
    background: var(--ui-surface-subtle);
    box-shadow: none;
}

body.layout-root .page-head,
body.layout-root .section-head,
body.layout-root .panel-head,
body.layout-root .card-head,
body.layout-root .toolbar,
body.layout-root .action-row {
    gap: var(--ui-space-3);
}

body.layout-root .page-head {
    margin-bottom: var(--ui-space-6);
}

body.layout-root .page-head p,
body.layout-root .section-head p {
    max-width: 72ch;
    margin: 6px 0 0;
}

body.layout-root :where(.btn, .btn-primary, .btn-secondary, .topbar-help, .help-panel-link, button[type="submit"]) {
    min-height: 40px;
    padding: 8px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent !important;
    border-radius: var(--ui-radius) !important;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0 !important;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

body.layout-root :where(.btn, .btn-primary, button[type="submit"]) {
    color: #fff !important;
    background: var(--ui-brand) !important;
    box-shadow: none !important;
}

body.layout-root :where(.btn, .btn-primary, button[type="submit"]):hover {
    background: var(--ui-brand-strong) !important;
    filter: none !important;
    transform: none !important;
}

body.layout-root :where(.btn-secondary, .btn.subtle, .subtle, .topbar-help, .help-panel-link) {
    color: var(--ui-text) !important;
    border-color: var(--ui-line-strong) !important;
    background: var(--ui-surface) !important;
    box-shadow: none !important;
}

body.layout-root :where(.btn-secondary, .btn.subtle, .subtle, .topbar-help, .help-panel-link):hover {
    color: var(--ui-brand-strong) !important;
    border-color: var(--ui-brand) !important;
    background: var(--ui-brand-soft) !important;
}

body.layout-root :where(.danger, .btn-danger, .danger-button) {
    color: var(--ui-danger) !important;
    border-color: color-mix(in srgb, var(--ui-danger) 35%, var(--ui-line)) !important;
    background: var(--ui-danger-soft) !important;
    box-shadow: none !important;
}

body.layout-root :where(button, .btn, .btn-primary, .btn-secondary)[disabled],
body.layout-root :where(button, .btn, .btn-primary, .btn-secondary).disabled {
    cursor: not-allowed;
    opacity: 0.5;
    filter: grayscale(0.2);
}

body.layout-root .icon-button {
    width: 40px;
    height: 40px;
    min-width: 40px;
    padding: 0;
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ui-text-soft);
    background: var(--ui-surface);
    cursor: pointer;
}

body.layout-root .icon-button:hover {
    color: var(--ui-brand);
    border-color: var(--ui-brand);
    background: var(--ui-brand-soft);
}

body.layout-root :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    color: var(--ui-text) !important;
    border: 1px solid var(--ui-line-strong) !important;
    border-radius: var(--ui-radius) !important;
    background: var(--ui-surface) !important;
    box-shadow: none !important;
    transition: border-color 140ms ease, box-shadow 140ms ease;
}

body.layout-root textarea {
    min-height: 112px;
    line-height: 1.55;
    resize: vertical;
}

body.layout-root :where(input, select, textarea)::placeholder {
    color: #98a19f;
}

body.layout-root :where(input, select, textarea):hover {
    border-color: #aebbb6 !important;
}

body.layout-root :where(input, select, textarea):focus {
    border-color: var(--ui-focus) !important;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ui-focus) 14%, transparent) !important;
}

body.layout-root label,
body.layout-root .field-label {
    color: var(--ui-text);
    font-size: 13px;
    font-weight: 680;
}

body.layout-root .field,
body.layout-root .form-field,
body.layout-root .form-group {
    gap: 6px;
}

body.layout-root :where(input[type="checkbox"], input[type="radio"]) {
    width: 18px;
    height: 18px;
    accent-color: var(--ui-brand);
}

body.layout-root .table-wrap,
body.layout-root .table-shell,
body.layout-root .data-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius-lg);
    background: var(--ui-surface);
    box-shadow: var(--ui-shadow-sm);
}

body.layout-root table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--ui-text);
    background: transparent;
}

body.layout-root th {
    height: 42px;
    padding: 9px 12px;
    color: var(--ui-text-soft) !important;
    border-bottom: 1px solid var(--ui-line-strong) !important;
    background: var(--ui-surface-subtle) !important;
    font-size: 12px;
    font-weight: 730;
    text-align: left;
    white-space: nowrap;
}

body.layout-root td {
    min-height: 48px;
    padding: 11px 12px;
    border-bottom: 1px solid var(--ui-line) !important;
    background: var(--ui-surface) !important;
    vertical-align: middle;
}

body.layout-root tr:last-child td {
    border-bottom: 0 !important;
}

body.layout-root tbody tr:hover td {
    background: #f7faf8 !important;
}

body.layout-root :where(.badge, .chip, .pill, .status-badge, .tag) {
    min-height: 24px;
    padding: 3px 8px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--ui-text-soft);
    border: 1px solid var(--ui-line);
    border-radius: 999px;
    background: var(--ui-surface-subtle);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0 !important;
}

body.layout-root :where(.badge, .chip, .pill).active,
body.layout-root :where(.badge, .chip, .pill).primary {
    color: var(--ui-brand-strong);
    border-color: #b9d5cc;
    background: var(--ui-brand-soft);
}

body.layout-root :where(.success, .status-success) {
    color: var(--ui-success) !important;
    background: var(--ui-success-soft) !important;
}

body.layout-root :where(.warning, .status-warning) {
    color: var(--ui-amber) !important;
    background: var(--ui-amber-soft) !important;
}

body.layout-root :where(.error, .status-danger) {
    color: var(--ui-danger) !important;
    background: var(--ui-danger-soft) !important;
}

body.layout-root :where(.tabs, .tab-list, .segmented-control) {
    padding: 3px;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius-lg);
    background: #edf1ef;
}

body.layout-root :where(.tab, .tab-button, .segmented-control button) {
    min-height: 36px;
    padding: 7px 12px;
    color: var(--ui-text-soft);
    border: 0 !important;
    border-radius: var(--ui-radius) !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 13px;
    font-weight: 680;
}

body.layout-root :where(.tab, .tab-button, .segmented-control button).active,
body.layout-root :where(.tab, .tab-button, .segmented-control button)[aria-selected="true"] {
    color: var(--ui-text) !important;
    background: var(--ui-surface) !important;
    box-shadow: var(--ui-shadow-sm) !important;
}

body.layout-root :where(.alert, .notice, .message, .feedback, .empty-state) {
    padding: 14px 16px;
    border: 1px solid var(--ui-line);
    border-radius: var(--ui-radius-lg);
    color: var(--ui-text-soft);
    background: var(--ui-surface-subtle);
}

body.layout-root :where(.alert, .notice).info {
    color: var(--ui-info);
    border-color: #bfd4e8;
    background: var(--ui-info-soft);
}

body.layout-root :where(.alert, .notice).warning {
    border-color: #ead2a6;
}

body.layout-root :where(.alert, .notice).danger {
    border-color: #e7b9b9;
}

body.layout-root .empty-state {
    min-height: 160px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 8px;
    text-align: center;
}

body.layout-root .empty-state .lucide {
    width: 28px;
    height: 28px;
    color: var(--ui-text-faint);
}

body.layout-root :where(.modal, .modal-card, .quick-popup, .dialog-card) {
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    color: var(--ui-text);
    border: 1px solid var(--ui-line) !important;
    border-radius: var(--ui-radius-lg) !important;
    background: var(--ui-surface) !important;
    box-shadow: var(--ui-shadow-lg) !important;
}

body.layout-root :where(.modal-shell, .modal-overlay, .help-overlay) {
    background: rgba(14, 25, 22, 0.48) !important;
    backdrop-filter: blur(2px);
}

body.layout-root .skeleton {
    overflow: hidden;
    color: transparent !important;
    border-radius: var(--ui-radius-sm);
    background: #e7ecea !important;
    position: relative;
}

body.layout-root .skeleton::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent);
    transform: translateX(-100%);
    animation: ui-skeleton 1.4s infinite;
}

@keyframes ui-skeleton {
    to { transform: translateX(100%); }
}

body.layout-root .app-footer {
    margin-top: 36px;
    padding: 18px 0 0;
    color: var(--ui-text-faint) !important;
    border-top: 1px solid var(--ui-line);
    font-size: 11px;
    text-align: left;
}

@media (max-width: 920px) {
    :root {
        --ui-topbar-height: 60px;
    }

    body.layout-root {
        padding-bottom: 68px;
    }

    .layout-root .app-layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .layout-root .content {
        padding: 18px 16px 32px;
    }

    body.layout-root h1 {
        font-size: 24px;
    }

    body.layout-root h2 {
        font-size: 18px;
    }

    body.layout-root :where(.card, .panel, .form-card, .dashboard-card, .dashboard-panel, .summary-card, .filter-card) {
        padding: 16px;
    }

    body.layout-root :where(.btn, .btn-primary, .btn-secondary, .topbar-help, .help-panel-link, button[type="submit"]) {
        min-height: 44px;
    }

    body.layout-root :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
        min-height: 46px;
        font-size: 16px;
    }
}

@media (max-width: 560px) {
    .layout-root .content {
        padding: 14px 12px 28px;
    }

    body.layout-root h1 {
        font-size: 22px;
    }

    body.layout-root :where(.page-actions, .action-row, .toolbar-actions) {
        width: 100%;
        align-items: stretch;
    }

    body.layout-root :where(.page-actions, .action-row, .toolbar-actions) > :where(.btn, button, a) {
        min-width: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
