:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel2: #1e222b;
  --line: #2a2f3a;
  --text: #e6e8ee;
  --muted: #9aa2b1;
  --accent: #4f8cff;
  --accent2: #6ee7b7;
  --danger: #ef4444;
  --warn: #f97316;
  --ok: #22c55e;
  --notice: #22c55e;
  --critical: #ef4444;
  --expired: #7f1d1d;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Pretendard", "Malgun Gothic", -apple-system, system-ui, sans-serif;
  background: var(--bg); color: var(--text); font-size: 13.5px;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea {
  font-family: inherit; font-size: 13px; background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
a { color: var(--accent); }

/* Login */
.login-screen { height: 100%; display: grid; place-items: center; background: radial-gradient(1200px 600px at 30% -10%, #1b2440, #0f1115); }
.login-card { width: 340px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px 28px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.4); }
.login-logo { font-weight: 800; font-size: 26px; letter-spacing: 1px; text-align: center; }
.login-logo span { color: var(--accent); }
.login-sub { text-align: center; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.login-card button { background: var(--accent); color: #fff; border: none; border-radius: 8px; padding: 11px; font-weight: 700; margin-top: 4px; }
.login-error { color: var(--danger); font-size: 12px; min-height: 16px; text-align: center; }
.login-hint { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.6; border-top: 1px solid var(--line); padding-top: 10px; }
.signup-link { text-align: center; font-size: 12px; color: var(--muted); margin-top: 4px; }
#signup-panel { width: 360px; max-height: 92vh; overflow-y: auto; }
#signup-panel input { width: 100%; }
.signup-type { display: flex; gap: 8px; }
.signup-type label { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; font-size: 12px; cursor: pointer; }
.signup-type label.on { border-color: var(--accent); background: rgba(79,140,255,.12); }
#signup-btn { background: var(--ok); color: #05240f; border: none; border-radius: 8px; padding: 11px; font-weight: 700; margin-top: 4px; }

/* Layout */
.app { display: grid; grid-template-columns: 236px 1fr; height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow: hidden; }
.brand { padding: 18px 20px; font-weight: 800; font-size: 18px; letter-spacing: .5px; border-bottom: 1px solid var(--line); }
.brand span { color: var(--accent); }
.brand small { display: block; color: var(--muted); font-weight: 500; font-size: 11px; letter-spacing: 2px; }
#nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 20px; color: var(--muted); cursor: pointer; font-weight: 500; border-left: 3px solid transparent; }
.nav-item:hover { background: var(--panel2); color: var(--text); }
.nav-item.active { color: var(--text); border-left-color: var(--accent); background: linear-gradient(90deg, rgba(79,140,255,.12), transparent); }
.nav-item .ico { width: 18px; text-align: center; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; border-radius: 10px; font-size: 10px; padding: 1px 7px; font-weight: 700; }
.nav-group { font-size: 10px; letter-spacing: 1px; color: #5c6472; padding: 12px 20px 4px; text-transform: uppercase; }
.userbox { border-top: 1px solid var(--line); padding: 14px 20px; }
#userinfo { font-size: 12px; margin-bottom: 8px; }
#userinfo b { display: block; font-size: 13px; }
.userbox button { width: 100%; background: var(--panel2); color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 7px; }

.main { display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 56px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; background: var(--panel); }
.crumb { font-weight: 700; font-size: 15px; }
.crumb small { color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.role-badge { background: var(--panel2); border: 1px solid var(--line); border-radius: 20px; padding: 4px 12px; font-size: 12px; }
.vat-toggle { display: flex; gap: 4px; align-items: center; }
.vat-toggle button { background: var(--panel2); border: 1px solid var(--line); color: var(--muted); border-radius: 6px; padding: 4px 10px; font-size: 12px; }
.vat-toggle button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.view { flex: 1; overflow-y: auto; padding: 22px 24px; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.btn { background: var(--panel2); border: 1px solid var(--line); color: var(--text); border-radius: 8px; padding: 8px 14px; font-weight: 600; font-size: 13px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #05240f; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.search { min-width: 220px; }

/* Cards */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 26px; font-weight: 800; margin-top: 6px; }
.card .value small { font-size: 13px; color: var(--muted); font-weight: 500; }
.card.alert { border-color: rgba(239,68,68,.4); }
.card.clickable { cursor: pointer; transition: border-color .12s, transform .08s; }
.card.clickable:hover { border-color: var(--accent); }
.card.clickable:active { transform: translateY(1px); }
.card .sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel h3 { margin: 0 0 12px; font-size: 14px; }
.panel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1100px){ .panel-grid { grid-template-columns: 1fr; } }

/* Table */
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--panel2); color: var(--muted); font-weight: 600; position: sticky; top: 0; font-size: 11.5px; }
tbody tr:hover { background: rgba(255,255,255,.02); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* pills */
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; border: 1px solid var(--line); }
.pill.green { background: rgba(34,197,94,.15); color: #86efac; border-color: transparent; }
.pill.orange { background: rgba(249,115,22,.15); color: #fdba74; border-color: transparent; }
.pill.red { background: rgba(239,68,68,.15); color: #fca5a5; border-color: transparent; }
.pill.blue { background: rgba(79,140,255,.15); color: #93c5fd; border-color: transparent; }
.pill.gray { background: var(--panel2); color: var(--muted); }
.exp-notice { color: #86efac; font-weight: 700; }
.exp-warn { color: #fdba74; font-weight: 700; }
.exp-critical { color: #fca5a5; font-weight: 700; }
.exp-expired { color: #ef4444; font-weight: 800; }
tr.rowlevel-critical { background: rgba(239,68,68,.08); }
tr.rowlevel-warn { background: rgba(249,115,22,.07); }
tr.rowlevel-notice { background: rgba(34,197,94,.06); }
tr.rowlevel-expired { background: rgba(127,29,29,.18); }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: min(920px, 94vw); max-height: 90vh; display: flex; flex-direction: column; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.modal .close { background: none; border: none; color: var(--muted); font-size: 20px; }

/* Form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; color: var(--muted); }
.field label .req { color: var(--danger); }
.field input[type=checkbox] { width: 18px; height: 18px; }
.field .checkline { display: flex; align-items: center; gap: 8px; height: 36px; }
.form-section { grid-column: 1/-1; margin-top: 6px; font-size: 12px; font-weight: 700; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 6px; }

/* toast */
#toast-root { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 8px; padding: 12px 16px; min-width: 240px; box-shadow: 0 10px 30px rgba(0,0,0,.4); animation: slidein .2s; font-size: 13px; }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--ok); }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }

.help { font-size: 12px; color: var(--muted); line-height: 1.7; }
.tag { display: inline-block; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; font-size: 11px; margin: 2px; }
.linkbtn { background: none; border: none; color: var(--accent); padding: 0; font-size: 12px; text-decoration: underline; }
.mini { font-size: 11px; color: var(--muted); }
.inline-alert { background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.35); color: #fca5a5; padding: 8px 12px; border-radius: 8px; font-size: 12px; margin: 8px 0; white-space: pre-line; }
.inline-ok { background: rgba(34,197,94,.1); border: 1px solid rgba(34,197,94,.35); color: #86efac; padding: 8px 12px; border-radius: 8px; font-size: 12px; margin: 8px 0; }
.cart-table td { padding: 6px 8px; }
.section-label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .5px; margin: 18px 2px 10px; text-transform: none; border-left: 3px solid var(--accent); padding-left: 8px; }
.branch-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.branch-checks label { display: flex; align-items: center; gap: 6px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; font-size: 12px; cursor: pointer; }
.branch-checks label.on { border-color: var(--accent); background: rgba(79,140,255,.12); }
.branch-checks input { width: 16px; height: 16px; }
