:root {
  --bg: #f6f7f9;
  --panel: #fff;
  --line: #e3e6ea;
  --text: #1d232a;
  --muted: #6b7480;
  --accent: #1f6feb;
  --ok: #1a7f37;
  --warn: #9a6700;
  --warn-bg: #fff8e1;
  --danger: #c62828;
  --danger-bg: #fdecec;
  --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Noto Sans KR", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 24px; height: 52px;
  background: #111827; color: #fff;
}
.topbar .brand { color: #fff; font-weight: 700; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a { color: #cbd5e1; padding: 6px 12px; border-radius: 6px; }
.topbar nav a.active { background: #1f2937; color: #fff; }
.topbar nav a:hover { text-decoration: none; color: #fff; }

main { max-width: 1200px; margin: 0 auto; padding: 24px; }
h1 { font-size: 20px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 24px 0 12px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }

table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #f0f2f5; font-weight: 600; color: #39424e; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 32px; }

input, select, textarea, button { font: inherit; }
input[type=text], input[type=number], input[type=date], input[type=search], select, textarea {
  padding: 7px 9px; border: 1px solid #cfd5dc; border-radius: 6px; background: #fff; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd3fb; border-color: var(--accent); }
textarea { width: 100%; min-height: 72px; resize: vertical; }
input.qty { width: 80px; text-align: right; }

button, .btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 6px; border: 1px solid #cfd5dc;
  background: #fff; color: var(--text); cursor: pointer;
}
button:hover, .btn:hover { background: #f3f4f6; text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #1a5fd0; }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.danger { background: #fff; border-color: var(--danger); color: var(--danger); }
button.danger:hover { background: var(--danger-bg); }
button:disabled { opacity: .5; cursor: not-allowed; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--text); }
.tabs a.active { background: var(--text); color: #fff; border-color: var(--text); }
.tabs a:hover { text-decoration: none; }
.tabs .count { margin-left: 4px; opacity: .7; font-size: 12px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.submitted { background: #e8f0fe; color: #1a4fb5; }
.badge.approved  { background: #e6f4ea; color: var(--ok); }
.badge.rejected  { background: var(--danger-bg); color: var(--danger); }
.badge.shipped   { background: #f3e8fd; color: #7b2cbf; }
.badge.received  { background: #eceff1; color: #455a64; }
.badge.rx        { background: #fde7e7; color: #b71c1c; }
.badge.otc       { background: #e7f5ff; color: #0b5394; }
.badge.active    { background: #e6f4ea; color: var(--ok); }
.badge.suspended { background: #eceff1; color: #546e7a; }
.badge.closed    { background: #eceff1; color: #546e7a; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px 20px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-weight: 600; font-size: 13px; color: #39424e; }
.field .hint { font-size: 12px; color: var(--muted); }
.field .err { font-size: 12px; color: var(--danger); }
.field.check { flex-direction: row; align-items: center; gap: 8px; padding-top: 22px; }
.req::after { content: " *"; color: var(--danger); }

dl.info { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.info dt { color: var(--muted); }
dl.info dd { margin: 0; }

.alert { padding: 10px 12px; border-radius: 6px; margin-bottom: 12px; }
.alert.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #f2d48a; }
.alert.danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #f3b8b8; }
.flag { display: block; font-size: 12px; color: var(--warn); }
.flag.bad { color: var(--danger); }
.row-warn td { background: #fffdf3; }

.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } main { padding: 16px; } }

#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 10; max-width: 90vw;
}
#toast.error { background: var(--danger); }

.temp-pw code { font-size: 18px; font-weight: 700; letter-spacing: 1px; background: #fff; padding: 2px 8px; border-radius: 4px; margin: 0 6px; user-select: all; }
.temp-pw > div + div { margin-top: 6px; font-size: 13px; }

/* 기관용 화면 */
.auth-wrap { max-width: 380px; margin: 64px auto; }
.auth-wrap h1 { text-align: center; }
.auth-wrap .field { margin-bottom: 12px; }
.auth-wrap input { width: 100%; }
.auth-wrap button.primary { width: 100%; justify-content: center; padding: 10px; }
.topbar .who { margin-left: auto; color: #cbd5e1; font-size: 13px; display: flex; gap: 12px; align-items: center; }
.topbar .who a, .topbar .who button { color: #cbd5e1; background: none; border: 0; padding: 0; cursor: pointer; font-size: 13px; }
.topbar .who button:hover { color: #fff; text-decoration: underline; background: none; }
.cart-bar { position: sticky; bottom: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin-top: 16px; box-shadow: 0 -4px 12px rgba(0,0,0,.05); }
.cart-bar .summary { font-weight: 600; margin-bottom: 8px; }
tr.selected td { background: #f2f7ff; }
