/* ==========================================================================
   app.css — 사이트 전체 스타일 (빌드 도구·프레임워크 없음)
   순서: 1. 변수  2. 기본  3. 레이아웃  4. 컴포넌트  5. 유틸
   ========================================================================== */


/* ==========================================================================
   1. 변수
   ========================================================================== */
:root {
    /* 상태 색상 (설계서) */
    --c-done:  #22C55E;   /* 완료 */
    --c-info:  #3B82F6;   /* 정보 / 수동 */
    --c-miss:  #EF4444;   /* 결측 / 누락 */
    --c-delay: #F59E0B;   /* 지연 / 업로드 대기 */
    --c-empty: #EAB308;   /* 미입력 */
    --c-wait:  #9CA3AF;   /* 대기 */
    --c-emph:  #1E293B;   /* 강조 배경 */

    /* 상태별 연한 배경 / 진한 글자 (뱃지·알림·행 배경) */
    --c-done-bg:  #DCFCE7;  --c-done-fg:  #15803D;  --c-done-row:  #ECFDF5;  /* Emerald-50 */
    --c-info-bg:  #DBEAFE;  --c-info-fg:  #1D4ED8;  --c-info-row:  #EFF6FF;
    --c-miss-bg:  #FEE2E2;  --c-miss-fg:  #B91C1C;  --c-miss-row:  #FEF2F2;
    --c-delay-bg: #FEF3C7;  --c-delay-fg: #B45309;  --c-delay-row: #FFFBEB;
    --c-empty-bg: #FEF9C3;  --c-empty-fg: #A16207;
    --c-wait-bg:  #F3F4F6;  --c-wait-fg:  #6B7280;

    /* 기본 색 */
    --c-primary:       #059669;   /* 주 버튼 (흰 글자 대비를 위해 완료색보다 진한 녹색) */
    --c-primary-hover: #047857;
    --c-primary-soft:  #ECFDF5;
    --c-danger:        #DC2626;
    --c-danger-hover:  #B91C1C;
    --c-text:    #0F172A;
    --c-text-2:  #334155;
    --c-muted:   #64748B;
    --c-border:  #E2E8F0;
    --c-border-strong: #CBD5E1;
    --c-bg:      #F1F5F9;
    --c-surface: #FFFFFF;
    --c-surface-2: #F8FAFC;
    --c-topbar:  #0F172A;
    --c-focus:   #3B82F6;

    /* 간격 */
    --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px;  --sp-4: 16px;
    --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;  --sp-10: 40px;

    /* 반경 · 그림자 */
    --r-sm: 6px;  --r: 8px;  --r-lg: 12px;  --r-full: 999px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow:    0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);

    /* 글자 */
    --font: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", "Noto Sans KR", sans-serif;
    --fs-xs: 12px; --fs-sm: 13px; --fs: 14px; --fs-md: 15px; --fs-lg: 18px; --fs-xl: 22px; --fs-2xl: 28px;

    /* 레이아웃 */
    --topbar-h: 60px;
    --lnb-w: 260px;
}


/* ==========================================================================
   2. 기본
   ========================================================================== */
/* Pretendard (public/fonts/pretendard, SIL OFL 1.1 — LICENSE.txt)
   한글 2,350자 + 영문 subset. 없는 글자·로딩 실패는 --font 의 시스템 한글 폰트로 대체 */
@font-face { font-family: "Pretendard"; font-weight: 400; font-style: normal; font-display: swap; src: url("../fonts/pretendard/Pretendard-Regular.subset.woff2") format("woff2"); }
@font-face { font-family: "Pretendard"; font-weight: 500; font-style: normal; font-display: swap; src: url("../fonts/pretendard/Pretendard-Medium.subset.woff2") format("woff2"); }
@font-face { font-family: "Pretendard"; font-weight: 600; font-style: normal; font-display: swap; src: url("../fonts/pretendard/Pretendard-SemiBold.subset.woff2") format("woff2"); }
@font-face { font-family: "Pretendard"; font-weight: 700; font-style: normal; font-display: swap; src: url("../fonts/pretendard/Pretendard-Bold.subset.woff2") format("woff2"); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: var(--fs); line-height: 1.5; color: var(--c-text); background: var(--c-bg); }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
p { margin: 0; }
a { color: var(--c-info-fg); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }
.icon { width: 1.15em; height: 1.15em; flex-shrink: 0; vertical-align: -0.2em; }


