:root {
    --primary: #0F766E;
    --primary-dark: #115E59;
    --navy: #134E4A;
    --bg: #F8FAFC;
    --surface: #FFFFFF;
    --border: #E2E8F0;
    --text: #1E293B;
    --muted: #64748B;
    --ok: #16A34A;
    --warn: #F59E0B;
    --danger: #DC2626;
    --info: #0EA5E9;
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    --radius: 12px;
    --field-radius: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: "Pretendard", "Noto Sans KR", sans-serif; color: var(--text); background: var(--bg); }
button, a { font: inherit; }
a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; }

.field-label { display: block; margin-bottom: 6px; font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.field-input,
input.field-input,
select.field-input,
textarea.field-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--field-radius);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.875rem;
}
.field-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}
textarea.field-input { min-height: 88px; resize: vertical; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    font-weight: 700;
    background: #fff;
    color: var(--text);
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: #fff; border-color: var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 10px; font-size: 0.8rem; }
.form-error { color: var(--danger); font-weight: 700; margin: 8px 0 0; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-bg {
    position: fixed; inset: 0;
    background: linear-gradient(160deg, #134E4A 0%, #0F766E 45%, #99F6E4 140%);
    z-index: 0;
}
.login-card {
    position: relative; z-index: 1;
    width: min(100%, 420px);
    background: #fff;
    border-radius: 20px;
    padding: 28px 24px 24px;
    box-shadow: var(--shadow);
}
.login-brand { text-align: center; margin-bottom: 20px; }
.login-brand h1 { margin: 10px 0 0; font-size: 1.25rem; }
.login-form { display: grid; gap: 12px; }

.app-shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.sidebar {
    background: var(--navy);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 12px 8px 10px;
}
.sidebar-brand { display: flex; gap: 8px; align-items: center; padding: 2px 8px 10px; }
.sidebar-brand img { width: 28px; height: 28px; }
.sidebar-brand strong { display: block; font-size: 0.9rem; line-height: 1.25; }
.sidebar-brand span { display: block; font-size: 0.7rem; color: #99F6E4; font-weight: 600; line-height: 1.3; }
.side-nav { display: grid; gap: 1px; flex: 1; align-content: start; }
.side-nav a, .side-nav button {
    display: flex; align-items: center; gap: 8px; text-align: left; width: 100%;
    color: #ecfeff; background: transparent; border: 0;
    padding: 5px 10px; min-height: 32px; line-height: 1.2;
    border-radius: 8px; font-size: 0.8125rem; font-weight: 650;
}
.side-nav a:hover, .side-nav button:hover { background: rgba(255,255,255,.08); }
.side-nav a.is-active, .side-nav button.is-active { background: rgba(255,255,255,.12); }
.nav-ico { display: inline-flex; width: 16px; height: 16px; flex: 0 0 16px; opacity: .92; }
.nav-ico svg { width: 16px; height: 16px; display: block; }
.sidebar-foot { display: grid; gap: 4px; margin-top: 8px; }
.sidebar-foot .btn {
    color: #fff; background: transparent; border-color: rgba(255,255,255,.2);
    height: 32px; font-size: 0.8rem; font-weight: 650; justify-content: flex-start; padding: 0 10px;
}
.app-main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px;
    background: #fff;
    border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 1.1rem; flex: 1; }
.topbar-user { color: var(--muted); font-weight: 700; }
.content { padding: 20px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card, .panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.stat-card { padding: 16px; }
.stat-card b { display: block; font-size: 1.35rem; margin-top: 6px; }
.stat-card span { color: var(--muted); font-size: 0.82rem; font-weight: 700; }
.panel { padding: 16px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.toolbar .grow { flex: 1; min-width: 180px; }
.table-wrap { overflow: auto; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
table.data th { background: #F8FAFC; font-size: 0.78rem; color: var(--muted); }
table.data .num { text-align: right; font-variant-numeric: tabular-nums; }
table.data .chk-col { width: 36px; text-align: center; padding-right: 4px; }
.ol-flow { margin: 0 0 12px; color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.ol-flow b { color: var(--text); }
.ol-btn-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px; margin-left: 2px;
    border-radius: 999px; background: #CCFBF1; color: var(--primary-dark);
    font-size: 0.72rem; font-weight: 800;
}
.excel-hist { max-height: 360px; overflow: auto; }
.badge {
    display: inline-flex; align-items: center;
    height: 24px; padding: 0 8px; border-radius: 999px;
    font-size: 0.75rem; font-weight: 800;
    background: #F1F5F9; color: #334155;
}
.badge-submitted { background: #E0F2FE; color: #075985; }
.badge-accepted { background: #EDE9FE; color: #5B21B6; }
.badge-sent { background: #FEF3C7; color: #92400E; }
.badge-confirmed { background: #DBEAFE; color: #1E40AF; }
.badge-shipping { background: #CFFAFE; color: #155E75; }
.badge-done { background: #DCFCE7; color: #166534; }
.badge-canceled { background: #FEE2E2; color: #991B1B; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); font-size: 0.8rem; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-grid .full { grid-column: 1 / -1; }
.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; background: #F1F5F9; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.modal {
    position: fixed; inset: 0; z-index: 80;
    display: none; align-items: center; justify-content: center;
    padding: 16px; background: rgba(15, 23, 42, .45);
}
.modal.is-open { display: flex; }
.modal-panel {
    width: min(100%, 720px); max-height: 90vh; overflow: auto;
    background: #fff; border-radius: 16px;
}
.modal-head, .modal-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 14px 16px;
}
.modal-head { background: var(--navy); color: #fff; }
.modal-head h2 { margin: 0; font-size: 1rem; }
.modal-head .btn { color: #fff; border-color: rgba(255,255,255,.25); background: transparent; }
.modal-body { padding: 16px; }
.modal-foot { border-top: 1px solid var(--border); justify-content: flex-end; }

.upload-dropzone {
    border: 1.5px dashed #99F6E4;
    background: #F0FDFA;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}
.upload-dropzone.is-dragover { border-color: var(--primary); background: #CCFBF1; }
.upload-dropzone__title { margin: 0 0 4px; font-weight: 800; }
.upload-dropzone__hint { margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.upload-dropzone img { max-height: 88px; margin: 8px auto; display: block; border-radius: 8px; }

.cart-line { display: grid; grid-template-columns: 1fr 90px 90px auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.sidebar-backdrop { display: none; }

.mobile-only { display: none; }

@media (max-width: 900px) {
    .form-grid { grid-template-columns: 1fr; }
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; inset: 0 auto 0 0; width: 260px;
        transform: translateX(-105%); transition: transform .2s; z-index: 70;
    }
    .sidebar.is-open { transform: none; }
    .sidebar-backdrop.is-open, .sidebar-backdrop:not([hidden]) {
        display: block; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 60;
    }
    .mobile-only { display: inline-flex; }
    .cart-line { grid-template-columns: 1fr 1fr; }
}
