/* lic-service - 깔끔한 웹 디자인 (배치는 데스크톱 프로그램과 동일)
   기준: 흰 바탕 + 짙은 남색 글자, ETAS 포털 상단의 파랑→보라 그라데이션을
   "머리 띠"와 "진행 표시줄" 두 곳에만 사용하고 나머지는 차분하게 */
:root {
  --ink: #14213d;          /* 본문 */
  --ink-soft: #5b6780;     /* 보조 글자 */
  --canvas: #f3f5f9;       /* 페이지 바탕 */
  --surface: #ffffff;      /* 패널 */
  --well: #f8f9fc;         /* 결과 창 바탕 */
  --line: #e1e6ee;
  --line-strong: #c9d1de;
  --brand: #1d3f8f;        /* 주 버튼, 선택 표시 */
  --brand-hover: #163274;
  --brand-tint: #eaf0fb;
  --violet: #6a2c91;
  --magenta: #8e1f7f;
  --gradient: linear-gradient(90deg, #1d3f8f 0%, #4a3192 55%, #8e1f7f 100%);
  --danger: #c0392b;

  --sans: "Pretendard", "Pretendard Variable", "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  --mono: "D2Coding", Consolas, "Cascadia Mono", "Malgun Gothic", monospace;
  --radius-panel: 12px;
  --radius-ctl: 8px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- 머리 띠 */
.masthead { background: var(--gradient); color: #fff; }
.masthead-inner {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 24px;
}
.app-icon { width: 30px; height: 30px; border-radius: 7px; box-shadow: 0 0 0 1px rgba(255,255,255,.35); }
.masthead h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.version {
  font-size: 12px; font-weight: 500; padding: 2px 9px; border-radius: 999px;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.28);
}
.version:empty { display: none; }

/* ---------------------------------------------------------------- 본문 */
.page {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; gap: 14px;
  width: 100%; padding: 20px 24px 14px;          /* 화면 전체 너비 사용 (좌우 빈 공간 없음) */
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
}

/* ---- 입력 (4열: 라벨 | 입력·조회 | 보조 버튼 | 보조 버튼) ---- */
.controls { padding: 18px 20px 14px; }
.form-grid {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 104px 104px;
  gap: 10px;
  align-items: center;
}
.form-grid label { color: var(--ink-soft); font-size: 13px; font-weight: 500; }
.req { color: var(--magenta); }
.span3 { grid-column: span 3; }

input[type=text] {
  height: 38px; padding: 0 12px; min-width: 0;
  border: 1px solid var(--line-strong); border-radius: var(--radius-ctl);
  background: var(--surface); color: var(--ink); font: inherit;
  transition: border-color .15s, box-shadow .15s;
}
input[type=text]::placeholder { color: #9aa5b8; }
input[type=text]:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-tint); }
input[readonly] { background: var(--well); color: var(--ink-soft); }
.mono { font-family: var(--mono); letter-spacing: .01em; }

/* ---- 버튼 ---- */
button { font: inherit; cursor: pointer; }
.btn {
  height: 38px; padding: 0 14px; white-space: nowrap;
  border: 1px solid var(--line-strong); border-radius: var(--radius-ctl);
  background: var(--surface); color: var(--ink); font-weight: 500;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); background: var(--brand-tint); }