/* ==========================================================================
   3. 레이아웃 — 상단 바 / 좌측 메뉴(LNB) / 본문 / 로그인 화면
   ========================================================================== */
/* --- 상단 바 --- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: var(--sp-4);
    height: var(--topbar-h); padding: 0 var(--sp-6);
    color: #fff; background: var(--c-topbar);
}
.topbar-menu-btn { display: none; color: #fff; font-size: 22px; line-height: 0; padding: var(--sp-1); border-radius: var(--r-sm); }
.topbar-brand { display: inline-flex; align-items: center; gap: var(--sp-2); color: #fff; font-size: var(--fs-lg); font-weight: 700; text-decoration: none; white-space: nowrap; }
.topbar-logo { width: 26px; height: 26px; color: var(--c-done); }
.topbar-project.is-empty { color: #CBD5E1; background: rgba(148, 163, 184, .14); border-color: rgba(148, 163, 184, .35); }
.topbar-project { padding: 3px 10px; font-size: var(--fs-sm); font-weight: 600; color: #D1FAE5; background: rgba(34, 197, 94, .16); border: 1px solid rgba(34, 197, 94, .35); border-radius: var(--r-full); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32ch; }
.topbar-right { display: flex; align-items: center; gap: var(--sp-3); margin-left: auto; }
.topbar-time { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: #CBD5E1; white-space: nowrap; }
.topbar-user { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: var(--fs-sm); background: var(--c-emph); border-radius: var(--r); white-space: nowrap; }
.topbar-user-role { color: #94A3B8; }
.topbar-user-role::before { content: "·"; margin-right: 6px; }
.topbar-logout { margin: 0; }
.topbar-logout button { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; font-size: var(--fs-sm); color: #CBD5E1; background: transparent; border: 1px solid #334155; border-radius: var(--r); }
.topbar-logout button:hover { color: #fff; border-color: #64748B; }

/* --- 본문 틀 --- */
.shell { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.content { flex: 1; min-width: 0; padding: var(--sp-6) var(--sp-6) var(--sp-10); }

/* --- 좌측 메뉴 --- */
.lnb {
    position: sticky; top: var(--topbar-h); align-self: flex-start;
    display: flex; flex-direction: column;
    width: var(--lnb-w); flex-shrink: 0; height: calc(100vh - var(--topbar-h)); overflow-y: auto;
    padding: var(--sp-5) var(--sp-4); background: var(--c-surface); border-right: 1px solid var(--c-border);
}
.lnb-head { display: flex; align-items: center; justify-content: space-between; padding: 0 var(--sp-2) var(--sp-3); }
.lnb-label { font-size: var(--fs-sm); font-weight: 700; letter-spacing: .08em; color: #94A3B8; }
.lnb-close { display: none; color: var(--c-muted); font-size: 20px; line-height: 0; }
.menu, .submenu { list-style: none; margin: 0; padding: 0; }
.menu > li + li { margin-top: 2px; }
.menu-link {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 10px; font-size: var(--fs-md); font-weight: 500; color: var(--c-text-2);
    text-decoration: none; border-radius: var(--r); cursor: pointer; list-style: none;
}
.menu-link::-webkit-details-marker { display: none; }
.menu-link .icon { width: 20px; height: 20px; color: var(--c-muted); }
.menu-link:hover { background: var(--c-surface-2); }
.menu-link.is-active { color: var(--c-primary); font-weight: 700; background: var(--c-primary-soft); }
.menu-link.is-active .icon, .menu-link.is-active-parent .icon { color: var(--c-primary); }
.menu-link.is-active-parent { color: var(--c-primary); font-weight: 700; }
.menu-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-chevron { width: 16px !important; height: 16px !important; transition: transform .15s; }
.menu-group[open] > .menu-link .menu-chevron { transform: rotate(180deg); }
.submenu { margin: 2px 0 var(--sp-2) 26px; padding-left: var(--sp-3); border-left: 2px solid var(--c-border); }
.submenu-link { display: block; padding: 8px var(--sp-3); font-size: var(--fs); color: var(--c-muted); text-decoration: none; border-radius: var(--r-sm); }
.submenu-link:hover { color: var(--c-text); background: var(--c-surface-2); }
.submenu-link.is-active { color: var(--c-info-fg); font-weight: 700; background: var(--c-info-row); }
.is-disabled, .is-disabled:hover { color: #A8B1BD; background: transparent; cursor: default; }
.is-disabled .icon { color: #C4CBD4; }
.menu-soon { margin-left: auto; padding: 1px 5px; font-size: 10px; font-weight: 600; color: var(--c-wait-fg); background: var(--c-wait-bg); border-radius: var(--r-full); white-space: nowrap; }
.submenu-link .menu-soon { margin-left: 4px; }
.lnb-help { margin-top: auto; padding: var(--sp-4); font-size: var(--fs-sm); color: var(--c-muted); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.lnb-help strong { display: block; margin-bottom: 4px; font-size: var(--fs); color: var(--c-text); }
.lnb-backdrop { display: none; }

/* --- 로그인 등 (비로그인 화면) --- */
body.auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: var(--sp-6) var(--sp-4); background: var(--c-bg); }

/* --- 반응형: 1024px 미만은 좌측 메뉴를 버튼으로 여닫기 --- */
@media (max-width: 1023.98px) {
    .topbar { gap: var(--sp-3); padding: 0 var(--sp-4); }
    .topbar-menu-btn { display: inline-flex; }
    .topbar-time { display: none; }
    .lnb {
        position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; height: 100vh;
        transform: translateX(-100%); transition: transform .2s ease, box-shadow .2s ease;
    }
    .lnb-close { display: inline-flex; }
    body.lnb-open .lnb, .lnb:target { transform: none; box-shadow: 0 10px 30px rgba(15, 23, 42, .25); }
    body.lnb-open .lnb-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(15, 23, 42, .45); }
    .content { padding: var(--sp-5) var(--sp-4) var(--sp-8); }
}
@media (max-width: 639.98px) {
    .topbar-brand { font-size: var(--fs-md); }
    .topbar-brand span, .topbar-user-name, .topbar-user-role, .topbar-logout span { display: none; }
    .topbar-project { max-width: 18ch; }
    .topbar-user { padding: 6px 8px; }
}


/* ==========================================================================
   4. 컴포넌트
   ========================================================================== */
/* 색 조합(tone) — 뱃지·알림·KPI 아이콘·진행 막대·범례가 공통으로 쓴다
   <span class="badge done">  <div class="alert warn">  <div class="kpi-icon info"> */
.done  { --tone: var(--c-done);  --tone-bg: var(--c-done-bg);  --tone-fg: var(--c-done-fg); }
.info  { --tone: var(--c-info);  --tone-bg: var(--c-info-bg);  --tone-fg: var(--c-info-fg); }
.miss  { --tone: var(--c-miss);  --tone-bg: var(--c-miss-bg);  --tone-fg: var(--c-miss-fg); }
.delay { --tone: var(--c-delay); --tone-bg: var(--c-delay-bg); --tone-fg: var(--c-delay-fg); }
.empty { --tone: var(--c-empty); --tone-bg: var(--c-empty-bg); --tone-fg: var(--c-empty-fg); }
.wait  { --tone: var(--c-wait);  --tone-bg: var(--c-wait-bg);  --tone-fg: var(--c-wait-fg); }
.dark  { --tone: var(--c-emph);  --tone-bg: var(--c-emph);     --tone-fg: #FFFFFF; }

/* --- 페이지 헤더: 경로형 제목 + 설명 + 오른쪽 버튼 --- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--sp-3) var(--sp-4); margin-bottom: var(--sp-5); }
.page-title { font-size: var(--fs-xl); font-weight: 700; color: var(--c-text); }
.page-title .sep { margin: 0 4px; color: var(--c-muted); font-weight: 600; }
.page-desc { margin-top: 4px; font-size: var(--fs); color: var(--c-muted); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.back-link { display: inline-flex; align-items: center; gap: 4px; margin-bottom: var(--sp-2); font-size: var(--fs-sm); color: var(--c-muted); text-decoration: none; }
.back-link:hover { color: var(--c-text); }

/* --- 카드 --- */
.card { background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: var(--sp-4); }
.grid > * { margin-top: 0 !important; }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-3); padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--c-border); }
.card-title { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-md); font-weight: 700; }
.card-title .icon { color: var(--c-primary); }
.card-meta { font-size: var(--fs-sm); font-weight: 600; color: var(--c-muted); }
.card-body { padding: var(--sp-5); }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2) var(--sp-4); padding: var(--sp-3) var(--sp-5); font-size: var(--fs-sm); color: var(--c-muted); background: var(--c-surface-2); border-top: 1px solid var(--c-border); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.card > .table-wrap { border: 0; border-radius: var(--r-lg); box-shadow: none; }
.card > .card-head + .table-wrap, .card > .filter-bar + .table-wrap { border-radius: 0; }
.card > .table-wrap:has(+ .card-foot) { border-radius: var(--r-lg) var(--r-lg) 0 0; }

