:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #687386;
  --line: #d8dee9;
  --primary: #1f4e78;
  --primary-dark: #173b5b;
  --ok-bg: #e7f7ee;
  --ok: #166534;
  --warn-bg: #fff7dc;
  --warn: #92400e;
  --neutral-bg: #e9eef5;
  --danger: #b42318;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans KR", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar { height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 24px; background: #0f2740; color: #fff; box-shadow: 0 2px 12px rgba(0,0,0,.12); }
.brand { display: flex; align-items: baseline; gap: 12px; font-weight: 700; }
.brand a { color: #fff; font-size: 20px; letter-spacing: .04em; }
.brand span { color: #c8d7ea; font-size: 14px; font-weight: 500; }
.nav { display: flex; align-items: center; gap: 14px; }
.nav a { color: #e7eef8; }
.nav .user { color: #b9c9dc; border-left: 1px solid rgba(255,255,255,.25); padding-left: 14px; }
.logout-form { margin: 0; }
.logout-form button { color: #fff; background: transparent; border: 1px solid rgba(255,255,255,.35); border-radius: 6px; padding: 6px 10px; cursor: pointer; }

.container { width: min(1480px, calc(100% - 40px)); margin: 28px auto 60px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 18px; }
h1 { margin: 0 0 6px; font-size: 28px; }
h2 { margin: 0 0 14px; font-size: 18px; }
.muted { color: var(--muted); margin: 0; }
.actions, .inline-actions, .form-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card, .auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: 0 6px 18px rgba(32, 48, 72, .05); }
.narrow { max-width: 680px; }
.narrow-form { max-width: 980px; }
.auth-card { max-width: 420px; margin: 80px auto; }
.auth-card h1 { font-size: 24px; }

button, .button { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); font-weight: 600; cursor: pointer; }
button:hover, .button:hover { text-decoration: none; background: #f2f5fa; }
.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.primary:hover { background: var(--primary-dark); }
.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.danger-link { color: var(--danger); }
.full { width: 100%; margin-top: 14px; }

.messages { margin-bottom: 16px; }
.message { padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line); background: #fff; margin-bottom: 8px; }
.message.success { background: #e8f7ee; border-color: #b7e1c4; }
.message.warning { background: #fff7dc; border-color: #f0d98b; }
.message.error { background: #ffebe9; border-color: #ffbbb3; color: #8f1b11; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.stat span { display: block; color: var(--muted); font-size: 13px; }
.stat strong { font-size: 28px; display: block; margin-top: 4px; }

.filter-grid { display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); gap: 12px; align-items: end; }
.filter-grid .wide { grid-column: span 2; }
.filter-actions { display: flex; gap: 8px; }
label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
input, select, textarea, .form-control { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: #fff; color: var(--text); }
input:disabled, select:disabled, textarea:disabled { background: #f0f3f7; color: #6b7280; }
small { display: block; margin-top: 5px; color: var(--muted); }
.error-text { color: var(--danger); }
.req { color: var(--danger); margin-left: 3px; }

.table-card { overflow-x: auto; padding: 0; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { border-bottom: 1px solid var(--line); padding: 10px 12px; vertical-align: top; }
.data-table th { background: #eef3f8; text-align: left; font-size: 13px; color: #344154; white-space: nowrap; }
.data-table tr:hover td { background: #fafcff; }
.data-table.compact th, .data-table.compact td { padding: 8px 9px; }
.title-col { min-width: 260px; }
.remark-col { max-width: 300px; }
.empty { text-align: center; color: var(--muted); padding: 28px !important; }

.badge { display: inline-flex; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.neutral { background: var(--neutral-bg); color: #344154; }

.detail-grid { display: grid; grid-template-columns: 1fr 1.3fr; gap: 16px; margin-bottom: 16px; }
.detail-list { display: grid; grid-template-columns: 140px 1fr; row-gap: 9px; column-gap: 12px; margin: 0; }
.detail-list dt { color: var(--muted); font-weight: 700; }
.detail-list dd { margin: 0; }
.preline { white-space: pre-line; }

.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.form-field.span-2 { grid-column: span 2; }
.form-actions { margin-top: 18px; }

.master-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.master-card { color: var(--text); text-decoration: none; }
.master-card span { color: var(--muted); font-weight: 700; }
.master-card strong { display: block; font-size: 34px; margin: 10px 0; }
.master-card em { font-style: normal; color: var(--primary); font-weight: 700; }

.pagination { display: flex; justify-content: center; gap: 12px; align-items: center; margin-top: 18px; }
.pagination a { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }

@media (max-width: 980px) {
  .page-head, .topbar { flex-direction: column; height: auto; align-items: stretch; gap: 10px; padding: 14px 18px; }
  .nav { flex-wrap: wrap; }
  .stats-grid, .filter-grid, .detail-grid, .form-grid { grid-template-columns: 1fr; }
  .filter-grid .wide, .form-field.span-2 { grid-column: span 1; }
}

.master-help { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.master-help strong { color: var(--primary); }
.master-help span { color: var(--muted); }
.master-group { margin-bottom: 16px; }
.master-group-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: #f8fbff; }
.master-group-head h2 { margin: 0; }
.drag-col { width: 58px; text-align: center !important; white-space: nowrap; }
.drag-handle { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; color: #64748b; cursor: grab; font-weight: 800; letter-spacing: -3px; user-select: none; }
.drag-handle:hover { background: #e8eef6; color: var(--primary); }
tr.dragging { opacity: .45; }
tr.dragging td { background: #edf5ff !important; }
.sort-save-status { min-height: 18px; padding: 8px 14px 12px; }

.use-col { width: 92px; text-align: center !important; white-space: nowrap; }
.action-col { width: 92px; text-align: center !important; white-space: nowrap; }

.issue-list-card { overflow-x: auto; }
.issue-table { min-width: 1780px; }
.issue-table th, .issue-table td { padding: 8px 9px; }
.doc-col { width: 170px; min-width: 170px; }
.code-col { width: 86px; min-width: 86px; text-align: center !important; }
.issue-title-col { width: 300px; min-width: 300px; }
.issue-content-col { width: 420px; min-width: 420px; }
.owner-col { width: 100px; min-width: 100px; }
.date-col { width: 132px; min-width: 132px; }
.status-col { width: 138px; min-width: 138px; }
.file-col { width: 68px; min-width: 68px; text-align: center !important; }
.issue-remark-col { width: 210px; min-width: 210px; }

.inline-field { width: 100%; min-height: 32px; border-radius: 6px; padding: 6px 8px; font-size: 13px; }
.inline-title { font-weight: 600; }
.inline-select { padding: 5px 7px; }
.inline-date { padding: 5px 7px; }
.inline-content { min-height: 42px; max-height: 260px; resize: vertical; transition: min-height .15s ease, box-shadow .15s ease; }
.inline-content:focus { min-height: 150px; }
.inline-remark { min-height: 42px; max-height: 180px; resize: vertical; }
.inline-remark:focus { min-height: 92px; }
.inline-field.saving { background: #f8fbff; }
.inline-field.save-error { border-color: var(--danger); box-shadow: 0 0 0 2px rgba(180, 35, 24, .08); }
.inline-save-state { display: block; min-height: 16px; margin-top: 4px; color: var(--muted); font-size: 11px; }

.code-pop { position: relative; display: inline-flex; justify-content: center; }
.code-chip { min-height: 28px; padding: 4px 7px; border: 0; background: transparent; color: var(--primary); font-weight: 800; }
.code-chip:hover { background: #eaf1f8; text-decoration: none; }
.code-popover { position: absolute; z-index: 20; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); min-width: 220px; max-width: 380px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 10px 30px rgba(15, 39, 64, .16); text-align: left; color: var(--text); white-space: normal; line-height: 1.45; }
.code-popover[hidden] { display: none; }

.content-details summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.content-details div { margin-top: 8px; padding: 10px; border-radius: 8px; background: #f8fbff; border: 1px solid var(--line); }

@media (max-width: 980px) {
  .issue-table { min-width: 1500px; }
}

/* patch 20260605-03: compact inline list controls */
.master-sortable-table th.use-col,
.master-sortable-table td.use-col,
.master-sortable-table th.action-col,
.master-sortable-table td.action-col {
  text-align: center !important;
  vertical-align: middle;
}
.master-sortable-table .use-col { width: 88px; }
.master-sortable-table .action-col { width: 76px; }

.issue-list-card {
  overflow: visible !important;
}
.issue-table {
  width: 100%;
  min-width: 0 !important;
  table-layout: fixed;
  font-size: 12.5px;
}
.issue-table th,
.issue-table td {
  padding: 7px 6px;
  overflow: hidden;
}
.issue-table .doc-col { width: 126px; min-width: 0 !important; }
.issue-table .code-col { width: 56px; min-width: 0 !important; text-align: center !important; }
.issue-table .issue-title-col { width: 16%; min-width: 0 !important; }
.issue-table .issue-content-col { width: 23%; min-width: 0 !important; }
.issue-table .owner-col { width: 72px; min-width: 0 !important; }
.issue-table .date-col { width: 104px; min-width: 0 !important; }
.issue-table .status-col { width: 86px; min-width: 0 !important; text-align: center !important; }
.issue-table .file-col { width: 42px; min-width: 0 !important; text-align: center !important; }
.issue-table .issue-remark-col { width: 10%; min-width: 0 !important; }
.issue-table .doc-col a {
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  line-height: 1.25;
}
.issue-table .owner-col,
.issue-table .file-col {
  vertical-align: middle;
}

.issue-table .inline-field {
  width: 100%;
  min-height: 28px;
  border: 0 !important;
  border-radius: 9px;
  background: transparent;
  box-shadow: none;
  outline: none;
  padding: 4px 6px;
  font-size: 12.5px;
  line-height: 1.35;
}
.issue-table .inline-field:hover {
  background: #f4f8fc;
}
.issue-table .inline-field:focus {
  background: #fff;
  box-shadow: inset 0 0 0 2px rgba(31, 78, 120, .12);
}
.issue-table .inline-title {
  font-weight: 650;
}
.issue-table .inline-date {
  padding: 4px 2px;
  text-align: center;
}
.issue-table .inline-content,
.issue-table .inline-content:focus {
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  resize: none;
  overflow: auto;
}
.issue-table .inline-remark,
.issue-table .inline-remark:focus {
  height: 38px;
  min-height: 38px;
  max-height: 38px;
  resize: none;
  overflow: auto;
}
.issue-table .inline-readonly-text {
  max-height: 48px;
  overflow: hidden;
  line-height: 1.45;
}
.issue-table .inline-save-state {
  display: none;
}
.issue-table .inline-field.saving {
  background: #f7fbff;
}
.issue-table .inline-field.save-error {
  background: #fff3f2;
  box-shadow: inset 0 0 0 2px rgba(180, 35, 24, .16);
}

.issue-table .inline-pill-select {
  width: auto;
  max-width: 100%;
  min-width: 62px;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 22px 4px 10px;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 9px 9px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 20 20'%3E%3Cpath fill='%23566' d='M5.5 7.5 10 12l4.5-4.5z'/%3E%3C/svg%3E");
}
.issue-table .inline-pill-select:focus {
  box-shadow: 0 0 0 3px rgba(31, 78, 120, .10);
}
.issue-table .pill-ok { background-color: #d8f8f2; color: #12696d; }
.issue-table .pill-blue { background-color: #dcecff; color: #23518f; }
.issue-table .pill-pink { background-color: #ffe5f5; color: #8a3f78; }
.issue-table .pill-red { background-color: #ffe2de; color: #9f3730; }
.issue-table .pill-gray { background-color: #e8eff0; color: #40515a; }
.issue-table .pill-green { background-color: #def8df; color: #25693d; }
.issue-table .pill-amber { background-color: #fff1c7; color: #80530c; }

.code-pop { position: static; display: inline-flex; justify-content: center; }
.code-chip {
  min-height: 24px;
  padding: 2px 5px;
  border-radius: 7px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 800;
}
.code-chip:hover,
.code-chip[aria-expanded="true"] {
  background: #eaf1f8;
}
.floating-code-popover {
  position: fixed;
  z-index: 9999;
  min-width: 220px;
  max-width: min(420px, calc(100vw - 24px));
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 14px 34px rgba(15, 39, 64, .20);
  text-align: left;
  color: var(--text);
  white-space: normal;
  line-height: 1.45;
}
.floating-code-popover::before {
  content: "";
  position: absolute;
  left: var(--arrow-left, 50%);
  width: 10px;
  height: 10px;
  background: #fff;
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
  transform: translateX(-50%) rotate(45deg);
}
.floating-code-popover[data-placement="bottom"]::before { top: -6px; }
.floating-code-popover[data-placement="top"]::before {
  bottom: -6px;
  transform: translateX(-50%) rotate(225deg);
}

@media (max-width: 980px) {
  .issue-table {
    min-width: 0 !important;
    font-size: 12px;
  }
  .issue-table th,
  .issue-table td {
    padding: 6px 4px;
  }
  .issue-table .doc-col { width: 112px; }
  .issue-table .code-col { width: 50px; }
  .issue-table .owner-col { width: 58px; }
  .issue-table .date-col { width: 94px; }
  .issue-table .status-col { width: 76px; }
  .issue-table .file-col { width: 34px; }
  .issue-table .issue-title-col { width: 15%; }
  .issue-table .issue-content-col { width: 25%; }
  .issue-table .issue-remark-col { width: 8%; }
  .issue-table .inline-pill-select {
    min-width: 54px;
    padding-left: 7px;
    padding-right: 18px;
    font-size: 11.5px;
  }
}
