/*
 * AI Dev Dashboard 화면 스타일.
 * 가독성을 우선한다: 본문 폭을 제한하고, 상태·종류는 색 배지와 글자를 함께 써서 색만으로 구분하지 않는다.
 * 색과 간격은 :root 변수로 모아 두어 한 곳에서 바꿀 수 있다.
 */
:root {
  --bg: #f4f6f9; --panel: #ffffff; --line: #d9dee7; --text: #1c2430; --muted: #5d6878;
  --accent: #2456c9; --accent-soft: #e6edfb; --danger: #b3261e; --ok: #1d7a46; --warn: #9a6200;
  --radius: 8px; --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
/* display를 지정한 요소도 hidden 속성으로 확실히 숨긴다. */
[hidden] { display: none !important; }
html { font-size: 15px; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; line-height: 1.55; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .6rem; }
h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
.loading, .empty { color: var(--muted); padding: 1.5rem; text-align: center; }
.muted { color: var(--muted); font-size: .88rem; }
.mono { font-family: var(--mono); font-size: .9rem; }

/* 상단 바와 본문 틀 */
.topbar { display: flex; align-items: center; gap: 1rem; padding: .6rem 1.25rem; background: #172033; color: #fff; flex-wrap: wrap; }
.topbar a { color: #dbe5ff; }
.topbar .brand { font-weight: 700; font-size: 1.05rem; color: #fff; }
.topbar .spacer { flex: 1; }
.topbar .who { color: #aab6d3; font-size: .88rem; }
main { max-width: 1180px; margin: 0 auto; padding: 1.25rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.15rem; margin-bottom: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card { display: block; color: inherit; }
.card:hover { border-color: var(--accent); text-decoration: none; }

/* 탭 */
.tabs { display: flex; gap: .15rem; border-bottom: 1px solid var(--line); margin: .9rem 0 1rem; flex-wrap: wrap; }
.tabs a { padding: .5rem .85rem; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* 입력 요소 */
button, .button { font: inherit; padding: .42rem .85rem; border-radius: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; }
button:hover, .button:hover { border-color: var(--accent); text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); }
button.small { padding: .2rem .55rem; font-size: .85rem; }
button:disabled { opacity: .55; cursor: default; }
input[type=text], input[type=password], input[type=search], input:not([type]), select, textarea {
  font: inherit; width: 100%; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text);
}
textarea { min-height: 5rem; resize: vertical; }
textarea.mono, input.mono { font-family: var(--mono); }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.field { display: block; margin-bottom: .75rem; }
.field > span { display: block; font-size: .88rem; font-weight: 600; margin-bottom: .2rem; }
.field > small { display: block; color: var(--muted); margin-top: .15rem; }
label.check { display: inline-flex; gap: .4rem; align-items: center; margin-right: 1rem; }
.cols { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.inline-select { width: auto; }

/* 표 */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .82rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--accent-soft); }
.table-wrap { overflow-x: auto; }

/* 배지: 상태·종류·작성자 구분 */
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #e9edf3; color: #3d4756; white-space: nowrap; }
.badge.open { background: #e6edfb; color: #1f4bb0; }
.badge.in_progress { background: #fff1d6; color: var(--warn); }
.badge.review { background: #f1e6fb; color: #6a2fa8; }
.badge.done { background: #dff3e7; color: var(--ok); }
.badge.hold, .badge.closed { background: #e9edf3; color: #5d6878; }
.badge.result { background: #dff3e7; color: var(--ok); }
.badge.change { background: #fff1d6; color: var(--warn); }
.badge.agent { background: #172033; color: #fff; }
.badge.high { background: #fbe4e2; color: var(--danger); }
.badge.version { font-family: var(--mono); background: #eef0f4; }

/* 마크다운 보기: 렌더링/원문 전환 */
.md { border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.md.plain { border: 0; }
.md-bar { display: flex; justify-content: flex-end; gap: .3rem; padding: .25rem .4rem; border-bottom: 1px solid var(--line); background: #fafbfc; border-radius: 6px 6px 0 0; }
.md.plain .md-bar { border: 0; background: none; padding: 0 0 .2rem; }
.md-body { padding: .6rem .9rem; overflow-x: auto; }
.md.plain .md-body { padding: 0; }
.md-raw { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: var(--mono); font-size: .9rem; }
.toastui-editor-contents { font-size: 1rem; font-family: inherit; }
.editor-box { margin-bottom: .75rem; }

/* 지시 본문과 이어지는 글 */
.post { border-left: 4px solid var(--line); }
.post.result { border-left-color: var(--ok); }
.post.change { border-left-color: var(--warn); }
.post-head { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.kv { display: grid; grid-template-columns: 9rem 1fr; gap: .3rem .8rem; margin: 0 0 .8rem; }
.kv dt { color: var(--muted); font-size: .88rem; }
.kv dd { margin: 0; word-break: break-word; }
.secret-value { font-family: var(--mono); white-space: pre-wrap; word-break: break-all; background: #fff8e1; border: 1px solid #f0d98a; border-radius: 6px; padding: .5rem .6rem; margin: .4rem 0; }
.masked { -webkit-text-security: disc; }
pre.code { background: #172033; color: #e8eefc; padding: .7rem .9rem; border-radius: 6px; overflow-x: auto; font-family: var(--mono); font-size: .88rem; white-space: pre-wrap; word-break: break-all; }

/* 로그인 화면 */
.login { max-width: 380px; margin: 12vh auto 0; }
.login h1 { text-align: center; margin-bottom: 1rem; }
.error { color: var(--danger); margin: .4rem 0; }
.notice { background: #fff8e1; border: 1px solid #f0d98a; border-radius: 6px; padding: .6rem .8rem; margin-bottom: .8rem; }

/* 모달과 알림 */
.modal-back { position: fixed; inset: 0; background: rgba(15, 23, 42, .5); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 1rem; overflow-y: auto; z-index: 50; }
.modal { background: #fff; border-radius: var(--radius); padding: 1.1rem 1.25rem; width: min(820px, 100%); }
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .4rem; z-index: 60; }
.toast { background: #172033; color: #fff; padding: .55rem .9rem; border-radius: 6px; max-width: 360px; box-shadow: 0 4px 14px rgba(0, 0, 0, .2); }
.toast.bad { background: var(--danger); }

@media (max-width: 640px) {
  main { padding: .75rem; }
  .kv { grid-template-columns: 1fr; }
  th.wide, td.wide { display: none; }
}