/* --- 그리드 --- */
.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1279.98px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767.98px)  { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } }

/* --- KPI 카드: 라벨 · 큰 숫자 · 단위 · 색 아이콘 타일 --- */
.kpi { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.kpi-label { font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-2); }
.kpi-value { margin-top: 2px; font-size: var(--fs-2xl); font-weight: 700; line-height: 1.2; color: var(--c-text); font-variant-numeric: tabular-nums; }
.kpi-value.done, .kpi-value.info, .kpi-value.miss, .kpi-value.delay, .kpi-value.violet { color: var(--tone-fg); }
.kpi-value.long { font-size: var(--fs-xl); white-space: nowrap; }   /* 자릿수가 긴 값 (단위가 다음 줄로 넘어가지 않게) */
.kpi-unit { margin-left: 2px; font-size: var(--fs); font-weight: 500; color: var(--c-muted); }
.kpi-sub { margin-top: 2px; font-size: var(--fs-xs); color: var(--c-muted); }
.kpi-icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; flex-shrink: 0; font-size: 22px; color: var(--tone, var(--c-primary)); background: var(--tone-bg, var(--c-primary-soft)); border-radius: var(--r-lg); }

/* --- 버튼: 기본 / 주(primary) / 위험(danger) / 외곽선(outline) / 강조(dark), 크기 2종(기본, sm) --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 40px; padding: 8px 16px; font-size: var(--fs); font-weight: 600; line-height: 1.2; white-space: nowrap;
    color: var(--c-text-2); background: var(--c-surface-2); border: 1px solid var(--c-border); border-radius: var(--r);
    text-decoration: none; cursor: pointer; transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { background: #EEF2F6; }
.btn.primary { color: #fff; background: var(--c-primary); border-color: var(--c-primary); }
.btn.primary:hover { background: var(--c-primary-hover); border-color: var(--c-primary-hover); }
.btn.danger { color: #fff; background: var(--c-danger); border-color: var(--c-danger); }
.btn.danger:hover { background: var(--c-danger-hover); border-color: var(--c-danger-hover); }
.btn.outline { color: var(--c-text-2); background: var(--c-surface); border-color: var(--c-border-strong); }
.btn.outline:hover { background: var(--c-surface-2); }
.btn.outline.danger { color: var(--c-danger); background: var(--c-surface); border-color: #FCA5A5; }
.btn.outline.danger:hover { background: var(--c-miss-row); }
.btn.dark { color: #fff; background: var(--c-emph); border-color: var(--c-emph); }
.btn.dark:hover { background: #0F172A; }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn:disabled, .btn.is-disabled { opacity: .5; cursor: not-allowed; }
.inline-form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0; }
.inline-form .select, .inline-form .input { width: auto; }

/* --- 폼 --- */
.form { display: grid; gap: var(--sp-4); max-width: 520px; }
.form-wide { max-width: none; }
.field { display: grid; gap: 6px; align-content: start; }
.label { font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-2); }
.label .req { color: var(--c-miss); margin-left: 2px; }
.input, .select, .textarea {
    width: 100%; min-height: 40px; padding: 8px 12px; font-size: var(--fs-md); color: var(--c-text);
    background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--r);
}
.textarea { min-height: 96px; resize: vertical; }
.select { padding-right: 32px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--c-muted) 50%), linear-gradient(135deg, var(--c-muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--c-info); box-shadow: 0 0 0 3px rgba(59, 130, 246, .18); }
.input.sm, .select.sm { min-height: 32px; padding-top: 4px; padding-bottom: 4px; font-size: var(--fs-sm); }
.is-invalid { border-color: var(--c-miss) !important; color: var(--c-miss-fg); }
.check { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--c-info); }
.help { font-size: var(--fs-sm); color: var(--c-muted); }
.field-error { font-size: var(--fs-sm); font-weight: 600; color: var(--c-miss-fg); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); padding-top: var(--sp-2); }

