:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #e3e7ef;
  --text: #1c2433;
  --muted: #6b7486;
  --primary: #2563eb;
  --primary-weak: #e8efff;
  --danger: #dc2626;
  --ok: #16a34a;
  --warn: #d97706;
  --v380: #fde3c2;
  --v380-line: #e69a3a;
  --v220: #cfeef2;
  --v220-line: #3aa4b4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  color: var(--text);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }

/* layout */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: #111827; color: #cbd2e0; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
.brand { color: #fff; font-weight: 700; font-size: 16px; padding: 4px 10px 18px; display: flex; gap: 8px; align-items: center; }
.brand .logo { width: 22px; height: 22px; border-radius: 6px; background: var(--primary); display: inline-block; }
.nav a { display: block; color: #cbd2e0; padding: 9px 12px; border-radius: 8px; margin-bottom: 2px; }
.nav a:hover { background: #1f2937; color: #fff; }
.nav a.active { background: var(--primary); color: #fff; }
.sidebar .me { position: absolute; bottom: 16px; left: 12px; right: 12px; font-size: 12px; border-top: 1px solid #263044; padding-top: 12px; }
.sidebar .me button { margin-top: 8px; width: 100%; }
.main { padding: 24px 28px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.mt { margin-top: 12px; }

/* cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card .label { color: var(--muted); font-size: 12px; }
.card .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* forms */
input, select, textarea, button { font: inherit; }
input, select, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: #fff; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-weak); border-color: var(--primary); }
textarea { width: 100%; min-height: 80px; resize: vertical; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.field > input, label.field > select, label.field > textarea { color: var(--text); font-size: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.btn { border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 8px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f6f7fb; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(.95); }
.btn.danger { color: var(--danger); border-color: #f3c2c2; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.check { display: flex; align-items: center; gap: 8px; }

/* table */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfd; }
tr.click { cursor: pointer; }
tr.click:hover td { background: #f8faff; }
.table-wrap { overflow-x: auto; }
.pager { display: flex; justify-content: flex-end; gap: 6px; margin-top: 12px; align-items: center; }

/* badges */
.badge { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef1f6; color: #3b4558; }
.badge.ASSIGNED { background: #eef1f6; }
.badge.IN_PROGRESS { background: #e8efff; color: #1d4ed8; }
.badge.SUBMITTED { background: #fff4e0; color: #b45309; }
.badge.APPROVED { background: #e5f7ec; color: #15803d; }
.badge.REJECTED { background: #fde8e8; color: #b91c1c; }
.badge.SCHEDULED { background: #e8efff; color: #1d4ed8; }
.badge.SENT { background: #e5f7ec; color: #15803d; }
.badge.CANCELED, .badge.SENDING { background: #eef1f6; }
.badge.FAILED { background: #fde8e8; color: #b91c1c; }

/* meter box grid */
.box-wrap { overflow-x: auto; padding-bottom: 4px; }
.mbox { display: inline-grid; gap: 6px; padding: 10px; background: #e9ecef; border: 3px solid #9aa3ae; border-radius: 6px; }
.mbox .cell { border: 1px dashed #c3c9d1; border-radius: 4px; min-height: 76px; }
.mbox .meter { border-radius: 6px; padding: 6px; font-size: 12px; text-align: center; display: flex; flex-direction: column; justify-content: center; gap: 2px; min-height: 76px; }
.mbox .meter.V380 { background: var(--v380); border: 2px solid var(--v380-line); }
.mbox .meter.V220 { background: var(--v220); border: 2px solid var(--v220-line); }
.mbox .meter b { font-size: 13px; }
.mbox .meter .no { font-family: ui-monospace, Consolas, monospace; font-size: 11px; color: #3b4558; word-break: break-all; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin: 6px 0 10px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* signatures */
.sigs { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.sig { border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.sig img { max-width: 100%; height: 80px; object-fit: contain; display: block; margin-top: 6px; background: #fff; }

/* timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 8px 0 8px 16px; border-left: 2px solid var(--line); position: relative; }
.timeline li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); position: absolute; left: -5px; top: 13px; }

/* modal & toast */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: min(680px, 100%); max-height: 90vh; overflow: auto; padding: 22px; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
#toast-root { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 380px; }
.toast.error { background: var(--danger); }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login { width: 360px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); }
.login h1 { margin-bottom: 4px; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }

.split { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar .me { position: static; margin-top: 12px; }
  .split { grid-template-columns: 1fr; }
  .main { padding: 16px; }
}
