/* common.css — 리셋 · 색상 변수 · 다크모드 · 공통 컴포넌트 (admin · service 공용)
   앱 고유 테마는 res/app.css 에서 변수만 덮어쓴다. fragment 스타일은 하드코딩 대신 변수를 쓴다. */

@font-face {
    font-family: 'Material Symbols Outlined';
    font-style: normal;
    font-weight: 300 500;
    font-display: block;
    src: local('Material Symbols Outlined'), url('MaterialSymbolsOutlined.woff2') format('woff2');
}

:root {
    color-scheme: light;
    --font: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    --background: #fff;
    --surface: #ffffff;
    --surface-2: #f6f7fb;
    --surface-3: #eceff8;
    --hover: #dcdfec;
    --border: #d0d4e4;
    --border-soft: #e6e9ef;
    --text: #323338;
    --text-2: #676879;
    --text-3: #9699a6;
    --heading-text: #1f2033;
    --anchor-text: #0073ea;

    --primary: #0073ea;
    --primary-hover: #0060b9;
    --primary-soft: #cce5ff;
    --primary-text: #ffffff;
    --danger: #d83a52;
    --danger-soft: #ffebef;
    --success: #00854d;
    --success-soft: #e5f6ee;
    --warning: #c27100;
    --warning-soft: #fff4e0;

    /* 상태 색상 (작업/문서/계정) */
    --st-gray: #c4c4c4;
    --st-blue: #579bfc;
    --st-orange: #fdab3d;
    --st-purple: #a25ddc;
    --st-red: #e2445c;
    --st-green: #00c875;
    --st-dark: #7e8195;

    --grade-background: rgba(180, 180, 180, .1);
    --grade-selected-background: #cce5ff;

    --radius: 8px;
    --radius-sm: 4px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .08);
    --shadow: 0 4px 8px rgba(0, 0, 0, .12);
    --shadow-lg: 0 15px 50px rgba(0, 0, 0, .25);
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --background: #181b34;
        --surface: #30324e;
        --surface-2: #181b34;
        --surface-3: #292f4c;
        --hover: #4b4e69;
        --border: #4b4e69;
        --border-soft: #3c3f59;
        --text: #d5d8df;
        --text-2: #b0b3c4;
        --text-3: #8a8da3;
        --heading-text: #ffffff;
        --anchor-text: #66b2ff;
        --primary-soft: #133774;
        --danger-soft: #4a2230;
        --success-soft: #133f2e;
        --warning-soft: #4a3517;
        --grade-background: rgba(230, 230, 230, .1);
        --grade-selected-background: #133774;
    }
}

/* ── reset ───────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--text); background: var(--surface-2); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, p, ul, ol, figure { margin: 0; padding: 0; }
ul, ol { list-style: none; }
a { color: var(--anchor-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.pre { white-space: pre-wrap; word-break: break-word; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ── icons ───────────────────────────────── */
.material-icons {
    font-family: 'Material Symbols Outlined'; font-weight: normal; font-style: normal;
    font-size: 20px; line-height: 1; letter-spacing: normal; text-transform: none;
    display: inline-block; white-space: nowrap; direction: ltr; vertical-align: middle;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
    -webkit-font-smoothing: antialiased; user-select: none;
}
.material-icons.fill { font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 20; }

/* ── buttons ─────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 32px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid transparent;
    background: transparent; color: var(--text); cursor: pointer; white-space: nowrap; font-size: 14px;
    transition: background .12s, border-color .12s, color .12s;
}
.btn .material-icons { font-size: 18px; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn:focus-visible, .input:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.busy { cursor: progress; }
.btn.primary { background: var(--primary); color: var(--primary-text); }
.btn.primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn.outline { border-color: var(--border); background: var(--surface); }
.btn.outline:hover:not(:disabled) { background: var(--surface-2); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover:not(:disabled) { filter: brightness(.92); }
.btn.danger-ghost { color: var(--danger); }
.btn.danger-ghost:hover:not(:disabled) { background: var(--danger-soft); }
.btn.sm { height: 26px; padding: 0 8px; font-size: 13px; }
.btn.icon-only { width: 32px; padding: 0; }
.btn.sm.icon-only { width: 26px; }

/* ── form ────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 14px; }
.form .row { display: flex; gap: 12px; }
.form .row > * { flex: 1; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > label { font-size: 13px; color: var(--text-2); font-weight: 500; }
.field > label .req { color: var(--danger); margin-left: 2px; }
.field .hint { font-size: 12px; color: var(--text-3); }
.input, select.input, textarea.input {
    width: 100%; height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); transition: border-color .12s;
}
textarea.input { height: auto; min-height: 84px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.input:hover { border-color: var(--text-3); }
.input:focus { border-color: var(--primary); outline: none; }
.input.invalid { border-color: var(--danger); }
.field-error { font-size: 12px; color: var(--danger); }
.form-error { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger); font-size: 13px; white-space: pre-wrap; }
.notice { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-3); color: var(--text-2); font-size: 13px; }
.notice .material-icons { font-size: 18px; }
.notice.warn { background: var(--warning-soft); color: var(--warning); }
.notice.info { background: var(--primary-soft); color: var(--text); }
.notice.danger { background: var(--danger-soft); color: var(--danger); }

/* ── segmented / tabs ────────────────────── */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg > button { border: 0; background: transparent; padding: 0 12px; height: 30px; cursor: pointer; color: var(--text-2); }
.seg > button + button { border-left: 1px solid var(--border); }
.seg > button.on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-soft); }
.tabs > button, .tabs > a {
    position: relative; border: 0; background: transparent; padding: 8px 10px; cursor: pointer; color: var(--text);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.tabs > button:hover, .tabs > a:hover { background: var(--hover); text-decoration: none; }
.tabs > .on::after { content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--primary); }
.tabs .count { font-size: 12px; color: var(--text-3); }