/* --- 필터 바 --- */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3) var(--sp-5); padding: var(--sp-3) var(--sp-5); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.card > .filter-bar { border: 0; border-bottom: 1px solid var(--c-border); border-radius: var(--r-lg) var(--r-lg) 0 0; box-shadow: none; }
.filter-bar + .card, .filter-bar + .table-wrap { margin-top: var(--sp-3); }
.card > .filter-bar + .table-wrap, .card > .filter-bar + .empty-state { margin-top: 0; }
.filter-item { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-2); }
.filter-item .select, .filter-item .input { width: auto; min-width: 160px; }
.filter-stats { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); margin-left: auto; font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-2); }
.filter-stats b { font-weight: 700; color: var(--c-text); }
.filter-stats .done { color: var(--c-done-fg); } .filter-stats .delay { color: var(--c-delay-fg); } .filter-stats .miss { color: var(--c-miss-fg); } .filter-stats .info { color: var(--c-info-fg); }

/* --- 표 --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs); }
.table th, .table td { padding: 11px 14px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--c-border); }
.table th { font-size: var(--fs-sm); font-weight: 700; color: var(--c-text-2); white-space: nowrap; background: var(--c-surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background-color: rgba(241, 245, 249, .6); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .center { text-align: center; }
.table .strong { font-weight: 700; }
.table .actions { text-align: right; white-space: nowrap; }
.table th .sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; text-decoration: none; }
.table th .sort .icon { width: 14px; height: 14px; color: var(--c-wait); }
.table th[aria-sort] .sort .icon { color: var(--c-info); }
.table tr.row-done td  { background: var(--c-done-row); }
.table tr.row-delay td { background: var(--c-delay-row); }
.table tr.row-miss td  { background: var(--c-miss-row); }
.table tr.row-info td  { background: var(--c-info-row); }
.table tr.row-off td   { color: #A8B1BD; }
.table tr.row-current td { background: var(--c-info-row); }
@media (max-width: 1023.98px) { .table th, .table td { white-space: nowrap; } }   /* 좁은 화면: 줄바꿈 대신 표 안에서 가로 스크롤 */

