:root {
    color-scheme: light;
    --bg: #f3f6fb;
    --surface: #ffffff;
    --surface-muted: #f8fafc;
    --border: #dbe3ee;
    --text: #172033;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --success: #15803d;
    --warning: #b45309;
    --radius: 12px;
    font-family: Inter, Pretendard, "Noto Sans KR", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 24px;
    min-height: 62px;
    padding: 0 28px;
    color: #fff;
    background: #111827;
    box-shadow: 0 2px 12px rgb(15 23 42 / 15%);
}
.app-brand { color: #fff; display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.app-brand img { width: auto; max-width: 44px; height: 30px; object-fit: contain; }
.app-brand-copy { display: flex; flex-direction: column; line-height: 1.1; }
.app-brand-copy small { color: #94a3b8; font-size: 10px; font-weight: 500; letter-spacing: 0; }
.app-brand:hover { text-decoration: none; }
.app-nav { display: flex; align-items: center; gap: 5px; flex: 1; }
.app-nav a { color: #cbd5e1; padding: 9px 11px; border-radius: 7px; font-size: 14px; }
.app-nav a:hover { color: #fff; background: #1f2937; text-decoration: none; }
.app-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.app-user form { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.language-picker { display: flex; align-items: center; }
.language-select { width: auto; min-width: 122px; padding: 7px 30px 7px 9px; font-size: 12px; }
.app-header .language-select, .public-header .language-select { color: #e2e8f0; background-color: #1f2937; border-color: #475569; }
.login-language { justify-content: flex-end; margin: -12px -12px 14px 0; }

.page-shell { width: min(1440px, calc(100% - 36px)); margin: 28px auto 48px; }
.page-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.page-heading h1 { margin: 0; font-size: 28px; letter-spacing: -.035em; }
.page-heading p { color: var(--muted); margin: 6px 0 0; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 5px 18px rgb(15 23 42 / 5%); }
.card-header { padding: 17px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-header h2, .card-header h3 { margin: 0; font-size: 17px; }
.card-body { padding: 20px; }
.card + .card { margin-top: 18px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.form-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.form-field.full { grid-column: 1 / -1; }
label { color: #334155; font-size: 13px; font-weight: 700; }
input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    color: var(--text);
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #60a5fa; box-shadow: 0 0 0 3px rgb(37 99 235 / 12%); }
textarea { min-height: 100px; resize: vertical; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    line-height: 1;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(.98); }
.btn-primary { color: #fff; background: var(--primary); }
.btn-secondary { color: #334155; background: #fff; border-color: #cbd5e1; }
.btn-danger { color: #fff; background: var(--danger); }
.btn-ghost { color: #cbd5e1; background: transparent; border-color: #475569; }
.btn-sm { min-height: 31px; padding: 6px 9px; font-size: 12px; }
.icon-btn { width: 36px; min-width: 36px; padding: 0; }
.material-symbols-outlined { font-size: 19px; vertical-align: middle; }

.alert { width: min(1440px, calc(100% - 36px)); margin: 16px auto -10px; padding: 12px 15px; border: 1px solid; border-radius: 9px; }
.alert-success { color: #166534; border-color: #bbf7d0; background: #f0fdf4; }
.alert-error { color: #991b1b; border-color: #fecaca; background: #fef2f2; }
.muted { color: var(--muted); }
.empty-state { padding: 52px 20px; color: var(--muted); text-align: center; }
.empty-state .material-symbols-outlined { display: block; margin-bottom: 10px; color: #94a3b8; font-size: 44px; }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { padding: 11px 12px; color: #475569; background: var(--surface-muted); border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.data-table td { padding: 12px; border-bottom: 1px solid #edf2f7; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tr:hover td { background: #fbfdff; }
.cell-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 999px; background: #e2e8f0; color: #475569; font-size: 11px; font-weight: 800; }
.badge-success, .status-Completed { color: #166534; background: #dcfce7; }
.badge-warning, .status-Processing { color: #92400e; background: #fef3c7; }
.badge-danger, .status-Failed { color: #991b1b; background: #fee2e2; }
.status-Pending { color: #1e40af; background: #dbeafe; }

.search-bar { display: flex; gap: 8px; align-items: end; }
.search-bar .form-field { flex: 1; }
.details-panel { margin-top: 10px; padding: 14px; background: #f8fafc; border: 1px solid var(--border); border-radius: 9px; }
details > summary { cursor: pointer; font-weight: 800; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top, #dbeafe, #f8fafc 55%); }
.login-card { width: min(430px, 100%); padding: 36px; }
.login-brand { margin-bottom: 28px; text-align: center; }
.login-brand .material-symbols-outlined { color: var(--primary); font-size: 50px; }
.login-logo { display: block; width: auto; max-width: 180px; height: 64px; margin: 0 auto 10px; object-fit: contain; }
.login-brand h1 { margin: 8px 0 4px; }
.login-brand .login-company { margin: 0 0 5px; font-size: 13px; }
.login-form { display: grid; gap: 16px; }
.login-form .btn { min-height: 45px; }

.upload-drop { position: relative; padding: 44px 20px; text-align: center; border: 2px dashed #93c5fd; border-radius: 13px; background: #eff6ff; transition: .15s; }
.upload-drop.dragging { background: #dbeafe; border-color: var(--primary); }
.upload-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-list { margin: 15px 0 0; padding: 0; list-style: none; }
.file-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 10px; border-bottom: 1px solid #e2e8f0; }
.progress { height: 10px; overflow: hidden; border-radius: 999px; background: #e2e8f0; }
.progress > span { display: block; width: 0; height: 100%; background: var(--primary); transition: width .2s; }

.public-header { padding: 26px; color: #fff; background: #172033; }
.public-header h1 { margin: 0 0 5px; }
.public-header-content { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.memo-list { display: grid; gap: 9px; margin: 0; padding: 0; list-style: none; }
.memo-item { padding: 12px; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; }
.memo-meta { display: flex; gap: 8px; margin-bottom: 6px; color: var(--muted); font-size: 11px; }

.viewer-page { height: 100vh; display: flex; flex-direction: column; overflow: hidden; background: #e5e7eb; }
.document-header { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 9px 15px; background: #fff; border-bottom: 1px solid var(--border); }
.document-title { min-width: 0; margin-right: auto; }
.document-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.document-toolbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.document-toolbar button.active { color: #fff; background: var(--primary); }
.document-viewer-layout { min-height: 0; flex: 1; display: flex; }
.document-sidebar { width: 150px; padding: 12px; overflow-y: auto; background: #f8fafc; border-right: 1px solid var(--border); }
.document-sidebar.collapsed { width: 0; padding: 0; overflow: hidden; border: 0; }
.thumbnail-card { padding: 8px; text-align: center; background: #fff; border: 2px solid var(--border); border-radius: 7px; cursor: pointer; }
.thumbnail-card.active { border-color: var(--primary); }
.document-stage { position: relative; flex: 1; min-width: 0; overflow: auto; padding: 24px; background: #cbd5e1; }
.document-pages { display: flex; flex-direction: column; align-items: center; gap: 24px; transform-origin: top center; }
.document-page { position: relative; width: min(1000px, 100%); min-height: calc(100vh - 115px); background: #fff; box-shadow: 0 8px 28px rgb(15 23 42 / 18%); }
.document-page iframe, .document-page img { display: block; width: 100%; min-height: calc(100vh - 115px); border: 0; object-fit: contain; }
.document-content-canvas { display: block; width: 100%; height: auto; }
.document-page pre { min-height: calc(100vh - 115px); margin: 0; padding: 32px; white-space: pre-wrap; overflow-wrap: anywhere; }
.annotation-canvas { position: absolute; inset: 0; z-index: 5; width: 100%; height: 100%; }
.annotation-canvas.select-mode { pointer-events: none; }
.memo-note { position: absolute; z-index: 7; max-width: 240px; padding: 7px 9px; color: #713f12; background: #fef08a; border: 1px solid #facc15; border-radius: 5px; font-size: 12px; white-space: pre-wrap; }
.viewer-message { display: grid; place-items: center; min-height: 60vh; padding: 30px; text-align: center; color: var(--muted); }
.blocking-overlay { position: fixed; inset: 0; z-index: 9999; display: none; place-items: center; background: rgb(15 23 42 / 45%); }
.blocking-overlay.visible { display: grid; }
.blocking-overlay > div { padding: 18px 22px; background: #fff; border-radius: 10px; font-weight: 800; }

.excel-shell { display: flex; min-height: 560px; }
.sheet-list { width: 190px; padding: 10px; background: #f8fafc; border-right: 1px solid var(--border); }
.sheet-list button { width: 100%; margin-bottom: 5px; padding: 9px; border: 0; border-radius: 6px; text-align: left; background: transparent; cursor: pointer; }
.sheet-list button.active { color: #fff; background: var(--primary); }
.excel-main { flex: 1; min-width: 0; }
.excel-grid { width: max-content; min-width: 100%; border-collapse: collapse; font-size: 12px; }
.excel-grid th, .excel-grid td { min-width: 110px; max-width: 360px; padding: 7px 9px; border: 1px solid #dbe3ee; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.excel-grid th { position: sticky; top: 0; z-index: 1; background: #e2e8f0; }
.excel-grid .row-number { min-width: 48px; color: var(--muted); text-align: right; background: #f8fafc; }
.media-player { width: 100%; max-height: 74vh; background: #000; border-radius: 10px; }
.cad-shell { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 620px; }
.cad-entries { padding: 12px; overflow-y: auto; border-right: 1px solid var(--border); }
.cad-preview { width: 100%; min-height: 620px; border: 0; background: #fff; }

@media (max-width: 900px) {
    .app-header { padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
    .app-nav { order: 3; width: 100%; overflow-x: auto; }
    .grid-2, .grid-3, .form-grid, .cad-shell { grid-template-columns: 1fr; }
    .page-shell { width: min(100% - 20px, 1440px); margin-top: 18px; }
    .page-heading { flex-direction: column; }
    .document-sidebar { display: none; }
    .document-header { align-items: flex-start; flex-wrap: wrap; overflow-y: auto; }
    .document-toolbar { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
    .cad-entries { border-right: 0; border-bottom: 1px solid var(--border); }
}
