:root {
    --bg: #f4f6f8;
    --card: #ffffff;
    --text: #1c1c1e;
    --sub: #8e8e93;
    --primary: #007aff;
    --primary-dark: #005ecb;
    --danger: #ff3b30;
    --border: #e5e5ea;
    --radius: 12px;
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    --header-h: 56px;
    --pad-x: clamp(16px, 2vw, 32px);
    --pad-y: clamp(16px, 2vh, 28px);
    --font: "Malgun Gothic", "맑은 고딕", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

* { box-sizing: border-box; }

html, body {
    min-height: 100%;
    font-family: var(--font);
}

body {
    margin: 0;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

button, input, select, textarea, table, th, td, a,
.btn, .menu-item, .page-title, h1, h2, h3, h4,
.content-editor, .content-view {
    font-family: inherit;
}

.page,
.wrap {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: var(--pad-y) var(--pad-x) 32px;
    flex: 1 1 auto;
    min-width: 0;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: var(--header-h);
    padding: 10px var(--pad-x);
    background: #fff;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.page-title {
    margin: 0 0 16px;
    font-size: clamp(20px, 1.6vw, 26px);
    font-family: var(--font);
    font-weight: 700;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
}

.back-link,
.logout-link {
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
}

.brand {
    text-align: center;
    margin-bottom: 28px;
}

.brand-badge {
    display: inline-block;
    background: #e8f2ff;
    color: var(--primary);
    font-size: 12px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 999px;
}

.brand h1 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.brand p {
    margin: 8px 0 0;
    color: var(--sub);
    font-size: 14px;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
}

.field { margin-bottom: 16px; }

.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #3a3a3c;
}

.field input,
.field select,
.field textarea,
.filter input,
.filter select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 15px;
    background: #fafafa;
    outline: none;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.filter input:focus,
.filter select:focus {
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.15);
}

.btn {
    display: inline-block;
    width: 100%;
    border: none;
    border-radius: 12px;
    padding: 12px 18px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-secondary {
    background: #e5e5ea;
    color: #1c1c1e;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover { background: #d70015; }

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.actions .btn {
    width: auto;
    min-width: 140px;
}

.alert {
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    margin-bottom: 16px;
}

.alert-error {
    background: #fff2f0;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.alert-info {
    background: #eef6ff;
    color: #1565c0;
    border: 1px solid #bbdefb;
}

.footer-note {
    margin-top: 18px;
    color: var(--sub);
    font-size: 12px;
    line-height: 1.5;
}

.menu-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 14px;
    width: 100%;
}

.menu-item {
    display: block;
    background: #fff;
    border-radius: 12px;
    padding: 18px 20px;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    min-height: 92px;
    min-width: 0;
    max-width: 100%;
}

.menu-item:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 20px rgba(0, 122, 255, 0.12);
}

.menu-item strong { display: block; font-size: 16px; }
.menu-item span { display: block; margin-top: 6px; color: var(--sub); font-size: 13px; }

.section-title {
    margin: 22px 0 10px;
    font-size: 13px;
    font-weight: 700;
    color: #636366;
}

.login-screen {
    display: grid;
    grid-template-columns: minmax(280px, 40%) minmax(0, 1fr);
    min-height: 100vh;
    flex: 1;
}

