/* 에이전트고삐 — 공통 스타일 */
:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --panel-2: #eef3f8;
  --line: #d8e0ea;
  --line-soft: #e8edf3;
  --text: #172033;
  --text-dim: #536173;
  --text-faint: #8290a3;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.10);

  --auto: #15803d;
  --verify: #b7791f;
  --readonly: #c05621;
  --stop: #dc2626;

  --radius: 14px;
  --radius-sm: 9px;
  --mono: "JetBrains Mono", "D2Coding", ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Malgun Gothic",
               "Apple SD Gothic Neo", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* ---------- 레이아웃 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 28px;
  padding: 0 28px; height: 60px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 0 rgba(23, 32, 51, 0.02);
}
.brand { display: flex; align-items: baseline; gap: 10px; font-weight: 700; font-size: 17px; }
.brand small { font-weight: 400; font-size: 12px; color: var(--text-faint); letter-spacing: .02em; }
.nav { display: flex; gap: 4px; margin-left: auto; }
.nav a {
  padding: 7px 15px; border-radius: 999px; font-size: 14px; color: var(--text-dim);
  transition: background .15s, color .15s;
}
.nav a:hover { background: var(--panel-2); color: var(--text); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 34px 28px 80px; }
.wrap.wide { max-width: 1340px; }

.page-head { margin-bottom: 26px; }
.page-head h1 { margin: 0 0 8px; font-size: 25px; letter-spacing: -.02em; }
.page-head p {
  margin: 0; color: var(--text-dim); font-size: 14.5px;
  width: 100%; max-width: none;
}

/* ---------- 패널 ---------- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: 0 12px 30px rgba(23, 32, 51, 0.06);
}
.panel + .panel { margin-top: 18px; }
.panel-title {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 16px; font-size: 14px; font-weight: 700;
  color: var(--text-dim); letter-spacing: .04em; text-transform: uppercase;
}
.panel-title .num {
  display: grid; place-items: center;
  width: 21px; height: 21px; border-radius: 6px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 11px; font-weight: 700;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.muted { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.small { font-size: 13px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------- 폼 ---------- */