/* --- 뱃지 --- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; font-size: var(--fs-xs); font-weight: 700; line-height: 1.5; white-space: nowrap; color: var(--tone-fg, var(--c-text-2)); background: var(--tone-bg, var(--c-wait-bg)); border-radius: var(--r-sm); }
.badge .icon { width: 13px; height: 13px; }
.badge.pill { border-radius: var(--r-full); }
.badge.line { background: var(--c-surface); border: 1px solid var(--tone, var(--c-border-strong)); }

/* --- 진행 막대: 단일 / 이중(수집·제출) --- */
.progress { height: 8px; overflow: hidden; background: #E9EEF4; border-radius: var(--r-full); }
.progress-bar { height: 100%; background: var(--tone, var(--c-primary)); border-radius: inherit; }
.progress-dual { display: grid; gap: 4px; }
.progress-dual .progress { height: 6px; }
.progress-head { display: flex; justify-content: space-between; gap: var(--sp-3); margin-bottom: 6px; font-size: var(--fs-sm); font-weight: 600; }
.progress-head .tone-text { color: var(--tone-fg); }

/* --- 알림 박스: 정보 / 경고 / 오류 / 성공 --- */
.alert { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); font-size: var(--fs); color: var(--tone-fg, var(--c-text-2)); background: var(--tone-bg, var(--c-surface-2)); border: 1px solid color-mix(in srgb, var(--tone, var(--c-border)) 35%, transparent); border-radius: var(--r); }
.alert > .icon { margin-top: 2px; }
.alert-title { display: block; font-weight: 700; }
.alert p + p { margin-top: 4px; }
.alert a { color: inherit; font-weight: 700; }
.alert + .card, .alert + .table-wrap, .alert + .alert, .alert + .grid, .alert + .form { margin-top: var(--sp-4); }
.alert.warn { --tone: var(--c-delay); --tone-bg: var(--c-delay-row); --tone-fg: var(--c-delay-fg); }
.alert.error { --tone: var(--c-miss); --tone-bg: var(--c-miss-row); --tone-fg: var(--c-miss-fg); }
.alert.success { --tone: var(--c-done); --tone-bg: var(--c-done-row); --tone-fg: var(--c-done-fg); }
.alert.info { --tone-bg: var(--c-info-row); }
.alert ul { margin: 0; padding-left: 18px; }