.login-hero {
    background: linear-gradient(160deg, #0b4f9c 0%, #007aff 55%, #4facfe 100%);
    color: #fff;
    padding: clamp(28px, 5vw, 64px);
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-hero h1 {
    margin: 12px 0 8px;
    font-size: clamp(26px, 3vw, 40px);
    line-height: 1.25;
}

.login-hero p { margin: 0; opacity: 0.9; font-size: 15px; }

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(24px, 4vw, 48px);
    background: var(--bg);
}

.login-panel .card {
    width: min(460px, 100%);
}

@media (max-width: 900px) {
    .login-screen { grid-template-columns: 1fr; }
    .login-hero { min-height: 180px; padding: 28px 24px; }
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.info-grid .row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.info-grid .lbl {
    width: auto;
    font-size: 12px;
    color: #636366;
    font-weight: 600;
}

.info-grid .val {
    font-size: 14px;
    word-break: break-word;
}

.preview-list { margin-top: 10px; display: flex; flex-direction: column; gap: 12px; text-align: left; }
.preview-item {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px;
}
.preview-item img {
    display: block;
    max-width: 100%;
    max-height: 280px;
    border-radius: 8px;
    margin-top: 8px;
}
.preview-cap { font-size: 12px; color: #334155; }
.drop {
    border: 2px dashed #94a3b8;
    border-radius: 12px;
    background: #f8fafc;
    padding: 18px;
    text-align: center;
    color: #64748b;
    min-height: 88px;
}
.drop.over { border-color: var(--primary); background: #eef6ff; }

.ui-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.ui-modal[hidden] { display: none !important; }
.ui-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}
.ui-modal-box {
    position: relative;
    width: min(460px, 100%);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.22);
    padding: 22px 22px 18px;
}
.ui-modal-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 10px;
}
.ui-modal.is-error .ui-modal-title { color: #c62828; }
.ui-modal-body {
    font-size: 15px;
    line-height: 1.6;
    color: #334155;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 28px;
}
.ui-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}
.ui-modal-actions .btn {
    width: auto;
    min-width: 88px;
    padding: 10px 16px;
    font-size: 14px;
}

.dash-home { margin: 4px 0 8px; }
.dash-filter {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.dash-filter label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 6px;
    color: #475569;
}
.dash-filter .btn { width: auto; min-width: 88px; }
.dash-dates { display: flex; gap: 8px; align-items: center; }
.dash-stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
    align-items: stretch;
}
.dash-stats-prior { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 4px; }
.dash-block {
    border-radius: 14px;
    padding: 10px 12px 8px;
    margin-bottom: 10px;
    border: 1px solid transparent;
}
.dash-block-period {
    background: #eef6ff;
    border-color: #c5ddff;
}
.dash-block-prior {
    background: #fff4e8;
    border-color: #fdba74;
}
.dash-block-head { margin-bottom: 8px; }
.dash-block-head h2 {
    margin: 4px 0 2px;
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
}
.dash-block-head p {
    margin: 0;
    font-size: 12px;
    color: #636366;
    line-height: 1.4;
}
.dash-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.02em;
    padding: 2px 8px;
    border-radius: 999px;
}
.dash-block-period .dash-badge { background: #007aff; color: #fff; }
.dash-block-prior .dash-badge { background: #c2410c; color: #fff; }
.dash-block .dash-stats { margin-bottom: 8px; }
@media (max-width: 1100px) {
    .dash-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .dash-stats-prior { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) { .dash-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dash-stat {
    background: #fff;
    border-radius: 10px;
    padding: 6px 8px;
    box-shadow: none;
    text-align: center;
    min-height: 58px;
    height: 58px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: 1px solid transparent;
    box-sizing: border-box;
}
.dash-stat .lbl {
    font-size: 12px;
    color: #64748b;
    font-weight: 700;
    line-height: 1.2;
    white-space: nowrap;
}
.dash-stat .num { font-size: 22px; font-weight: 800; margin-top: 2px; line-height: 1.1; }
.dash-stat a {
    color: inherit;
    text-decoration: none;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}
.dash-stat.wait .num { color: #b45309; }
.dash-stat.ing .num { color: #1d4ed8; }
.dash-stat.done .num { color: #15803d; }
.dash-stat.alert { border-color: #fed7aa; background: #fff7ed; }
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dash-card-wide { grid-column: 1 / -1; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
.dash-card {
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
}
.dash-card h2 { margin: 0 0 12px; font-size: 15px; }
.dash-bar-row {
    display: grid;
    grid-template-columns: 90px 1fr 40px;
    gap: 8px;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
}
.dash-bar { height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.dash-bar > span { display: block; height: 100%; background: var(--primary); }
.dash-ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-tbl-wrap { overflow: auto; }
.dash-tbl-wrap table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.dash-tbl-wrap th {
    text-align: left;
    background: #f8fafc;
    padding: 8px 10px;
    border-bottom: 1px solid #e2e8f0;
    position: relative;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: none;
}
.dash-tbl-wrap td {
    padding: 8px 10px;
    border-bottom: 1px solid #f1f5f9;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.dash-tbl-wrap tr.data:hover { background: #fff7ed; cursor: pointer; }
.dash-recent-tbl .col-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    z-index: 2;
}
.dash-recent-tbl .col-resizer:hover,
body.col-resizing .dash-recent-tbl .col-resizer { background: rgba(0, 122, 255, 0.35); }
body.col-resizing { cursor: col-resize !important; user-select: none !important; }
.dash-empty { text-align: center; color: #94a3b8; padding: 24px; white-space: normal; overflow: visible; }
.st { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.st-wait { background: #ffedd5; color: #c2410c; }
.st-ing { background: #dbeafe; color: #1d4ed8; }
.st-done { background: #dcfce7; color: #15803d; }
.st-hold { background: #e2e8f0; color: #475569; }