textarea, input[type=text], input[type=number], select {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 14px 15px; font-family: inherit; font-size: 15px; line-height: 1.7;
  outline: none; transition: border-color .15s;
}
textarea { resize: vertical; }
textarea:focus, input:focus, select:focus { border-color: var(--accent); }
textarea::placeholder { color: var(--text-faint); }
select { appearance: none; min-height: 49px; }
input:disabled { color: var(--text-faint); background: #eef1f5; cursor: not-allowed; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--panel-2); color: var(--text);
  font-family: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover:not(:disabled) { background: #e3eaf3; border-color: #c6d1de; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #1d4ed8; border-color: #1d4ed8; }
.btn.lg { padding: 14px 30px; font-size: 15.5px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.chip {
  padding: 6px 13px; border-radius: 999px; font-size: 13px;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--text-dim); cursor: pointer; transition: all .15s;
}
.chip:hover { color: var(--text); border-color: #bac6d5; }

/* ---------- 권한 배지 ---------- */
.perm {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .03em;
  border: 1px solid currentColor;
}
.perm .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.perm.AUTO      { color: var(--auto);     background: rgba(63,185,80,.10); }
.perm.VERIFY    { color: var(--verify);   background: rgba(210,153,34,.10); }
.perm.READ_ONLY { color: var(--readonly); background: rgba(240,136,62,.10); }
.perm.STOP      { color: var(--stop);     background: rgba(248,81,73,.10); }

/* ---------- 정책 표 ---------- */
.policy-list { display: flex; flex-direction: column; gap: 1px; background: var(--line-soft);
               border: 1px solid var(--line-soft); border-radius: var(--radius-sm); overflow: hidden; }
.policy-row { display: grid; grid-template-columns: 200px 1fr; gap: 18px;
              padding: 13px 16px; background: var(--panel); align-items: baseline; }
.policy-row dt { color: var(--text-dim); font-size: 13.5px; }
.policy-row dd { margin: 0; font-weight: 600; }
.policy-row dd .hint { display: block; font-weight: 400; font-size: 12.5px;
                       color: var(--text-faint); margin-top: 3px; }
.policy-row.editing { align-items: start; }
.policy-row.editing dd { font-weight: 400; }
.policy-control, .policy-row select { max-width: 260px; min-height: 40px; padding: 8px 10px; font-size: 14px; }
.policy-control.hour { max-width: 88px; }
.inline-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: 7px; }
.check-item {
  display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  color: var(--text); font-weight: 500;
}
.check-item input { width: 16px; height: 16px; accent-color: var(--accent); }

.notice {
  padding: 12px 15px; border-radius: var(--radius-sm); font-size: 13.5px;
  background: #fff7df; border: 1px solid #f2d58b;
  color: #7a5300;
}
.notice ul { margin: 6px 0 0; padding-left: 18px; }
.notice.ok { background: #e8f7ed; border-color: #a9dfb8; color: #126b33; }
.notice.err { background: #fff0ee; border-color: #f5b5af; color: #b42318; }

/* ---------- 시나리오 카드 ---------- */
.scn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.scn {
  text-align: left; padding: 18px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line);
  cursor: pointer; transition: border-color .15s, background .15s, transform .12s;
  display: flex; flex-direction: column; gap: 9px; font-family: inherit; color: inherit;
}
.scn:hover { border-color: #bac6d5; transform: translateY(-1px); }
.scn.sel { border-color: var(--accent); background: #eef5ff; }
.scn-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.scn h3 { margin: 0; font-size: 15.5px; }
.scn .tag { font-size: 11px; color: var(--text-faint); font-family: var(--mono);
            border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.scn p { margin: 0; font-size: 13.5px; color: var(--text-dim); }

/* ---------- 결과 화면 ---------- */
.result-top { margin-bottom: 18px; }
.result-bottom { display: grid; grid-template-columns: 340px 1fr; gap: 18px; align-items: start; }
.left-col { display: flex; flex-direction: column; gap: 10px; }

.summary-head { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.summary-head h2 { margin: 0 0 6px; font-size: 21px; letter-spacing: -.02em; }
.summary-head .lead {
  margin: 0; color: var(--text-dim); font-size: 14.5px;
  width: 100%; max-width: none;
}

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
            gap: 1px; margin-top: 18px; background: var(--line-soft);
            border: 1px solid var(--line-soft); border-radius: var(--radius-sm); overflow: hidden; }
.stat { padding: 13px 15px; background: var(--panel); }
.stat .k { font-size: 12px; color: var(--text-faint); }
.stat .v { font-size: 18px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .v.sm { font-size: 15px; }

/* 권한 카드 */
.perm-card { text-align: center; padding: 26px 22px; }
.perm-card .big { font-size: 34px; font-weight: 800; letter-spacing: -.03em; margin: 10px 0 4px; }
.perm-card .lbl { font-size: 14px; font-weight: 600; }
.perm-card .desc { font-size: 13px; color: var(--text-dim); margin-top: 12px; line-height: 1.6; }
.perm-ladder { display: flex; flex-direction: column; gap: 5px; margin-top: 18px; }
.rung { display: flex; align-items: center; gap: 9px; padding: 7px 11px;
        border-radius: 7px; font-size: 12.5px; border: 1px solid transparent;
        background: var(--panel-2); color: var(--text-faint); }
.rung.on { font-weight: 700; }
.rung .cap { margin-left: auto; font-size: 11px; opacity: .8; }

/* 위험도 카드 */
.score-big { font-size: 46px; font-weight: 800; letter-spacing: -.04em; line-height: 1;
             font-variant-numeric: tabular-nums; }
.score-band { font-size: 13.5px; font-weight: 700; margin-top: 6px; }
.meter { height: 7px; border-radius: 4px; background: var(--panel-2); overflow: hidden; margin-top: 14px; }
.meter i { display: block; height: 100%; border-radius: 4px; transition: width .5s ease; }
.meter-scale { display: flex; justify-content: space-between; font-size: 10.5px;
               color: var(--text-faint); margin-top: 5px; font-family: var(--mono); }
.sub-scores { display: flex; flex-direction: column; gap: 11px; margin-top: 18px; }
.sub { font-size: 12.5px; }
.sub .r { display: flex; justify-content: space-between; margin-bottom: 4px; }
.sub .r b { font-variant-numeric: tabular-nums; }
.sub .bar { height: 4px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.sub .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* 설명 */
.explain h3 { margin: 0 0 10px; font-size: 18px; letter-spacing: -.01em; }
.explain .para { color: var(--text-dim); font-size: 14.3px; margin: 0 0 14px; }
.explain .para.strong { color: var(--text); }
.rec { padding: 14px 16px; border-radius: var(--radius-sm); font-size: 13.8px;
       background: var(--accent-soft); border: 1px solid rgba(76,141,255,.22); }

.factors { display: grid; grid-template-columns: 1fr 1fr; gap: 1px;
           background: var(--line-soft); border: 1px solid var(--line-soft);
           border-radius: var(--radius-sm); overflow: hidden; margin-top: 6px; }
.factor { padding: 13px 15px; background: var(--panel); border-left: 3px solid transparent; }
.factor.NORMAL  { border-left-color: #b8c3d0; }
.factor.CAUTION { border-left-color: var(--verify); }
.factor.RISK    { border-left-color: var(--stop); }
.factor .fl { font-size: 12px; color: var(--text-faint); display: flex; justify-content: space-between; }
.factor .fv { font-weight: 700; font-size: 14.5px; margin: 3px 0 4px; }
.factor .fn { font-size: 12.5px; color: var(--text-dim); line-height: 1.55; }
.badge { font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px; letter-spacing: .04em; }
.badge.CAUTION { color: var(--verify); background: rgba(210,153,34,.14); }
.badge.RISK { color: var(--stop); background: rgba(248,81,73,.14); }

/* 타임라인 */
table.tl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tl th { text-align: left; padding: 9px 10px; color: var(--text-faint);
              font-size: 11.5px; font-weight: 600; letter-spacing: .04em;
              border-bottom: 1px solid var(--line); white-space: nowrap; }
table.tl td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.tl tr:last-child td { border-bottom: none; }
table.tl td.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.oc { font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.oc.EXECUTED { color: var(--auto); background: rgba(63,185,80,.12); }
.oc.PENDING_APPROVAL { color: var(--verify); background: rgba(210,153,34,.12); }
.oc.BLOCKED { color: var(--stop); background: rgba(248,81,73,.12); }
.oc.REJECTED_BY_BANK { color: var(--readonly); background: rgba(240,136,62,.12); }
.risk-cell { display: inline-block; min-width: 42px; padding: 2px 8px; border-radius: 6px;
             font-family: var(--mono); font-size: 12px; font-weight: 700; text-align: center; }
.newtag { font-size: 10px; font-weight: 700; color: var(--readonly);
          background: rgba(240,136,62,.13); padding: 1px 6px; border-radius: 4px; margin-left: 6px; }

/* 권한 변경 이벤트 */
.events { display: flex; flex-direction: column; gap: 9px; }
.event { display: flex; gap: 12px; align-items: flex-start; padding: 11px 13px;
         background: var(--panel-2); border-radius: var(--radius-sm); font-size: 13px; }
.event .t { font-family: var(--mono); font-size: 12px; color: var(--text-faint); white-space: nowrap; }
.event .body { flex: 1; }
.event .transition { display: flex; align-items: center; gap: 7px; margin-bottom: 3px; flex-wrap: wrap; }
.event .why { color: var(--text-dim); font-size: 12.5px; }

.spinner { width: 15px; height: 15px; border: 2px solid rgba(37,99,235,.22);
           border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; padding: 70px 20px; color: var(--text-faint); }

.tagline { font-size: 12px; color: var(--text-faint); font-family: var(--mono); }

@media (max-width: 1000px) {
  .result-bottom { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .factors { grid-template-columns: 1fr; }
  .policy-row { grid-template-columns: 1fr; gap: 2px; }
  .check-grid { grid-template-columns: 1fr; }
  .policy-control, .policy-row select { max-width: 100%; }
}
