/* 통관팀 문의함 (dashboard.hubnet.net) — 청록 + 주황, 둥근 카드 */
:root {
    --brand: #0f766e; --brand-dark: #0b5e58; --title: #0b4f4a; --soft: #e4f3f1; --soft2: #f0f8f6;
    --point: #f97316; --point-ink: #d35f0a; --admin: #5fb3a9;
    --bg: #f3f8f7; --surface: #fff; --ink: #17302c; --body: #3f5652; --muted: #5f716e;
    --line: #e3eeec; --line2: #c9dcd8;
    --red: #c8372d; --red-soft: #fdeeec; --red-line: #f5c4be;
    --green: #1f8a4c; --green-soft: #e9f7ef;
    --blue: #2563a8; --blue-soft: #e6effb; /* '확인' 상태: 청록(대표색)·초록(답변 완료)과 구분 */
    --radius: 14px;
    --shadow: 0 1px 2px rgba(15, 70, 60, .06), 0 6px 20px rgba(15, 70, 60, .07);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif; font-size: 14px; color: var(--ink); background: var(--bg); word-break: keep-all; overflow-wrap: anywhere; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 20px; margin: 0; color: var(--title); }
h2 { font-size: 16px; margin: 0; color: var(--title); }
h3 { font-size: 12px; margin: 0 0 6px; color: var(--body); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.r { text-align: right; }
.ok-text { color: var(--green); }
.err-text { color: var(--red); }

/* 틀 */
.shell { display: flex; min-height: 100vh; }
.side { width: 200px; flex: none; background: var(--surface); border-right: 1px solid var(--line); padding: 20px 10px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; flex-direction: column; gap: 6px; padding: 2px 8px 22px; }
.brand:hover { text-decoration: none; }
.brand img { width: 150px; height: auto; display: block; }
.brand small { font-size: 12px; font-weight: bold; color: var(--muted); }
.side nav { display: flex; flex-direction: column; gap: 4px; }
.side nav a { color: var(--body); padding: 9px 10px; border-radius: 10px; display: flex; justify-content: space-between; align-items: center; }
.side nav a.on, .side nav a:hover { background: var(--soft); color: var(--title); font-weight: bold; text-decoration: none; }
.admin-tag { display: inline-block; font-size: 10.5px; font-weight: bold; color: #fff; background: var(--admin); border-radius: 4px; padding: 1px 6px; margin-left: 4px; vertical-align: middle; }
.admin-tag.big { font-size: 12px; padding: 2px 8px; margin-left: 8px; }
.count { background: var(--point); color: #fff; font-weight: bold; font-size: 12px; border-radius: 10px; padding: 1px 8px; }
.me { margin-top: auto; font-size: 12px; color: var(--muted); padding: 0 8px; display: flex; flex-direction: column; gap: 4px; }
.me .link { color: var(--muted); padding: 0; }
.main { flex: 1; min-width: 0; padding: 24px 28px 40px; }

.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.head .subject { font-size: 18px; flex: 1; min-width: 200px; }
.back { display: inline-block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.search input { width: 260px; max-width: 100%; }
.head-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fetch .btn { white-space: nowrap; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }
.flash.ok { background: var(--green-soft); color: var(--green); }
.flash.err { background: var(--red-soft); color: var(--red); }

/* 입력 · 버튼 */
input, textarea, select { font: inherit; color: var(--ink); border: 1px solid var(--line2); border-radius: 8px; padding: 7px 9px; background: #fff; width: 100%; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--soft); border-color: var(--brand); }
input:disabled { background: var(--soft2); color: var(--body); }
textarea { resize: vertical; line-height: 1.5; }
.btn { display: inline-block; font: inherit; border: 1px solid var(--line2); background: #fff; color: var(--brand); border-radius: 10px; padding: 7px 16px; cursor: pointer; text-align: center; }
.btn:hover { text-decoration: none; background: var(--soft); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: bold; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.small { padding: 3px 12px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .6; cursor: default; }
.btn.danger { color: var(--red); border-color: var(--red-line); }
.btn.danger:hover { background: var(--red-soft); }
.btn.danger.solid { background: var(--red); border-color: var(--red); color: #fff; font-weight: bold; }
.btn.danger.solid:hover { background: #a92c23; }
.danger-zone { display: flex; align-items: center; gap: 10px; border-top: 1px dashed var(--line2); padding-top: 14px; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; }
.link:hover { text-decoration: underline; }
.disabled { color: var(--line2); cursor: not-allowed; }
.badge { display: inline-block; font-size: 12px; font-weight: bold; border-radius: 10px; padding: 2px 10px; white-space: nowrap; }
.badge.unread { background: var(--red-soft); color: var(--red); }
.badge.seen { background: var(--blue-soft); color: var(--blue); }
.badge.answered { background: var(--green-soft); color: var(--green); }
.tag-reply { font-style: normal; font-weight: bold; color: var(--point-ink); margin-right: 6px; }
.tag-web { font-style: normal; font-weight: bold; font-size: 11px; color: var(--brand); background: var(--soft); border-radius: 4px; padding: 1px 6px; margin-right: 6px; }
.facts { display: grid; grid-template-columns: 64px 1fr; gap: 4px 8px; margin: 0; font-size: 12.5px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* 현황 (목록 맨 위) */
.dash { display: grid; gap: 12px; margin-bottom: 16px; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; border-top: 4px solid var(--c); }
.kpi.dashed { border-top-style: dashed; }
.kpi .k { font-size: 12.5px; color: var(--muted); font-weight: bold; }
.kpi .v { font-size: 28px; font-weight: 800; color: var(--c); line-height: 1.25; margin-top: 2px; }
.kpi .v small { font-size: 13px; font-weight: bold; margin-left: 2px; }
.kpi .s { font-size: 11.5px; color: var(--muted); }
.wk { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 16px; }
.wk-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.wk-head h2 { font-size: 13px; }
.wk-tools { display: flex; gap: 10px; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { font: inherit; font-size: 12px; border: 0; background: #fff; color: var(--muted); padding: 3px 11px; cursor: pointer; }
.seg button.on { background: var(--brand); color: #fff; font-weight: bold; }
.fold { font: inherit; font-size: 12px; border: 0; background: none; color: var(--muted); cursor: pointer; padding: 3px 4px; }
.wk.folded .wk-body { display: none; }
.wk-body { margin-top: 6px; }
.wk-bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; padding: 0 4px; }
.wk-bars .bar { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; color: var(--muted); font-size: 11.5px; border-radius: 8px; padding: 2px 0; }
.wk-bars .bar:hover { text-decoration: none; background: var(--soft2); }
.wk-bars .bar em { font-style: normal; font-weight: bold; color: var(--ink); font-size: 12px; margin-bottom: 3px; }
.wk-bars .bar small { font-size: inherit; white-space: nowrap; margin-top: 5px; }
.stk { display: flex; flex-direction: column; width: 56%; max-width: 64px; min-height: 2px; height: var(--h8); border-radius: 6px 6px 2px 2px; overflow: hidden; background: var(--line); }
.stk .n { background: var(--brand); } .stk .r { background: #8fd1c7; }
.wk[data-period="12"] .stk { height: var(--h12); }
.wk[data-period="26"] .stk { height: var(--h26); }
.wk[data-period="8"] .bar.gt8, .wk[data-period="12"] .bar.gt12 { display: none; }
.wk[data-period="26"] .wk-bars { gap: 3px; }
.wk[data-period="26"] .bar { font-size: 9.5px; }
.wk[data-period="26"] .bar em { font-size: 10px; }
.wk-bars .bar.now { color: var(--point-ink); font-weight: bold; }
.wk-bars .bar.now .stk { outline: 2px solid var(--point); outline-offset: 2px; }
.wk-bars .bar.sel { background: var(--soft); color: var(--title); font-weight: bold; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.legend b { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.legend b.n { background: var(--brand); } .legend b.r { background: #8fd1c7; }
.week-chip { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; font-size: 12.5px; color: var(--title); background: var(--soft); border-radius: 999px; padding: 5px 12px; }
.week-chip a { color: var(--muted); font-weight: bold; }

/* 2시간 넘게 미확인: 스크롤해도 위에 고정 */
.stale { position: sticky; top: 0; z-index: 5; background: var(--red-soft); border: 1px solid var(--red-line); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 14px; box-shadow: var(--shadow); max-height: 40vh; overflow-y: auto; }
.stale-head { color: var(--red); margin-bottom: 6px; }
.stale-row { display: grid; grid-template-columns: 80px minmax(80px, 160px) minmax(0, 1fr) auto; gap: 10px; align-items: center; background: #fff; border-radius: 10px; padding: 6px 10px; margin-top: 4px; color: var(--ink); font-size: 13px; }
.stale-row:hover { text-decoration: none; background: #fffafa; }
.stale-row .who, .stale-row .subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stale-row .age { color: var(--red); font-weight: bold; white-space: nowrap; }

/* 탭 · 목록 */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs a { background: #fff; border: 1px solid var(--line); color: var(--muted); padding: 6px 14px; border-radius: 999px; font-size: 13px; }
.tabs a.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: bold; }
.tabs a:hover { text-decoration: none; }
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
table.list { width: 100%; border-collapse: collapse; }
.list th { background: var(--soft2); color: var(--muted); font-weight: bold; text-align: left; font-size: 12px; }
.list th, .list td { border-bottom: 1px solid var(--line); padding: 11px 12px; }
.list tbody tr:last-child td { border-bottom: 0; }
.list tbody tr { cursor: pointer; }
.list.plain tbody tr { cursor: default; }
.list tbody tr:hover { background: var(--soft2); }
.list tr.unread td { font-weight: bold; }
.list tr.unread td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.list td a { color: var(--ink); }
.c-status { width: 92px; } .c-time { width: 92px; white-space: nowrap; } .c-from { width: 170px; } .c-who { width: 80px; } .c-n { width: 50px; text-align: center; }
.list .empty { text-align: center; color: var(--muted); padding: 40px; cursor: default; }
.foot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-size: 12px; gap: 12px; flex-wrap: wrap; }
.pager { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.pager a, .pager .off { padding: 2px 8px; }
.pager .off { color: var(--line2); }

/* 상세 */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.thread { display: flex; flex-direction: column; gap: 12px; }
/* 받은 메일 = 흰 카드 + 청록 띠, 우리 답변 = 주황빛 카드 + 주황 띠(오른쪽으로 들여씀), 자동 응답 = 회색 */
.msg { border-radius: var(--radius); padding: 14px 16px 14px 18px; background: var(--surface); box-shadow: var(--shadow); border-left: 5px solid var(--brand); margin-right: 48px; }
.msg.out { background: #fff4ea; border-left-color: var(--point); margin: 0 0 0 48px; box-shadow: 0 1px 2px rgba(150, 70, 10, .06), 0 6px 20px rgba(150, 70, 10, .08); }
.msg.auto { opacity: .75; border-left-color: #b8c4c2; background: #f7f9f9; }
.msg header strong { color: var(--title); }
.msg.out header strong { color: #9a3f06; }
.msg header { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; font-size: 13px; }
.msg-subject { font-size: 12px; color: var(--muted); margin: -4px 0 8px; }
.msg .body { white-space: pre-wrap; line-height: 1.6; }
.html-body { width: 100%; height: 420px; border: 1px solid var(--line); border-radius: 8px; background: #fff; resize: vertical; }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.file { background: var(--soft2); border: 1px solid var(--line); color: var(--brand); font-size: 12px; padding: 4px 12px; border-radius: 999px; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; position: sticky; top: 12px; }
.panel .row { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline.spread { justify-content: space-between; }
.history, .others { list-style: none; margin: 0; padding: 0; font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; }
.history .muted { display: inline-block; min-width: 72px; }

/* 창 */
.dlg { border: 0; border-radius: 16px; padding: 20px 22px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(15, 50, 45, .25); color: var(--ink); }
.dlg.wide { width: min(760px, calc(100vw - 32px)); }
.dlg::backdrop { background: rgba(11, 45, 42, .5); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.dlg .x { background: none; border: 0; font-size: 16px; color: var(--muted); cursor: pointer; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.f { display: grid; grid-template-columns: 90px 1fr; align-items: center; gap: 10px; margin-bottom: 8px; }
.f.top { align-items: start; }
.f > span { font-weight: bold; color: var(--body); font-size: 13px; }
.check { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.check input { width: auto; accent-color: var(--brand); }
.choices { border: 0; padding: 0; margin: 0 0 10px; display: flex; flex-direction: column; gap: 6px; }
.choices legend { font-weight: bold; color: var(--body); font-size: 13px; margin-bottom: 6px; }
.choices label { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line2); border-radius: 10px; padding: 7px 10px; cursor: pointer; }
.choices input { width: auto; accent-color: var(--brand); }
.choices label:has(input:checked) { background: var(--soft); border-color: var(--brand); }

/* 접속 */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--bg); padding: 16px; }
.login-card { background: var(--surface); border-radius: 16px; box-shadow: var(--shadow); padding: 32px 28px; width: min(400px, 100%); }
.login-logo { display: block; width: 190px; height: auto; margin: 0 auto 6px; }
.login-card h1 { text-align: center; margin-bottom: 12px; font-size: 16px; color: var(--muted); }
.login-card label { display: block; font-weight: bold; color: var(--body); margin: 18px 0 6px; font-size: 13px; }
.login-card .btn { margin-top: 12px; }
.login-card .sent { background: var(--soft2); border-radius: 10px; padding: 14px; margin: 12px 0; line-height: 1.6; }
.field-err { color: var(--red); font-size: 12px; margin: 6px 0 0; }

/* 휴대폰 */
@media (max-width: 800px) {
    .shell { flex-direction: column; }
    .side { width: auto; height: auto; position: static; flex-direction: row; align-items: center; padding: 10px 16px; gap: 12px; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
    .brand { padding: 0; }
    .brand img { width: 104px; }
    .brand small { display: none; }
    .side nav { flex-direction: row; }
    .me { margin: 0 0 0 auto; flex-direction: row; gap: 10px; }
    .main { padding: 14px 16px 32px; }
    .detail { grid-template-columns: 1fr; }
    .panel { position: static; }
    .msg, .msg.out { margin-left: 0; margin-right: 0; }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .kpi .v { font-size: 22px; }
    .wk[data-period] .bar.gt8 { display: none; }
    .wk-bars { gap: 4px; }
    .wk-bars .bar { font-size: 10px; }
    .week-chip { margin-left: 0; }
    .stale-row { grid-template-columns: minmax(0, 1fr) auto; }
    .c-from { width: auto; }
    .list th, .list td { padding: 9px 6px; }
    .stale-row .t, .stale-row .who { display: none; }
    .c-time, .c-who, .c-n { display: none; }
    .f { grid-template-columns: 1fr; gap: 4px; }
    .head-tools { width: 100%; flex-wrap: nowrap; }
    .search { flex: 1; }
    .search input { width: 100%; }
}