.btn:active:not(:disabled) { background: #dde7f8; }
.btn:disabled { color: #a3acbb; cursor: default; background: var(--well); }
.btn-primary {
  height: 46px; margin-top: 4px;
  background: var(--brand); border-color: var(--brand); color: #fff;
  font-size: 15px; font-weight: 600; letter-spacing: -0.005em;
}
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.btn-primary:active:not(:disabled) { background: #112a63; }
.btn-primary:disabled { background: #8a9cc4; border-color: #8a9cc4; color: #fff; }
.btn-row3 { height: 46px; margin-top: 4px; }
.btn-solid { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-solid:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); color: #fff; }
.btn-text {
  height: 28px; padding: 0 10px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ink-soft); font-weight: 500;
}
.btn-text:hover { background: #e6eaf2; color: var(--ink); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---- 진행 표시 ---- */
.progress-area { margin-top: 16px; }
.progress { height: 6px; border-radius: 999px; background: #e8ecf3; overflow: hidden; }
.progress-bar { height: 100%; width: 0; border-radius: inherit; background: var(--gradient); transition: width .3s ease; }
.status { margin-top: 8px; min-height: 20px; color: var(--ink-soft); font-size: 13px; }
.status.error { color: var(--danger); }

/* ---- 결과 (탭 + 출력) ---- */
.output { flex: 1; min-height: 260px; display: flex; flex-direction: column; overflow: hidden; }
.tab-strip {
  display: flex; flex-wrap: wrap; gap: 2px;
  padding: 0 12px; border-bottom: 1px solid var(--line);
}
.tab {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  height: 42px; padding: 0 8px 0 12px;
  color: var(--ink-soft); font-weight: 500; font-variant-numeric: tabular-nums;
  cursor: pointer; user-select: none;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); }
.tab.active::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px;
  height: 2px; border-radius: 2px; background: var(--brand);
}
.tab-x {
  width: 20px; height: 20px; line-height: 19px; text-align: center;
  border-radius: 5px; color: #9aa5b8; font-size: 15px;
}
.tab-x:hover { background: #fbe9e7; color: var(--danger); }
.tab.busy .tab-label::after { content: " …"; }

.output-text {
  flex: 1; margin: 0; padding: 16px 20px; overflow: auto;
  background: var(--surface); color: var(--ink);
  font: 13.5px/1.6 var(--mono); white-space: pre; tab-size: 4;
}
.output-text:focus-visible { outline-offset: -2px; }
.output-text.is-error { color: var(--danger); font-weight: 500; }

/* ---- 바로가기 ---- */
.links { display: grid; gap: 10px; }
.links button {
  height: 40px; padding: 0 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); border-radius: var(--radius-ctl);
  background: var(--surface); color: var(--ink); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.links button::after {   /* 새 창으로 열림 표시 */
  content: ""; flex: none; width: 12px; height: 12px; opacity: .55;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M4.5 1.5h6v6M10.5 1.5 4 8M8.5 7.5v3h-7v-7h3' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Cpath d='M4.5 1.5h6v6M10.5 1.5 4 8M8.5 7.5v3h-7v-7h3' fill='none' stroke='black' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.links button:hover { border-color: var(--brand); color: var(--brand); }

/* ---------------------------------------------------------------- 상태 표시줄 */
.statusbar { border-top: 1px solid var(--line); background: var(--surface); }
.statusbar-inner {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 24px;
  font-size: 13px;
}
.statusbar-inner > .muted, .statusbar-inner > .btn-text { flex: none; white-space: nowrap; }
.log-link {
  color: var(--brand); text-decoration: none; font-family: var(--mono); font-size: 12.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.log-link:hover { text-decoration: underline; }
.spacer { flex: 1; }
.muted { color: var(--ink-soft); }
.small { font-size: 12.5px; }

/* ---------------------------------------------------------------- 오른쪽 클릭 메뉴 */
.ctx-menu {
  position: fixed; z-index: 50; margin: 0; padding: 6px; list-style: none; min-width: 150px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(20, 33, 61, .14);
}
.ctx-menu li { padding: 8px 12px; border-radius: 6px; cursor: pointer; }
.ctx-menu li:hover { background: var(--brand-tint); color: var(--brand); }

/* ---------------------------------------------------------------- 대화상자 */
.modal {
  position: fixed; inset: 0; z-index: 40; padding: 16px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20, 33, 61, .38);
}
.modal[hidden] { display: none; }
.modal-box {
  width: 100%; max-width: 520px; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border-radius: 14px;
  box-shadow: 0 24px 60px rgba(20, 33, 61, .28);
}
.modal-box.wide { max-width: 780px; }
.modal-head { display: flex; align-items: center; padding: 16px 12px 8px 22px; }
.modal-head h2 { flex: 1; margin: 0; font-size: 17px; font-weight: 600; }
.modal-head .x { width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-soft); font-size: 20px; }
.modal-head .x:hover { background: #eef1f6; color: var(--ink); }
.modal-body { padding: 8px 22px 6px; overflow: auto; }
.modal-foot { display: flex; gap: 8px; padding: 14px 22px 18px; }
fieldset { margin: 0 0 18px; padding: 0; border: 0; }
legend { padding: 0; margin-bottom: 10px; font-weight: 600; }
fieldset > input { width: 100%; }
.links-grid { display: grid; grid-template-columns: 16px minmax(130px, 230px) minmax(0, 1fr) 64px; gap: 8px; align-items: center; }
.links-grid input { width: 100%; }
.links-grid button { height: 38px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-ctl); background: var(--surface); color: var(--ink); }
.links-grid button:hover { border-color: var(--brand); color: var(--brand); }
code { font-family: var(--mono); font-size: 12px; background: var(--well); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }

.log-table { width: 100%; border-collapse: collapse; }
.log-table th, .log-table td { padding: 10px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.log-table th { color: var(--ink-soft); font-weight: 500; font-size: 12.5px; }
.log-table td:first-child { font-family: var(--mono); font-size: 13px; }
.log-table td:nth-child(2) { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.log-table td:last-child { white-space: nowrap; width: 1%; }
.log-table button {
  height: 30px; padding: 0 10px; margin-left: 4px;
  border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); color: var(--ink);
}
.log-table button:hover { border-color: var(--brand); color: var(--brand); }

/* ---------------------------------------------------------------- 좁은 화면 */
@media (max-width: 720px) {
  html, body { height: auto; }          /* 좁은 화면: 페이지 전체가 스크롤 */
  body { min-height: 100vh; }
  .page { flex: none; }
  .output { flex: none; height: 70vh; min-height: 360px; }
  .masthead-inner, .page, .statusbar-inner { padding-left: 16px; padding-right: 16px; }
  .controls { padding: 16px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-grid label, .form-grid > span:empty { grid-column: span 2; }
  .form-grid label { margin-bottom: -4px; }
  .span3, #binName, #btnQuery { grid-column: span 2; }
  .links { grid-template-columns: 1fr !important; }
  .links-grid { grid-template-columns: 1fr; }
  .links-grid > span:first-child { display: none; }
  .statusbar-inner { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