/* ── badges / pills ──────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 11px; font-size: 12px; font-weight: 500; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.badge.blue { background: var(--primary-soft); color: var(--primary); }
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.orange { background: var(--warning-soft); color: var(--warning); }
.badge.purple { background: #ede1f8; color: #7b3fae; }
.pill { display: inline-flex; align-items: center; justify-content: center; height: 24px; padding: 0 12px; border-radius: 12px; color: #fff; font-size: 13px; font-weight: 500; }

/* ── table ───────────────────────────────── */
.table-wrap { overflow: auto; border: 1px solid var(--border-soft); border-radius: var(--radius); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; }
table.table th, table.table td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.table th { font-weight: 500; color: var(--text-2); font-size: 13px; background: var(--surface); position: sticky; top: 0; z-index: 1; }
table.table tbody tr:hover { background: var(--surface-2); }
table.table tbody tr:last-child td { border-bottom: 0; }
table.table td.actions { text-align: right; white-space: nowrap; }

/* ── card ────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); }
.card > .card-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); }
.card > .card-head h3 { font-size: 15px; font-weight: 600; flex: 1; color: var(--heading-text); }
.card > .card-body { padding: 16px; }

/* ── avatar ──────────────────────────────── */
.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; color: #fff; font-weight: 600; flex: none; }
.avatar.empty { background: transparent !important; border: 1px dashed var(--text-3); color: var(--text-3); }

/* ── empty / loading ─────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 40px 16px; color: var(--text-2); text-align: center; }
.empty-state .material-icons { font-size: 40px; color: var(--text-3); }
.empty-state p { font-size: 13px; color: var(--text-3); max-width: 420px; }
.loading { padding: 32px; text-align: center; color: var(--text-3); }
.loading::before { content: ''; display: inline-block; width: 16px; height: 16px; margin-right: 8px; vertical-align: -3px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.dev-only { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 3px; background: #fff3c4; color: #7a5b00; }

/* ── toast ───────────────────────────────── */
#ui_toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 1000; pointer-events: none; }
.ui-toast { min-width: 260px; max-width: 520px; padding: 10px 16px; border-radius: var(--radius-sm); background: #323338; color: #fff; box-shadow: var(--shadow); font-size: 14px; transition: opacity .3s, transform .3s; white-space: pre-wrap; }
.ui-toast.success { background: #00854d; }
.ui-toast.error { background: #d83a52; }
.ui-toast.out { opacity: 0; transform: translateY(8px); }

/* ── 공통 다이얼로그 / 알림 골격 ─────────── */
.dialog-box { position: relative; display: flex; flex-direction: column; width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.dialog-box > .dlg-head { display: flex; align-items: center; gap: 8px; padding: 18px 20px 8px; }
.dialog-box > .dlg-head h4 { flex: 1; font-size: 18px; font-weight: 600; color: var(--heading-text); }
.dialog-box > .dlg-body { padding: 12px 20px; overflow-y: auto; }
.dialog-box > .dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }

/* ── 자재 공통 (material.js) ─────────────── */
.badge .material-icons { font-size: 14px; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.item-picker-pop { position: fixed; z-index: 400; background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 300px; overflow-y: auto; padding: 4px; }
.item-picker-pop > button { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 8px; align-items: center; width: 100%; border: 0; background: transparent; padding: 7px 8px; border-radius: var(--radius-sm); cursor: pointer; text-align: left; color: var(--text); }
.item-picker-pop > button .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-picker-pop > button:hover, .item-picker-pop > button.on { background: var(--hover); }
.item-picker-pop .ip-msg { padding: 8px; color: var(--text-3); font-size: 13px; }
.item-picker-pop .ip-foot { border-top: 1px solid var(--border-soft); margin-top: 4px; padding: 6px 4px 2px; }
.qty-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-3); min-width: 80px; }
.qty-bar > span { height: 100%; }
table td.mono, table td .mono, table td.date { white-space: nowrap; }