/* --- 범례 --- */
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4); font-size: var(--fs-sm); color: var(--c-muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--tone-fg, var(--c-text-2)); }
.legend-item::before { content: ""; width: 9px; height: 9px; background: var(--tone, var(--c-wait)); border-radius: 50%; }

/* --- 페이지네이션 --- */
.pagination { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.pagination a, .pagination span { display: inline-flex; align-items: center; justify-content: center; min-width: 30px; height: 30px; padding: 0 8px; font-size: var(--fs-sm); font-weight: 600; color: var(--c-text-2); text-decoration: none; background: var(--c-surface); border: 1px solid var(--c-border-strong); border-radius: var(--r-sm); }
.pagination a:hover { background: var(--c-surface-2); }
.pagination .is-current { color: var(--c-primary); border-color: var(--c-primary); }
.pagination .is-gap { border-color: transparent; background: transparent; }

/* --- 빈 상태 --- */
.empty-state { display: grid; justify-items: center; gap: var(--sp-2); padding: var(--sp-10) var(--sp-5); text-align: center; color: var(--c-muted); }
.empty-state > .icon { width: 40px; height: 40px; color: var(--c-wait); }
.empty-state strong { font-size: var(--fs-md); color: var(--c-text-2); }
.empty-state .btn { margin-top: var(--sp-2); }

/* --- 정보 목록 (용어 : 설명) --- */
.dl { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: var(--sp-2) var(--sp-4); margin: 0; font-size: var(--fs); }
.dl dt { font-weight: 600; color: var(--c-muted); }
.dl dd { margin: 0; color: var(--c-text-2); }
@media (max-width: 639.98px) { .dl { grid-template-columns: minmax(0, 1fr); gap: 2px; } .dl dd { margin-bottom: var(--sp-2); } }

/* --- 고정 헤더 스크롤 표 (농가 배정 등 긴 목록) --- */
.table-scroll { max-height: max(360px, calc(100vh - 380px)); overflow: auto; }
.table-scroll .table th { position: sticky; top: 0; z-index: 2; box-shadow: inset 0 -1px 0 var(--c-border); }
.card > .filter-bar + .filter-bar { border-radius: 0; }
.assign-bulk { background: var(--c-info-row); }
.assign-table .farm-name { min-width: 120px; white-space: nowrap; }
.assign-table .farm-name .field-error { max-width: 320px; white-space: normal; font-weight: 600; }
.assign-table .select.sm { min-width: 128px; max-width: 170px; }
.assign-table td.muted { min-width: 140px; max-width: 200px; white-space: normal; }
.assign-table th, .assign-table td { padding-left: 10px; padding-right: 10px; }
.table .target-check { width: 18px; height: 18px; accent-color: var(--c-info); }
.table tr.is-changed td:first-child { box-shadow: inset 3px 0 0 var(--c-info); }
.table tr.row-error td { background: var(--c-miss-bg); }

/* --- 작업자 현황 보고 표 --- */
.report-table .date-input { width: 140px; }
.report-table .receipt-input { width: 120px; }
.report-table .evidence { min-width: 200px; }
.evidence-file { display: flex; align-items: center; gap: 4px; margin-bottom: 4px; font-size: var(--fs-sm); }
.evidence-file a { display: inline-flex; align-items: center; gap: 4px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--c-info-fg); text-decoration: none; }
.evidence-del { display: inline-flex; padding: 2px; color: var(--c-miss-fg); background: transparent; border: 0; border-radius: var(--r-sm); }
.evidence-del:hover { background: var(--c-miss-row); }
.evidence-input { max-width: 190px; font-size: var(--fs-xs); }

/* --- 데이터 입력현황 매트릭스 --- */
.matrix-table th, .matrix-table td { padding: 8px; }
.matrix-table th .badge { margin-top: 2px; }
.mx-cell { display: inline-flex; flex-direction: column; align-items: stretch; gap: 2px; min-width: 104px; padding: 4px; text-decoration: none; border: 1px solid transparent; border-radius: var(--r-sm); }
.mx-cell:hover, .mx-cell.is-open { border-color: var(--c-info); background: var(--c-surface); }
.mx-line { display: block; padding: 1px 6px; font-size: var(--fs-xs); font-weight: 700; white-space: nowrap; color: var(--tone-fg, var(--c-muted)); background: var(--tone-bg, transparent); border-radius: 4px; }
.mx-line.none { color: var(--c-wait); font-weight: 500; }
.mx-notify { display: inline-flex; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--c-muted); }
.mx-notify .icon { width: 11px; height: 11px; }
.notify-log { margin: 4px 0 0; padding-left: 16px; font-size: var(--fs-sm); }
.notify-log li + li { margin-top: 2px; }

/* --- 권한 선택 (등급 수정 화면): 메뉴 묶음별 --- */
.perm-group { margin: 0; padding: 0; border: 0; min-width: 0; }
.perm-group + .perm-group { margin-top: var(--sp-4); padding-top: var(--sp-4); border-top: 1px solid var(--c-border); }
.perm-group-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: 4px; font-size: var(--fs-sm); font-weight: 700; color: var(--c-text-2); }
.perm-group-head .check { font-weight: 500; color: var(--c-muted); }
.perm-item { display: flex; align-items: flex-start; gap: var(--sp-2); padding: 6px 0; cursor: pointer; }
.perm-item input { width: 18px; height: 18px; margin: 2px 0 0; flex-shrink: 0; accent-color: var(--c-info); }
.perm-name { display: block; font-weight: 600; }
.perm-desc { display: block; margin-top: 2px; font-size: var(--fs-sm); line-height: 1.45; color: var(--c-muted); }

/* --- 대시보드·센서·추가수집 화면 공용 조각 --- */
.violet { --tone: #8B5CF6; --tone-bg: #EDE9FE; --tone-fg: #6D28D9; }   /* 시리즈 구분용 보조색 (상태색 아님) */
.stat-tile { padding: var(--sp-3) var(--sp-4); background: var(--tone-bg, var(--c-surface-2)); border-radius: var(--r); }
.stat-tile.info { background: var(--c-info-row); } .stat-tile.done { background: var(--c-done-row); }
.stat-tile-label { font-size: var(--fs-xs); font-weight: 700; color: var(--tone-fg, var(--c-text-2)); }
.stat-tile-value { margin-top: 2px; font-size: var(--fs-xl); font-weight: 700; color: var(--tone-fg, var(--c-text)); font-variant-numeric: tabular-nums; }
.stat-tile-value small { margin-left: 2px; font-size: var(--fs-sm); font-weight: 600; }
.stat-tile-sub { margin-top: 2px; font-size: var(--fs-xs); font-weight: 600; color: var(--c-miss-fg); }
.week-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: var(--sp-2); }
.week-tile { padding: var(--sp-2) var(--sp-3); text-align: center; background: var(--c-surface); border: 1px solid var(--c-border); border-top: 3px solid var(--tone, var(--c-border-strong)); border-radius: var(--r); }
.week-tile.delay { background: var(--c-delay-row); } .week-tile.wait { background: var(--c-surface-2); }
.week-tile-label { font-size: var(--fs-xs); color: var(--c-muted); }
.week-tile.delay .week-tile-label { color: var(--c-delay-fg); font-weight: 700; }
.week-tile-value { font-size: var(--fs-lg); font-weight: 700; color: var(--tone-fg, var(--c-text)); font-variant-numeric: tabular-nums; }
.week-tile-sub { font-size: var(--fs-xs); color: var(--tone-fg, var(--c-muted)); }
.bar-row + .bar-row { margin-top: var(--sp-5); }
.bar-row { padding: var(--sp-3) var(--sp-4); background: var(--c-surface-2); border-radius: var(--r); }
.alert-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.alert-row a, .link-more { font-weight: 700; color: inherit; text-decoration: none; white-space: nowrap; }
.big-number { font-size: 40px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.big-number small { margin-left: 4px; font-size: var(--fs-md); font-weight: 600; color: var(--c-muted); }
.farm-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-4); }
.farm-card { padding: var(--sp-4); background: var(--c-miss-row); border: 1px solid #FECACA; border-radius: var(--r-lg); }
.farm-card[hidden] { display: none; }
.farm-card-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); }
.farm-card-days { font-size: var(--fs-sm); font-weight: 700; color: var(--c-miss-fg); }
.farm-card h3 { margin-top: var(--sp-2); font-size: var(--fs-lg); }
.farm-card-meta { font-size: var(--fs-sm); color: var(--c-muted); }
.farm-card-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: var(--fs); color: var(--c-text-2); }
.farm-card-row .icon { color: var(--c-muted); }
.farm-card-last { margin-top: var(--sp-3); padding: var(--sp-2) var(--sp-3); background: var(--c-surface); border-radius: var(--r); }
.farm-card-last span { display: block; font-size: var(--fs-xs); color: var(--c-muted); }
.farm-card-last b { color: var(--c-miss-fg); font-variant-numeric: tabular-nums; }
.carousel-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.carousel-dots { display: inline-flex; gap: 5px; }
.carousel-dots button { width: 9px; height: 9px; padding: 0; background: #D1D5DB; border: 0; border-radius: 50%; }
.carousel-dots button.is-current { background: var(--c-miss); }
@media (max-width: 1023.98px) { .farm-cards { grid-template-columns: minmax(0, 1fr); } }
.table th.col-current, .table td.col-current { background: var(--c-delay-row); }
.table th.col-current { color: var(--c-delay-fg); }
.table th.col-input, .table td.col-input { background: var(--c-info-row); }
.table .group-start td { border-top: 2px solid var(--c-border); }
.extra-card { position: relative; padding: var(--sp-4) var(--sp-5); background: var(--c-surface); border: 1px solid var(--c-border); border-left: 4px solid var(--tone); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.extra-card-head { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-2); margin-bottom: 4px; }
.extra-card-head h3 { font-size: var(--fs-md); }
.extra-card-nums { display: flex; justify-content: space-between; gap: var(--sp-2); margin-bottom: 6px; font-size: var(--fs-sm); color: var(--c-text-2); }
.extra-card-nums b { color: var(--c-done-fg); }
.extra-table td, .extra-table th { white-space: nowrap; }
.extra-input { width: 88px; text-align: right; font-variant-numeric: tabular-nums; }
.extra-input.is-changed { border-color: var(--c-info); background: var(--c-info-row); }
.extra-input.is-invalid { border-color: var(--c-miss); background: var(--c-miss-row); }

/* --- 로그인 카드 --- */
.auth-card { width: 100%; max-width: 400px; padding: var(--sp-8) var(--sp-8) var(--sp-6); background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--r-lg); box-shadow: 0 10px 30px rgba(15, 23, 42, .08); }
.auth-brand { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-6); font-size: var(--fs-lg); font-weight: 700; }
.auth-brand .icon { width: 30px; height: 30px; color: var(--c-done); }
.auth-card h1 { margin-bottom: 4px; font-size: var(--fs-xl); }
.auth-card .form { max-width: none; margin-top: var(--sp-5); }
.auth-card .btn { width: 100%; }
@media (max-width: 479.98px) { .auth-card { padding: var(--sp-6) var(--sp-5); } }



/* ==========================================================================
   5. 유틸
   ========================================================================== */
.muted { color: var(--c-muted); }
.small { font-size: var(--fs-sm); }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); } .mt-6 { margin-top: var(--sp-6); }
.stack > * + * { margin-top: var(--sp-4); }
.text-done { color: var(--c-done-fg); } .text-info { color: var(--c-info-fg); } .text-miss { color: var(--c-miss-fg); } .text-delay { color: var(--c-delay-fg); }
.strong { font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
/* 스타일 가이드(/dev/styleguide) 전용 */
.sg-section { margin-top: var(--sp-8); }
.sg-section > h2 { margin-bottom: var(--sp-3); font-size: var(--fs-lg); }
.sg-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.sg-code { margin: var(--sp-3) 0 0; padding: var(--sp-3); overflow-x: auto; font-size: var(--fs-xs); line-height: 1.6; color: #E2E8F0; background: #0F172A; border-radius: var(--r); }
.sg-swatch { display: grid; gap: 4px; width: 132px; font-size: var(--fs-xs); color: var(--c-muted); }
.sg-swatch span { height: 44px; border-radius: var(--r); border: 1px solid rgba(0, 0, 0, .06); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
