/* ====================================================================
   임대료 관리 — 디자인 시스템
   톤: 차분한 회색 + 네이비, PC 우선
   ==================================================================== */

:root {
    /* Color palette — neutral grays */
    --gray-50:  #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;

    /* Accent — calm navy/blue */
    --accent-50:  #eff6ff;
    --accent-100: #dbeafe;
    --accent-500: #3b82f6;
    --accent-600: #2563eb;
    --accent-700: #1d4ed8;

    /* Semantic colors */
    --success-50:  #f0fdf4;
    --success-500: #16a34a;
    --success-700: #15803d;
    --danger-50:   #fef2f2;
    --danger-500:  #dc2626;
    --danger-700:  #b91c1c;
    --warning-50:  #fffbeb;
    --warning-500: #d97706;
    --warning-700: #b45309;

    /* Surfaces */
    --bg-app:           var(--gray-50);
    --bg-surface:       #ffffff;
    --bg-sidebar:       var(--gray-900);
    --bg-sidebar-hover: rgba(255, 255, 255, 0.08);
    --bg-sidebar-active: var(--accent-600);

    /* Borders */
    --border-subtle:  var(--gray-200);
    --border-default: var(--gray-300);
    --border:         var(--gray-200);  /* alias — 템플릿에서 사용 중 */

    /* Text */
    --text-primary:        var(--gray-900);
    --text-secondary:      var(--gray-700);
    --text-muted:          var(--gray-500);
    --text-on-dark:        rgba(255, 255, 255, 0.92);
    --text-on-dark-muted:  rgba(255, 255, 255, 0.6);

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-sm: 0 2px 4px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.08);

    /* Radii */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;

    /* Transitions */
    --transition-fast: 120ms ease;
    --transition: 180ms ease;

    /* Fonts — 숫자 표기용 (Microsoft Sans Serif 우선, OS별 시스템 sans 폴백) */
    --font-mono: "Microsoft Sans Serif", "MS Sans Serif", "맑은 고딕", "Malgun Gothic",
        Tahoma, Verdana, "Helvetica Neue", Arial, sans-serif;
}

/* 숫자 정렬·가독성 유틸리티 — JetBrains Mono로 통일 (표·금액·코드·날짜 모두) */
.num,
.tabular-nums {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;  /* slashed zero — 0과 O 구분 */
    letter-spacing: 0;
}
.mono {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    letter-spacing: 0;
}

/* ====================================================================
   Base
   ==================================================================== */

body {
    background: var(--bg-app);
    color: var(--text-primary);
    font-family: "Pretendard Variable", Pretendard, -apple-system,
        BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
        "Noto Sans KR", Roboto, "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "calt" 1, "ss01" 1;
}

a {
    color: var(--accent-600);
    text-decoration: none;
}

a:hover {
    color: var(--accent-700);
    text-decoration: underline;
}

/* ====================================================================
   Layout — Sidebar
   ==================================================================== */

.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ─── 상단 메뉴 레이아웃 (User.nav_layout='topbar') — 2026-05-28 ───
   .app-shell--topnav 는 사이드바 없이 본문만 전폭으로 렌더. body 에 padding-top 으로 header 공간 확보. */
.app-shell--topnav {
    display: block;
    padding-top: 54px;   /* topnav 높이만큼 본문 밀어내기 */
}

/* 환경 구분 배지 — dev 일 때만 brand 옆에 작게 (2026-05-28, 상단 풀-띠 대체) */
.env-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #1a1408;
    vertical-align: middle;
    margin-left: 4px;
}
.env-badge--dev {
    background: #f59e0b;
}

.topnav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 54px;
    z-index: 100;
    background: var(--bg-sidebar);
    color: var(--text-on-dark);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.topnav__brand {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
    flex-shrink: 0;
    padding-right: 8px;
    margin-right: 4px;
    border-right: 1px solid rgba(255,255,255,0.1);
}
.topnav__brand-icon {
    width: 30px; height: 30px;
    border-radius: var(--radius-sm);
    background: var(--accent-600);
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: 0.95rem;
}
.topnav__brand-text {
    display: flex; align-items: baseline; gap: 6px;
}
.topnav__brand-name {
    font-weight: 700; font-size: 1rem;
}
.topnav__brand-name-kr {
    font-weight: 500; font-size: 0.78rem; color: var(--text-on-dark-muted);
}
.topnav__menu {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    /* overflow 두면 자식 .topnav__dropdown(absolute) 가 잘려 안 보임 — visible 강제 (2026-05-28) */
    overflow: visible;
    flex-wrap: wrap;
}
.topnav__link {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 12px;
    color: var(--text-on-dark);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    white-space: nowrap;
}
.topnav__link:hover { background: var(--bg-sidebar-hover); color: var(--text-on-dark); text-decoration: none; }
.topnav__link.is-active { background: var(--bg-sidebar-active); font-weight: 600; }

.topnav__group {
    position: relative;
}
.topnav__group-toggle {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 12px;
    background: transparent;
    border: 0;
    color: var(--text-on-dark);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    font-family: inherit;
}
.topnav__group-toggle:hover { background: var(--bg-sidebar-hover); }
.topnav__group.is-open > .topnav__group-toggle { background: var(--bg-sidebar-active); }
.topnav__caret { font-size: 0.7rem; opacity: 0.7; margin-left: 2px; }
.topnav__group.is-open > .topnav__group-toggle > .topnav__caret { transform: rotate(180deg); }
.topnav__group-dot {
    display: inline-block;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #ef4444;
    margin-left: 2px;
}

.topnav__dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    min-width: 240px;
    background: #1e293b;                                 /* 어두운 슬레이트 — topnav 와 톤 통일 */
    color: var(--text-on-dark);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: var(--radius-md);
    box-shadow: 0 10px 28px rgba(0,0,0,0.32);
    padding: 6px;
    display: none;
    z-index: 10001;
}
.topnav__group.is-open > .topnav__dropdown { display: block !important; }
@media (hover: hover) and (pointer: fine) {
    .topnav__group:hover > .topnav__dropdown,
    .topnav__group:focus-within > .topnav__dropdown {
        display: block !important;
    }
    .topnav__group:hover > .topnav__group-toggle,
    .topnav__group:focus-within > .topnav__group-toggle {
        background: var(--bg-sidebar-active);
    }
}
.topnav__dd-link {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    color: var(--text-on-dark);
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    white-space: nowrap;
}
.topnav__dd-link:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.topnav__dd-link.is-active { background: var(--accent-600); color: #fff; font-weight: 600; }
.topnav__dd-link.is-active > i { color: #fff; }
.topnav__dd-link > i { width: 16px; text-align: center; color: var(--text-on-dark-muted); }
.topnav__dd-badge {
    margin-left: auto;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px;
    background: #ef4444; color: #fff;
    font-size: 0.72rem; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}

.topnav__user {
    display: flex; align-items: center; gap: 8px;
    flex-shrink: 0;
    padding-left: 8px;
    border-left: 1px solid rgba(255,255,255,0.1);
}
.topnav__user-link {
    display: inline-flex; align-items: center; gap: 8px;
    text-decoration: none; color: var(--text-on-dark);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
}
.topnav__user-link:hover { background: var(--bg-sidebar-hover); color: var(--text-on-dark); text-decoration: none; }
.topnav__user-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--accent-600);
    color: white;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.82rem;
}
.topnav__user-name { font-weight: 600; font-size: 0.88rem; }
.topnav__user-pos { font-size: 0.75rem; color: var(--text-on-dark-muted); }
.topnav__user-logout {
    color: var(--text-on-dark-muted);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    text-decoration: none;
}
.topnav__user-logout:hover { background: var(--bg-sidebar-hover); color: var(--text-on-dark); }

/* 사용자 드롭다운 — 권한 전환·내 정보·로그아웃 통합 (2026-05-28) */
.topnav__user-group { position: relative; }
.topnav__user-toggle {
    display: inline-flex; align-items: center; gap: 8px;
    background: transparent; border: 0;
    color: var(--text-on-dark);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: inherit;
}
.topnav__user-toggle:hover { background: var(--bg-sidebar-hover); }
.topnav__user-dropdown {
    right: 0; left: auto;        /* 우측 정렬 — 화면 오른쪽 끝에 위치 */
    min-width: 280px;
}
.topnav__dd-divider { height: 1px; background: rgba(255,255,255,0.1); margin: 6px 0; }
.topnav__dd-section-label {
    padding: 2px 12px 4px;
    font-size: 0.7rem; font-weight: 600;
    color: var(--text-on-dark-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
}
.topnav__dd-link--back {
    background: #fee2e2; color: #991b1b; font-weight: 600;
}
.topnav__dd-link--back:hover { background: #fecaca; color: #7f1d1d; }
.topnav__dd-role-row {
    display: flex; gap: 4px;
    padding: 0 6px 4px;
}
.topnav__dd-role {
    flex: 1; text-align: center;
    font-size: 0.74rem; padding: 4px 6px;
    border-radius: 4px; text-decoration: none;
    border: 1px solid;
}
.topnav__dd-role--director { background: #ede9fe; border-color: #8b5cf6; color: #5b21b6; }
.topnav__dd-role--director:hover { background: #ddd6fe; color: #4c1d95; }
.topnav__dd-role--ceo { background: #ecfccb; border-color: #65a30d; color: #365314; }
.topnav__dd-role--ceo:hover { background: #d9f99d; color: #1a2e05; }
.topnav__dd-role--admin { background: #fee2e2; border-color: #ef4444; color: #991b1b; }
.topnav__dd-role--admin:hover { background: #fecaca; color: #7f1d1d; }

.topnav__dd-teams {
    display: flex; flex-direction: column; gap: 2px;
    padding: 0 6px;
    max-height: 320px; overflow-y: auto;
}
.topnav__dd-team { border-radius: 4px; }
.topnav__dd-team[open] { background: rgba(245, 158, 11, 0.08); padding-bottom: 4px; }
.topnav__dd-team summary {
    list-style: none; cursor: pointer;
    display: grid; grid-template-columns: 60px 40px 1fr; gap: 6px;
    align-items: center; padding: 3px 4px;
    font-size: 0.74rem;
}
.topnav__dd-team summary::-webkit-details-marker { display: none; }
.topnav__dd-team-name { font-weight: 600; color: #fbbf24; }
.topnav__dd-team-mgr {
    padding: 2px 6px; border-radius: 4px;
    background: #fef3c7; border: 1px solid #f59e0b; color: #78350f;
    text-decoration: none; font-size: 0.7rem; text-align: center;
}
.topnav__dd-team-mgr:hover { background: #fde68a; color: #422006; }
.topnav__dd-team-count { font-size: 0.7rem; color: var(--text-on-dark-muted); }
.topnav__dd-team-members {
    display: flex; flex-wrap: wrap; gap: 3px;
    padding: 4px 6px 2px;
    border-top: 1px dashed rgba(245, 158, 11, 0.3);
}
.topnav__dd-team-member {
    font-size: 0.7rem; padding: 2px 7px;
    background: #fff; border: 1px solid #fcd34d; color: #78350f;
    border-radius: 999px; text-decoration: none;
    white-space: nowrap;
}
.topnav__dd-team-member:hover { background: #fde68a; color: #92400e; }

.topnav__mobile-toggle {
    display: none;
    background: transparent; border: 0; color: var(--text-on-dark);
    font-size: 1.4rem; padding: 6px 8px; cursor: pointer;
}

/* 모바일: 메뉴를 햄버거로 접고, .topnav__menu 는 펼침 시 세로 패널 */
@media (max-width: 900px) {
    .topnav__mobile-toggle { display: inline-flex; }
    .topnav__menu {
        position: fixed;
        top: 54px; left: 0; right: 0;
        flex-direction: column;
        gap: 0;
        background: var(--bg-sidebar);
        padding: 8px;
        max-height: calc(100vh - 54px);
        overflow-y: auto;
        display: none;
        border-top: 1px solid rgba(255,255,255,0.08);
    }
    .topnav__menu.is-open { display: flex; }
    .topnav__group { width: 100%; }
    .topnav__group-toggle { width: 100%; justify-content: space-between; }
    .topnav__dropdown { position: static; min-width: 0; background: transparent; box-shadow: none; border: 0; padding: 0 0 4px 12px; color: var(--text-on-dark); }
    .topnav__dd-link { color: var(--text-on-dark); }
    .topnav__dd-link:hover { background: var(--bg-sidebar-hover); color: var(--text-on-dark); }
    .topnav__dd-link.is-active { background: var(--bg-sidebar-active); color: white; }
    .topnav__dd-link > i { color: var(--text-on-dark-muted); }
    .topnav__user-name, .topnav__user-pos { display: none; }
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--bg-sidebar);
    color: var(--text-on-dark);
    padding: 20px 9px;   /* 좌우 여백 축소 — 긴 메뉴명 줄바꿈 방지 (수정요청) */
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 12px;
}

.sidebar__brand-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: var(--accent-600);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sidebar__brand-name {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-on-dark);
    margin: 0;
    white-space: nowrap;
}
.sidebar__brand-name-kr {
    font-weight: 500;
    font-size: 0.82rem;
    color: var(--text-on-dark-muted);
    margin-left: 4px;
}

.sidebar__brand-sub {
    font-size: 0.72rem;
    color: var(--text-on-dark-muted);
    margin: 0;
}

.sidebar__brand-user {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px 12px;
    margin-top: -8px;
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 0.78rem;
    color: var(--text-on-dark);
}
.sidebar__brand-user > i {
    color: var(--text-on-dark-muted);
    font-size: 0.95rem;
}
.sidebar__brand-user-name {
    font-weight: 600;
}
.sidebar__brand-user-meta {
    color: var(--text-on-dark-muted);
    font-size: 0.72rem;
    margin-left: auto;
}

.sidebar__group-label {
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #93c5fd;             /* 어두운 사이드바 위에서 또렷한 라이트 블루 — 메뉴 항목과 시각적으로 분리 */
    padding: 12px 12px 4px;
    font-weight: 700;
}

.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 1px;            /* 2px → 1px (메뉴 사이 간격 축소) */
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2px 8px;   /* 행간격 + 좌우 여백 축소 (긴 메뉴명 줄바꿈 방지) */
    border-radius: var(--radius-sm);
    color: var(--text-on-dark);
    font-size: 0.9rem;
    text-decoration: none;
    transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar__link:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-on-dark);
    text-decoration: none;
}

.sidebar__link.is-active {
    background: var(--bg-sidebar-active);
    color: white;
    font-weight: 600;
}

.sidebar__link-icon {
    width: 18px;
    text-align: center;
    font-size: 1rem;
    flex-shrink: 0;
    opacity: 0.85;
}

.sidebar__link.is-active .sidebar__link-icon {
    opacity: 1;
}

/* 서브 메뉴 — 부모 메뉴 아래 들여쓴 보조 링크 (예: GDrive 상태 ↳ 첨부 한도) */
.sidebar__link--sub {
    padding-left: 28px;
    font-size: 0.84rem;
    opacity: 0.85;
}
.sidebar__link--sub .sidebar__link-icon {
    font-size: 0.85rem;
    opacity: 0.75;
}

.sidebar__footer {
    margin-top: auto;
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    font-size: 0.78rem;
    color: var(--text-on-dark-muted);
}

.sidebar__user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 4px;
}

.sidebar__user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--accent-600);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.sidebar__user-info {
    flex: 1;
    min-width: 0;
}

.sidebar__user-name {
    color: var(--text-on-dark);
    font-size: 0.86rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar__user-role {
    color: var(--text-on-dark-muted);
    font-size: 0.72rem;
}

.sidebar__logout {
    color: var(--text-on-dark-muted);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    text-decoration: none;
}

.sidebar__logout:hover {
    background: var(--bg-sidebar-hover);
    color: white;
    text-decoration: none;
}

/* ====================================================================
   Layout — Main content area
   ==================================================================== */

.app-main {
    flex: 1;
    min-width: 0;
    padding: 28px 36px;
    max-width: 1600px;
    width: 100%;
}

/* ====================================================================
   Page header
   ==================================================================== */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.page-header__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 4px;
}

.page-header__subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin: 0;
}

.page-header__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ====================================================================
   Stat cards
   ==================================================================== */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-xs);
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: box-shadow var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
}

.stat-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-card__label {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-card__icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    background: var(--gray-100);
    color: var(--gray-600);
}

.stat-card__icon--accent { background: var(--accent-50);  color: var(--accent-600); }
.stat-card__icon--success { background: var(--success-50); color: var(--success-700); }
.stat-card__icon--danger  { background: var(--danger-50);  color: var(--danger-700); }
.stat-card__icon--warning { background: var(--warning-50); color: var(--warning-700); }

.stat-card__value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.stat-card__value--success { color: var(--success-700); }
.stat-card__value--danger  { color: var(--danger-700); }

.stat-card__caption {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ====================================================================
   Alert banner (e.g. overdue notice)
   ==================================================================== */

.alert-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    border: 1px solid transparent;
}

.alert-banner--danger {
    background: var(--danger-50);
    border-color: #fecaca;
    color: var(--danger-700);
}

.alert-banner--success {
    background: var(--success-50);
    border-color: #bbf7d0;
    color: var(--success-700);
}

.alert-banner--info {
    background: var(--accent-50);
    border-color: #bfdbfe;
    color: var(--accent-700);
}

.alert-banner__icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.alert-banner__body {
    flex: 1;
    font-size: 0.9rem;
}

.alert-banner__title {
    font-weight: 600;
    margin-bottom: 2px;
}

.alert-banner__action {
    color: inherit;
    font-weight: 600;
    text-decoration: underline;
}

.alert-banner__action:hover {
    color: inherit;
    opacity: 0.8;
}

/* ====================================================================
   Generic surface card
   ==================================================================== */

.surface-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
}

.surface-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.surface-card__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.surface-card__action {
    font-size: 0.82rem;
    color: var(--accent-600);
    font-weight: 500;
}

.surface-card__body {
    padding: 16px 20px;
}

.surface-card__body--flush {
    padding: 0;
}

/* ====================================================================
   Two-column dashboard grid (chart + side panel)
   ==================================================================== */

.dashboard-split {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

@media (max-width: 1100px) {
    .dashboard-split {
        grid-template-columns: 1fr;
    }
}

/* ====================================================================
   Mini stat (small inline stats inside a card)
   ==================================================================== */

.mini-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.mini-stat-row:last-child {
    border-bottom: 0;
}

.mini-stat-row__label {
    font-size: 0.88rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.mini-stat-row__value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.mini-stat-row__value--muted { color: var(--text-muted); font-weight: 500; }
.mini-stat-row__value--success { color: var(--success-700); }
.mini-stat-row__value--danger { color: var(--danger-700); }

/* ====================================================================
   OCR upload page (사업자등록증 자동 입력)
   ==================================================================== */

.ocr-upload {
    text-align: center;
    padding: 30px 20px 20px;
    max-width: 520px;
    margin: 0 auto;
}

.ocr-upload__icon-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--accent-50);
    color: var(--accent-600);
    font-size: 2rem;
    margin-bottom: 16px;
}

.ocr-upload__title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px;
}

.ocr-upload__hint {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin: 0 0 20px;
    line-height: 1.6;
}

.ocr-upload__field {
    margin-bottom: 18px;
}

.ocr-upload__submit {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
}

.ocr-upload__submit:disabled {
    opacity: 0.7;
    cursor: wait;
}

.ocr-upload__caption {
    margin: 16px 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.ocr-upload__caption i {
    margin-right: 4px;
}

.ocr-divider {
    text-align: center;
    margin: 24px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    position: relative;
}

.ocr-divider::before,
.ocr-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: var(--border-subtle);
}

.ocr-divider::before { left: 0; }
.ocr-divider::after { right: 0; }

.ocr-direct {
    text-align: center;
    padding: 4px 0 16px;
}

/* ====================================================================
   업태/종목 페어 입력 (최대 5쌍)
   ==================================================================== */

.business-categories {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--gray-50);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 12px;
}

.business-categories__header {
    display: grid;
    grid-template-columns: 28px 1fr 2fr;
    gap: 8px;
    padding: 0 4px 4px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 4px;
}

.business-categories__col-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    padding-left: 4px;
}

.business-categories__col-label--type {
    grid-column: 2;
}

.business-categories__col-label--item {
    grid-column: 3;
}

.business-categories__row {
    display: grid;
    grid-template-columns: 28px 1fr 2fr;
    gap: 8px;
    align-items: center;
}

.business-categories__index {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 600;
    flex-shrink: 0;
    margin-left: 2px;
}

/* ====================================================================
   File preview (사업자등록증 등 첨부 파일)
   ==================================================================== */

.file-preview {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 12px;
    background: var(--gray-50);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
}

.file-preview__thumb {
    position: relative;
    display: block;
    width: 200px;
    height: 200px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    flex-shrink: 0;
    text-decoration: none;
    transition: transform var(--transition);
}

.file-preview__thumb:hover {
    transform: scale(1.02);
    text-decoration: none;
}

.file-preview__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #fff;
}

.file-preview__thumb--pdf {
    background: #f8f9fb;
}

.file-preview__overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(15, 23, 42, 0.85), rgba(15, 23, 42, 0));
    color: #fff;
    padding: 24px 12px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    text-align: center;
    opacity: 0;
    transition: opacity var(--transition);
    pointer-events: none;
}

.file-preview__thumb:hover .file-preview__overlay {
    opacity: 1;
}

.file-preview__meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 4px;
}

.file-preview__name {
    font-size: 0.86rem;
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-all;
    display: flex;
    align-items: center;
    gap: 6px;
}

.file-preview__name i {
    color: var(--text-muted);
    flex-shrink: 0;
}

.file-preview__remove {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    user-select: none;
    margin-top: auto;
}

/* ====================================================================
   Compact form (회사 폼 등 입력 항목 많을 때)
   ==================================================================== */

.compact-form .form-control,
.compact-form .form-select {
    padding: 4px 10px;
    font-size: 0.86rem;
    height: 32px;   /* 폼 높이 표준: 컴팩트 = 32px (2026-07-20) */
    min-height: 32px;
}

.compact-form textarea.form-control {
    height: auto;
    min-height: 76px;
}

.compact-form .form-label {
    font-size: 0.78rem;
    margin-bottom: 4px;
}

.compact-form .input-group-text {
    padding: 4px 10px;
    font-size: 0.86rem;
    min-width: 32px;
}

.compact-form .form-text {
    font-size: 0.72rem;
    margin-top: 2px;
}

.compact-form .row.g-3 {
    --bs-gutter-y: 0.75rem;
}

/* ====================================================================
   Tables
   ==================================================================== */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table thead th {
    background: var(--gray-50);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 7px 12px;
    border-bottom: 1px solid var(--border-subtle);
    text-align: left;
}

.data-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

/* 일괄선택 — 체크된 행 강조 (수정요청 #50). td 에 !important 로 인라인 배경(단종/보류 등) 위에 적용 */
.data-table tbody tr.bulk-row-selected > td {
    background-color: #dbeafe !important;
}
.data-table tbody tr.bulk-row-selected:hover > td {
    background-color: #bfdbfe !important;
}

.data-table--clickable tbody tr {
    cursor: pointer;
    transition: background var(--transition-fast);
}

/* 셀 안 링크 — 호버 시 커서 pointer 만, 폰트/색/밑줄 변화 없음 (인라인 클릭 가능 셀용) */
.cell-link {
    color: inherit; text-decoration: none; cursor: pointer;
}
.cell-link:hover, .cell-link:focus {
    color: inherit; text-decoration: none;
}

.data-table--clickable tbody tr:focus {
    outline: 2px solid var(--accent-500);
    outline-offset: -2px;
    background: var(--accent-50);
}

.data-table .text-end {
    text-align: right;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    letter-spacing: 0;
}
.data-table .text-center { text-align: center; }
.data-table .text-muted { color: var(--text-muted); }
/* 본문 셀은 Pretendard 유지 + tabular-nums (Korean 텍스트와 자연스럽게 어울림) */
.data-table tbody td {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

.data-table__empty {
    text-align: center;
    color: var(--text-muted);
    padding: 32px 16px;
}

/* ====================================================================
   한글 헤더 컬럼 너비 — "줄바꿈 영구 차단 + 글자 수 기반 자동 너비"
   ====================================================================
   th 의 글씨가 좁아서 줄바꿈/잘림 되는 문제 영구 해결.

   원리:
     - 한글 1글자 ≈ 1em (현재 셀 폰트 크기 기준)
     - thead 폰트 0.78rem · padding 11px 16px · letter-spacing 0.04em 반영
     - --col-pad-x = 좌우 패딩(32px) + 시각 여유(8px) = 40px
     - col-ko-N = N글자 + 패딩 = N×0.78rem + 40px

   사용:
     <th class="col-ko-5">영업담당자</th>      ← 한글 5글자
     <th class="col-phone">연락처</th>          ← 전화번호 (mono)
     <th class="col-money text-end">미수금액</th>

   주의:
     - table-layout: auto 가 기본이라 "셀 내용이 더 길면" 자동 확장됨.
       정확히 고정하려면 .col-strict 모디파이어 추가 (max-width 도 함께).
     - 영문은 한글보다 좁아서 약간 여유 발생 (정상).
   ==================================================================== */

/* 헤더 — nowrap 유지 (제목 줄바꿈 시 시각 노이즈). */
.data-table thead th { white-space: nowrap; }
/* 본문 셀 — 기본 wrap 허용 (한글 자연 줄바꿈 + 긴 영문/URL 글자 단위 절단).
   2026-06-01 — 전역 nowrap 정책 부분 폐기. col-* 클래스 (col-money/col-date/col-status/col-phone/col-projno 등)
   가 붙은 셀은 위쪽 nowrap 규칙으로 한 줄 유지. 일반 본문 셀은 wrap. */
.data-table tbody td {
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: anywhere;
}
/* 명시적 nowrap 셀 (.col-nowrap) — col-* 외에 셀 단위 수동 nowrap 필요 시 */
.data-table .col-nowrap,
.data-table td.col-nowrap,
.data-table th.col-nowrap { white-space: nowrap; }
/* 표가 화면을 넘으면 가로 스크롤 (예외적인 매우 넓은 표만 — 일반 목록은 wrap 으로 적응) */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* 숫자/날짜/금액 셀 — Q2: nowrap 유지 (콤마 분리되면 가독성 떨어짐) */
.data-table .num,
.data-table .text-end,
.data-table .col-money,
.data-table .col-money-lg,
.data-table .col-phone,
.data-table .col-mobile,
.data-table .col-bizno,
.data-table .col-projno,
.data-table .col-date,
.data-table .col-datetime,
.data-table .col-datetime-short,
.data-table .col-pct {
    white-space: nowrap;
}

:root { --col-pad-x: 40px; }    /* 좌우 padding 32px + 시각 여유 8px */

/* 한글 글자 수 기반 — 헤더 텍스트 길이에 맞춤 */
.col-ko-2  { width: calc(2em  + var(--col-pad-x)); }
.col-ko-3  { width: calc(3em  + var(--col-pad-x)); }
.col-ko-4  { width: calc(4em  + var(--col-pad-x)); }
.col-ko-5  { width: calc(5em  + var(--col-pad-x)); }
.col-ko-6  { width: calc(6em  + var(--col-pad-x)); }
.col-ko-7  { width: calc(7em  + var(--col-pad-x)); }
.col-ko-8  { width: calc(8em  + var(--col-pad-x)); }
.col-ko-10 { width: calc(10em + var(--col-pad-x)); }
.col-ko-12 { width: calc(12em + var(--col-pad-x)); }
.col-ko-15 { width: calc(15em + var(--col-pad-x)); }

/* 데이터 타입별 표준 너비 — 셀 내용 기반 (mono/sans 폰트 차이까지 반영) */
.col-icon      { width:  28px; }   /* ★·⋮ 아이콘 1개만 (체크박스보다 좁은 칸) */
.col-checkbox  { width:  44px; }   /* □ 체크박스 단독 */
.col-ord       { width:  56px; }   /* 회차 번호 (1·2·3...) */
.col-projno    { width: 100px; }   /* 25-C001 */
.col-bizno     { width: 130px; }   /* 123-45-67890 */
.col-phone     { width: 140px; }   /* 010-1234-5678 (mono) */
.col-mobile    { width: 130px; }   /* 010-1234-5678 (sans) */
.col-email     { width: 200px; }   /* xxx@xxx.com */
.col-date      { width: 110px; }   /* 2026-05-08 */
.col-datetime  { width: 130px; }   /* 2026-05-08 14:30 */
.col-datetime-short { width: 90px; }   /* 05-08 14:30 (시각만 짧게) */
.col-money     { width: 130px; }   /* 1,234,567 (text-end + mono) */
.col-money-lg  { width: 160px; }   /* 12,345,678,901 */
.col-pct       { width:  80px; }   /* 99.5% */
.col-status    { width: 100px; }   /* 상태 뱃지 */
.col-status-lg { width: 130px; }   /* 1차상담완료 같은 긴 뱃지 */
.col-action    { width: 140px; }   /* 동작 버튼 1개 */
.col-action-lg { width: 200px; }   /* 동작 버튼 2개 */

/* 정확한 너비 고정이 필요한 경우 — max-width 도 함께 잠금 (overflow ellipsis 와 같이 쓸 때) */
.col-strict { max-width: var(--col-strict-w, 100%); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 가변 길이 셀(메모·본문·주소·건명) — 전역 nowrap 정책의 유일한 예외. BOOTSTRAP §9-3.
   한글은 어절 단위로 자연스럽게 접고(keep-all), 긴 영문·URL 은 칸을 넘기지 않게 글자 단위 절단. */
.data-table .col-wrap,
.data-table th.col-wrap,
.data-table td.col-wrap {
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: anywhere;
}

/* ====================================================================
   영업이력 1줄 카드 — list.html 펼침 패널 + form.html 편집 페이지 공통
   ==================================================================== */
.log-row { margin-bottom: 4px; }
.log-row:last-child { margin-bottom: 0; }

.log-row__view {
    display: flex;
    align-items: baseline;  /* 첫 줄 텍스트 baseline에 모든 메타·버튼 정렬 — 내용이 멀티라인이어도 흔들리지 않음 */
    gap: 10px;
    padding: 8px 10px 8px 12px;
    background: #fff;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    line-height: 1.45;
}
.log-row__view:hover { background: #fafcff; border-color: var(--gray-300); }

/* 날짜 — 가독성 강조: mono, 약간 진한 색, 등폭 */
.log-row__date {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    font-weight: 600;
    color: var(--gray-800);
    font-size: 0.82rem;
    letter-spacing: -0.01em;
    flex-shrink: 0;
    min-width: 86px;
}
/* 시간 — 작은 칩 형태로 시각적 구분 */
.log-row__time {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--gray-500);
    background: var(--gray-100);
    padding: 1px 7px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 500;
    flex-shrink: 0;
    line-height: 1.5;
}
/* 작성자 — 사람 아이콘 + 이름, 회색톤 */
.log-row__author {
    color: var(--gray-600);
    font-weight: 500;
    font-size: 0.8rem;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.log-row__author i {
    color: var(--gray-400);
    font-size: 0.9rem;
    flex-shrink: 0;
}
.log-row__badge {
    flex-shrink: 0;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 7px;
}
.log-row__content {
    flex: 1 1 auto;
    color: var(--text-primary);
    font-size: 0.9rem;
    line-height: 1.45;
    word-break: break-word;
    min-width: 0;
    white-space: pre-wrap;  /* 줄바꿈 보존 */
}

/* 영업이력 내용 입력 — textarea 자동 높이 조정 */
.log-content-input {
    resize: none;
    overflow-y: hidden;
    line-height: 1.45;
    min-height: calc(1.5em + 0.5rem + 2px);  /* form-control-sm 1줄 높이와 동일 */
    transition: height 0.08s ease;
}

/* 수정/삭제 — 아이콘 대신 작은 텍스트 링크 (가벼운 노출) */
.log-row__actions {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
    padding-left: 4px;
}
.log-row__btn {
    background: transparent;
    border: none;
    padding: 2px 7px;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.74rem;
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: -0.01em;
    transition: color 0.12s ease, background 0.12s ease;
}
.log-row__btn:hover { color: var(--accent-700); background: var(--accent-50); }
.log-row__btn--danger:hover { color: var(--danger-700); background: var(--danger-50); }
.log-row__view .log-row__actions form { display: inline-flex; }

/* 인라인 수정 폼 — 노란 배경으로 편집 중 시각화 */
.log-row__edit {
    padding: 8px 10px;
    background: #fffbeb;
    border: 1px solid #fcd34d;
    border-radius: 6px;
}

/* ====================================================================
   Chart container
   ==================================================================== */

.chart-container {
    position: relative;
    height: 280px;
    padding: 8px 0;
}

/* ====================================================================
   Buttons (overrides Bootstrap a bit for tone consistency)
   ==================================================================== */

.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
}

/* 표 행 액션용 초소형 버튼 — 그동안 미정의라 기본 .btn 크기로 커 보였음(2026-07-15) */
.btn-xs {
    padding: 3px 10px;
    font-size: 0.76rem;
    line-height: 1.4;
    border-radius: 6px;
}

.btn-primary {
    background: var(--accent-600);
    border-color: var(--accent-600);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--accent-700);
    border-color: var(--accent-700);
}

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border-default);
}

.btn-outline-secondary:hover {
    background: var(--gray-100);
    color: var(--text-primary);
    border-color: var(--gray-400);
}

/* ====================================================================
   Forms
   ==================================================================== */

.form-control,
.form-select {
    border-radius: var(--radius-sm);
    border-color: var(--border-default);
    color: var(--text-primary);
    font-size: 0.92rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent-500);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.86rem;
    margin-bottom: 6px;
}

.input-group-text {
    background: var(--gray-100);
    border-color: var(--border-default);
    color: var(--text-secondary);
    min-width: 40px;
    justify-content: center;
}

/* --------------------------------------------------------------------
   폼 높이 표준 (2026-07-20 UI 전수감사 후 확정 — docs/CONVENTIONS.md §폼 표준)
   - 기본(등록·수정 폼): .form-control / .form-select = 36px 고정
   - 컴팩트(목록 필터·표 안 인라인): -sm = 32px 고정
   - textarea·다중 select(multiple/size)는 높이 고정 제외
   - scripts/ui_check.py 가 {32, 36} 외 높이를 HARD 실패로 검출
   -------------------------------------------------------------------- */

.form-control,
.form-select {
    height: 36px;
    min-height: 36px;   /* Bootstrap의 em 기반 min-height(폰트 크면 36 초과) 무력화 */
}

.form-control-sm,
.form-select-sm {
    height: 32px;
    min-height: 32px;
    font-size: 0.84rem;
}

textarea.form-control,
textarea.form-control-sm {
    height: auto;
    min-height: 76px;
}

select.form-select[multiple],
select.form-select[size]:not([size="1"]) {
    height: auto;
}

/* ====================================================================
   Status badges
   ==================================================================== */

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    min-width: 64px;
    justify-content: center;
}

.status-badge--success { background: var(--success-50); color: var(--success-700); }
.status-badge--danger  { background: var(--danger-50);  color: var(--danger-700); }
.status-badge--warning { background: var(--warning-50); color: var(--warning-700); }
.status-badge--neutral { background: var(--gray-100);   color: var(--gray-700); }

/* ====================================================================
   Legacy admin-table (used in list pages — keep for now)
   ==================================================================== */

.admin-table {
    table-layout: auto;
    width: max-content;
    min-width: 100%;
    font-size: 0.92rem;
}

.admin-table th,
.admin-table td {
    vertical-align: middle;
}

.admin-table .col-compact {
    width: 1%;
    white-space: nowrap;
}

.admin-table .col-money {
    width: 1%;
    min-width: 120px;
}

.admin-table .col-normal {
    min-width: 120px;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-table .col-wide {
    min-width: 220px;
    max-width: 420px;
    white-space: normal;
    word-break: keep-all;
}

/* Card wrapper used on list/form pages — keep for now */
.table-card {
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
    background: var(--bg-surface);
}

/* ====================================================================
   업태 / 종목 — 그리드 row UI (사업자등록증 카테고리 입력)
   ==================================================================== */
.business-categories {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: var(--gray-50);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 12px;
}
.business-categories__header {
    display: grid;
    grid-template-columns: 28px 1fr 2fr 32px;
    gap: 8px;
    padding: 0 4px 4px;
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: 4px;
}
.business-categories__col-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    padding-left: 4px;
}
.business-categories__col-label--type { grid-column: 2; }
.business-categories__col-label--item { grid-column: 3; }

.business-categories__rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.business-categories__row {
    display: grid;
    grid-template-columns: 28px 1fr 2fr 32px;
    gap: 8px;
    align-items: center;
}
.business-categories__index {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--gray-200);
    color: var(--text-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 600;
    flex-shrink: 0;
    margin-left: 2px;
    font-variant-numeric: tabular-nums;
}
.business-categories__remove {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    background: #fff;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.business-categories__remove:hover {
    color: var(--danger-700);
    border-color: var(--danger-500);
    background: var(--danger-50);
}
.business-categories__add {
    align-self: flex-start;
    margin-top: 4px;
}

/* ====================================================================
   File preview — 사업자등록증 이미지·PDF 미리보기
   ==================================================================== */
.file-preview {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding: 12px;
    background: var(--gray-50);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
}
.file-preview__thumb {
    position: relative;
    display: block;
    width: 200px;
    height: 200px;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    flex-shrink: 0;
    text-decoration: none;
    transition: transform 0.18s ease;
}
.file-preview__thumb:hover {
    transform: scale(1.02);
    text-decoration: none;
}
.file-preview__thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #fff;
}
.file-preview__thumb--pdf { background: #f8f9fb; }
.file-preview__overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(15, 23, 42, 0.85), rgba(15, 23, 42, 0));
    color: #fff;
    padding: 24px 12px 10px;
    font-size: 0.78rem;
    font-weight: 600;
    text-align: center;
    opacity: 0;
    transition: opacity 0.18s ease;
    pointer-events: none;
}
.file-preview__thumb:hover .file-preview__overlay { opacity: 1; }
.file-preview__meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 4px;
}
.file-preview__name {
    font-size: 0.86rem;
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-all;
    display: flex;
    align-items: center;
    gap: 6px;
}
.file-preview__name i { color: var(--text-muted); flex-shrink: 0; }
.file-preview__remove {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    cursor: pointer;
    user-select: none;
    margin-top: auto;
}

/* ====================================================================
   페이지네이션 — 모든 리스트 공용
   ==================================================================== */
.pager {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
    margin: 18px 0 8px;
    padding: 12px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}
.pager__info {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.pager__count { font-size: 0.85rem; color: var(--text-secondary); }
.pager__size-group { display: flex; gap: 4px; align-items: center; }
.pager__size-label { font-size: 0.78rem; color: var(--text-muted); margin-left: 4px; }
.pager__size {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    padding: 3px 10px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    text-decoration: none;
    transition: all 120ms ease;
    line-height: 1.5;
}
.pager__size:hover { border-color: var(--accent-500); color: var(--accent-700); text-decoration: none; }
.pager__size.is-active {
    background: var(--accent-600);
    border-color: var(--accent-600);
    color: #fff;
    font-weight: 600;
}
.pager__nav { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.pager__btn {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    padding: 5px 10px;
    min-width: 34px;
    text-align: center;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    text-decoration: none;
    display: inline-block;
    line-height: 1.4;
    transition: all 120ms ease;
}
.pager__btn:hover:not(.is-disabled):not(.is-current) {
    border-color: var(--accent-500);
    color: var(--accent-700);
    text-decoration: none;
}
.pager__btn.is-current {
    background: var(--accent-600);
    border-color: var(--accent-600);
    color: #fff;
    font-weight: 600;
}
.pager__btn.is-disabled { opacity: 0.4; pointer-events: none; }
.pager__ellipsis { padding: 0 4px; color: var(--text-muted); user-select: none; }


/* ====================================================================
   THEME B — Premium Dark · Fraunces 헤드라인 + 골드 액센트
   ==================================================================== */
body[data-theme="b"] {
    --bg-app:           #0d1117;
    --bg-surface:       #161e2c;
    --bg-sidebar:       #131a24;
    --bg-sidebar-hover: rgba(212, 165, 116, 0.08);
    --bg-sidebar-active: rgba(212, 165, 116, 0.18);

    --border:         #232d40;
    --border-subtle:  #1e2738;
    --border-default: #2d3a52;

    --accent-50:  rgba(212, 165, 116, 0.10);
    --accent-100: rgba(212, 165, 116, 0.18);
    --accent-500: #d4a574;
    --accent-600: #d4a574;
    --accent-700: #e8b988;

    --text-primary:        #e6ecf3;
    --text-secondary:      #cbd5e1;
    --text-muted:          #94a3b8;
    --text-on-dark:        rgba(255, 255, 255, 0.92);
    --text-on-dark-muted:  rgba(255, 255, 255, 0.60);

    --success-50:  rgba(110, 231, 183, 0.12);
    --success-500: #6ee7b7;
    --success-700: #34d399;
    --danger-50:   rgba(248, 113, 113, 0.12);
    --danger-500:  #f87171;
    --danger-700:  #fca5a5;
    --warning-50:  rgba(251, 191, 36, 0.12);
    --warning-500: #fbbf24;
    --warning-700: #fcd34d;

    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.30);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.40);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.50);

    --font-mono: 'JetBrains Mono', SFMono-Regular, Menlo, monospace;

    background:
        radial-gradient(1200px 600px at 85% -10%, rgba(212, 165, 116, 0.08), transparent 60%),
        radial-gradient(900px 500px at -10% 30%, rgba(125, 211, 252, 0.05), transparent 60%),
        #0d1117;
    color: var(--text-primary);
}

/* 헤드라인은 Fraunces 세리프, 본문은 Pretendard */
body[data-theme="b"] h1,
body[data-theme="b"] h2,
body[data-theme="b"] h3,
body[data-theme="b"] h4,
body[data-theme="b"] .page-header h1,
body[data-theme="b"] .surface-card__title {
    font-family: 'Fraunces', Georgia, serif;
    letter-spacing: -0.015em;
    color: var(--text-primary);
}
body[data-theme="b"] .num,
body[data-theme="b"] .tabular-nums,
body[data-theme="b"] .mono {
    font-family: 'JetBrains Mono', SFMono-Regular, Menlo, monospace;
}

/* 사이드바 */
body[data-theme="b"] .sidebar { background: var(--bg-sidebar); border-right: 1px solid var(--border); }
body[data-theme="b"] .sidebar__brand-name {
    color: var(--text-primary);
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 700;
}
body[data-theme="b"] .sidebar__brand-sub {
    color: var(--accent-500);
    font-family: 'JetBrains Mono', SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-size: 0.7rem;
}
body[data-theme="b"] .sidebar__brand-icon {
    background: linear-gradient(135deg, var(--accent-700), var(--accent-500));
    color: #1a1408;
}
body[data-theme="b"] .sidebar__group-label {
    color: var(--accent-500);
    font-family: 'JetBrains Mono', SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}
body[data-theme="b"] .sidebar__link { color: rgba(255, 255, 255, 0.78); }
body[data-theme="b"] .sidebar__link:hover { background: var(--bg-sidebar-hover); color: #fff; }
body[data-theme="b"] .sidebar__link.is-active { background: var(--bg-sidebar-active); color: var(--accent-700); }
body[data-theme="b"] .sidebar__link.is-active .sidebar__link-icon { color: var(--accent-700); }

/* 본문 카드 / 표 */
body[data-theme="b"] .surface-card { background: var(--bg-surface); border-color: var(--border); }
body[data-theme="b"] .surface-card__header { border-bottom-color: var(--border); }
body[data-theme="b"] .data-table thead th {
    background: #131a24;
    color: var(--text-muted);
    border-bottom-color: var(--border);
}
body[data-theme="b"] .data-table tbody td {
    border-bottom-color: var(--border);
    color: var(--text-primary);
}
body[data-theme="b"] .data-table--clickable tbody tr { cursor: pointer; }
body[data-theme="b"] .data-table--clickable tbody tr:hover {
    background: rgba(212, 165, 116, 0.05) !important;
}
body[data-theme="b"] .data-table__empty { color: var(--text-muted); }

/* 인라인 style="background:#xxxxxx" 셀들의 배경 — 다크 톤에 맞게 흐리게 */
body[data-theme="b"] tr[style*="#f0fdf4"] { background: rgba(110, 231, 183, 0.07) !important; }
body[data-theme="b"] tr[style*="#eff6ff"] { background: rgba(125, 211, 252, 0.06) !important; }
body[data-theme="b"] tr[style*="#fef2f2"] { background: rgba(248, 113, 113, 0.07) !important; }
body[data-theme="b"] tr[style*="#fffbeb"] { background: rgba(251, 191, 36, 0.07) !important; }

/* 입력·버튼·링크 */
body[data-theme="b"] .form-control,
body[data-theme="b"] .form-select,
body[data-theme="b"] .input-group-text {
    background: #131a24;
    border-color: var(--border);
    color: var(--text-primary);
}
body[data-theme="b"] .form-control:focus,
body[data-theme="b"] .form-select:focus {
    background: #131a24;
    border-color: var(--accent-500);
    color: var(--text-primary);
    box-shadow: 0 0 0 0.2rem rgba(212, 165, 116, 0.18);
}
body[data-theme="b"] .form-control::placeholder { color: var(--text-muted); }

body[data-theme="b"] .btn-primary {
    background: var(--accent-600);
    border-color: var(--accent-600);
    color: #1a1408;
    font-weight: 600;
}
body[data-theme="b"] .btn-primary:hover {
    background: var(--accent-700);
    border-color: var(--accent-700);
    color: #1a1408;
}
body[data-theme="b"] .btn-secondary {
    background: #2d3a52;
    border-color: #2d3a52;
    color: var(--text-primary);
}
body[data-theme="b"] .btn-outline-secondary,
body[data-theme="b"] .btn-outline-primary,
body[data-theme="b"] .btn-outline-warning,
body[data-theme="b"] .btn-outline-danger,
body[data-theme="b"] .btn-outline-success {
    border-color: var(--border-default);
    color: var(--text-secondary);
    background: transparent;
}
body[data-theme="b"] .btn-outline-secondary:hover { background: var(--bg-sidebar-hover); color: var(--text-primary); }
body[data-theme="b"] .btn-outline-primary:hover  { background: var(--accent-50); color: var(--accent-700); border-color: var(--accent-500); }
body[data-theme="b"] .btn-outline-warning:hover  { background: var(--warning-50); color: var(--warning-500); border-color: var(--warning-500); }
body[data-theme="b"] .btn-outline-danger:hover   { background: var(--danger-50); color: var(--danger-500); border-color: var(--danger-500); }
body[data-theme="b"] .btn-outline-success:hover  { background: var(--success-50); color: var(--success-500); border-color: var(--success-500); }
body[data-theme="b"] a { color: var(--accent-700); }
body[data-theme="b"] a:hover { color: #f5d0a5; }

/* 알림 배너 */
body[data-theme="b"] .alert-info { background: rgba(125, 211, 252, 0.08); border-color: rgba(125, 211, 252, 0.25); color: #cbe7fb; }
body[data-theme="b"] .alert-warning { background: rgba(251, 191, 36, 0.08); border-color: rgba(251, 191, 36, 0.25); color: #fcd34d; }
body[data-theme="b"] .alert-danger { background: rgba(248, 113, 113, 0.08); border-color: rgba(248, 113, 113, 0.25); color: #fda4a4; }
body[data-theme="b"] .alert-success { background: rgba(110, 231, 183, 0.08); border-color: rgba(110, 231, 183, 0.25); color: #a7f3d0; }

/* Bootstrap badge 변형 — 다크 톤 */
body[data-theme="b"] .badge.bg-info-subtle    { background: rgba(125, 211, 252, 0.15) !important; color: #7dd3fc !important; }
body[data-theme="b"] .badge.bg-success-subtle { background: rgba(110, 231, 183, 0.15) !important; color: #6ee7b7 !important; }
body[data-theme="b"] .badge.bg-warning-subtle { background: rgba(251, 191, 36, 0.15) !important; color: #fbbf24 !important; }
body[data-theme="b"] .badge.bg-danger-subtle  { background: rgba(248, 113, 113, 0.15) !important; color: #f87171 !important; }
body[data-theme="b"] .badge.bg-primary-subtle { background: rgba(212, 165, 116, 0.15) !important; color: var(--accent-700) !important; }
body[data-theme="b"] .badge.bg-secondary-subtle { background: rgba(148, 163, 184, 0.18) !important; color: #cbd5e1 !important; }
body[data-theme="b"] .badge.bg-light          { background: rgba(255, 255, 255, 0.06) !important; color: var(--text-secondary) !important; }
body[data-theme="b"] .badge.bg-info-subtle.text-info-emphasis { color: #7dd3fc !important; }

/* 칩(필터) */
body[data-theme="b"] .chip {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
body[data-theme="b"] .chip:hover { border-color: var(--accent-500); color: var(--accent-700); }
body[data-theme="b"] .chip--active {
    background: rgba(212, 165, 116, 0.12);
    border-color: var(--accent-500);
    color: var(--accent-700);
}

/* KPI / 미수금 카드 — 인라인 hex 직접 쓰는 곳들 보정 */
body[data-theme="b"] .kpi-card {
    background: var(--bg-surface) !important;
    border-color: var(--border) !important;
    color: var(--text-primary);
}
body[data-theme="b"] .kpi-card--warning  { background: rgba(251, 191, 36, 0.08) !important; border-color: rgba(251, 191, 36, 0.30) !important; }
body[data-theme="b"] .kpi-card--warning .kpi-card__value { color: var(--warning-700) !important; }
body[data-theme="b"] .kpi-card--danger   { background: rgba(248, 113, 113, 0.08) !important; border-color: rgba(248, 113, 113, 0.30) !important; }
body[data-theme="b"] .kpi-card--danger .kpi-card__value  { color: var(--danger-700) !important; }
body[data-theme="b"] .kpi-card--imminent { background: rgba(251, 146, 60, 0.08) !important; border-color: rgba(251, 146, 60, 0.30) !important; }
body[data-theme="b"] .kpi-card--imminent .kpi-card__value { color: #fdba74 !important; }

/* Stat card */
body[data-theme="b"] .stat-card { background: var(--bg-surface); border-color: var(--border); }
body[data-theme="b"] .stat-card__icon--accent  { background: rgba(212, 165, 116, 0.15); color: var(--accent-700); }
body[data-theme="b"] .stat-card__icon--success { background: rgba(110, 231, 183, 0.15); color: var(--success-500); }
body[data-theme="b"] .stat-card__icon--danger  { background: rgba(248, 113, 113, 0.15); color: var(--danger-500); }
body[data-theme="b"] .stat-card__icon--warning { background: rgba(251, 191, 36, 0.15); color: var(--warning-500); }
body[data-theme="b"] .stat-card__value--success { color: var(--success-500); }
body[data-theme="b"] .stat-card__value--danger  { color: var(--danger-500); }

/* invoice/receivable 탭 — 라이트 hex 인라인 보정 */
body[data-theme="b"] .invoice-tabs,
body[data-theme="b"] .rcv-tabs { border-bottom-color: var(--border); }
body[data-theme="b"] .invoice-tabs .tab,
body[data-theme="b"] .rcv-tabs .tab { color: var(--text-muted); }
body[data-theme="b"] .invoice-tabs .tab:hover,
body[data-theme="b"] .rcv-tabs .tab:hover { background: var(--bg-sidebar-hover); color: var(--text-primary); }
body[data-theme="b"] .invoice-tabs .tab--active,
body[data-theme="b"] .rcv-tabs .tab--active {
    background: var(--bg-surface) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) var(--border) var(--bg-surface) var(--border) !important;
}
body[data-theme="b"] .invoice-tabs .tab__count,
body[data-theme="b"] .rcv-tabs .tab__count { background: rgba(255,255,255,0.08); color: var(--text-secondary); }
body[data-theme="b"] .invoice-tabs .tab--active .tab__count,
body[data-theme="b"] .rcv-tabs .tab--active .tab__count { background: var(--accent-600); color: #1a1408; }
body[data-theme="b"] .rcv-row--overdue  { background: rgba(248, 113, 113, 0.08) !important; }
body[data-theme="b"] .rcv-row--imminent { background: rgba(251, 191, 36, 0.07) !important; }
body[data-theme="b"] .rcv-row--future   { background: transparent !important; }

/* 텍스트 유틸리티 — 라이트 톤 보정 */
body[data-theme="b"] .text-muted   { color: var(--text-muted) !important; }
body[data-theme="b"] .text-success { color: var(--success-500) !important; }
body[data-theme="b"] .text-danger  { color: var(--danger-500) !important; }
body[data-theme="b"] .text-warning { color: var(--warning-500) !important; }
body[data-theme="b"] .text-primary-emphasis  { color: var(--accent-700) !important; }
body[data-theme="b"] .text-success-emphasis  { color: var(--success-500) !important; }
body[data-theme="b"] .text-info-emphasis     { color: #7dd3fc !important; }
body[data-theme="b"] .text-warning-emphasis  { color: var(--warning-500) !important; }
body[data-theme="b"] .text-danger-emphasis   { color: var(--danger-500) !important; }
body[data-theme="b"] .text-secondary-emphasis{ color: var(--text-secondary) !important; }

/* 진행률 바 */
body[data-theme="b"] .progress { background: rgba(255, 255, 255, 0.06); }
body[data-theme="b"] .progress-bar.bg-info    { background-color: #38bdf8 !important; }
body[data-theme="b"] .progress-bar.bg-success { background-color: var(--success-500) !important; }

/* 페이지 헤더 보조 텍스트 */
body[data-theme="b"] .page-header p,
body[data-theme="b"] .page-header__subtitle { color: var(--text-muted); }

/* 즐겨찾기 별표 */
body[data-theme="b"] .favorite-btn { color: var(--text-muted); }
body[data-theme="b"] .favorite-btn.is-starred { color: var(--accent-500); }


/* ====================================================================
   THEME C — Editorial Light · 크림 + 와인 액센트 + Fraunces 헤드라인
   ==================================================================== */
body[data-theme="c"] {
    --bg-app:           #fbf7f1;
    --bg-surface:       #ffffff;
    --bg-sidebar:       #2b1d12;
    --bg-sidebar-hover: rgba(255, 255, 255, 0.06);
    --bg-sidebar-active: rgba(214, 176, 130, 0.18);

    --border:         #e8ddc9;
    --border-subtle:  #efe5d2;
    --border-default: #d6c5a5;

    --accent-50:  rgba(107, 39, 55, 0.06);
    --accent-100: rgba(107, 39, 55, 0.12);
    --accent-500: #8b3a4d;
    --accent-600: #6b2737;
    --accent-700: #4f1c29;

    --text-primary:        #2b1d12;
    --text-secondary:      #5a4736;
    --text-muted:          #8a7763;

    --success-50:  #f0fdf4;
    --success-500: #15803d;
    --success-700: #166534;
    --danger-50:   rgba(127, 29, 29, 0.06);
    --danger-500:  #b91c1c;
    --danger-700:  #7f1d1d;
    --warning-50:  rgba(180, 83, 9, 0.06);
    --warning-500: #b45309;
    --warning-700: #78350f;

    --font-mono: 'JetBrains Mono', SFMono-Regular, Menlo, monospace;

    background:
        radial-gradient(900px 500px at 90% -10%, rgba(214, 176, 130, 0.18), transparent 60%),
        var(--bg-app);
    color: var(--text-primary);
}

body[data-theme="c"] h1,
body[data-theme="c"] h2,
body[data-theme="c"] h3,
body[data-theme="c"] h4,
body[data-theme="c"] .page-header h1,
body[data-theme="c"] .surface-card__title {
    font-family: 'Fraunces', Georgia, serif;
    letter-spacing: -0.015em;
    color: var(--text-primary);
}
body[data-theme="c"] .num,
body[data-theme="c"] .tabular-nums,
body[data-theme="c"] .mono {
    font-family: 'JetBrains Mono', SFMono-Regular, Menlo, monospace;
}

/* 사이드바 — 어두운 테라코타/모카 톤 */
body[data-theme="c"] .sidebar { background: var(--bg-sidebar); border-right: 1px solid #1f140d; }
body[data-theme="c"] .sidebar__brand-name {
    color: #f3ece1;
    font-family: 'Fraunces', Georgia, serif;
    font-weight: 700;
}
body[data-theme="c"] .sidebar__brand-sub {
    color: #d6b082;
    font-family: 'JetBrains Mono', SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-size: 0.7rem;
}
body[data-theme="c"] .sidebar__brand-icon {
    background: linear-gradient(135deg, #d6b082, #b58c5e);
    color: #2b1d12;
}
body[data-theme="c"] .sidebar__group-label {
    color: #d6b082;
    font-family: 'JetBrains Mono', SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}
body[data-theme="c"] .sidebar__link { color: rgba(243, 236, 225, 0.82); }
body[data-theme="c"] .sidebar__link:hover { background: var(--bg-sidebar-hover); color: #fff; }
body[data-theme="c"] .sidebar__link.is-active {
    background: var(--bg-sidebar-active);
    color: #f3d9b8;
}
body[data-theme="c"] .sidebar__link.is-active .sidebar__link-icon { color: #f3d9b8; }

/* 본문 카드 / 표 */
body[data-theme="c"] .surface-card {
    background: var(--bg-surface);
    border-color: var(--border);
    box-shadow: 0 1px 3px rgba(120, 83, 42, 0.04);
}
body[data-theme="c"] .surface-card__header { border-bottom-color: var(--border); }
body[data-theme="c"] .data-table thead th {
    background: #f3ece1;
    color: var(--text-secondary);
    border-bottom-color: var(--border);
    font-family: 'JetBrains Mono', SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.06em;
    font-size: 0.74rem;
    text-transform: uppercase;
}
body[data-theme="c"] .data-table tbody td { border-bottom-color: var(--border-subtle); color: var(--text-primary); }
body[data-theme="c"] .data-table--clickable tbody tr:hover { background: var(--accent-50) !important; }

/* 입력·버튼·링크 */
body[data-theme="c"] .form-control,
body[data-theme="c"] .form-select {
    background: #fffaf2;
    border-color: var(--border-default);
    color: var(--text-primary);
}
body[data-theme="c"] .form-control:focus,
body[data-theme="c"] .form-select:focus {
    background: #fff;
    border-color: var(--accent-500);
    box-shadow: 0 0 0 0.2rem rgba(139, 58, 77, 0.15);
    color: var(--text-primary);
}
body[data-theme="c"] .btn-primary {
    background: var(--accent-600);
    border-color: var(--accent-600);
    color: #fff;
    font-weight: 600;
}
body[data-theme="c"] .btn-primary:hover {
    background: var(--accent-700);
    border-color: var(--accent-700);
    color: #fff;
}
body[data-theme="c"] .btn-secondary {
    background: #d6b082;
    border-color: #b58c5e;
    color: #2b1d12;
}
body[data-theme="c"] a { color: var(--accent-600); }
body[data-theme="c"] a:hover { color: var(--accent-700); }

/* 칩 */
body[data-theme="c"] .chip {
    background: transparent;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
}
body[data-theme="c"] .chip:hover { border-color: var(--accent-500); color: var(--accent-600); }
body[data-theme="c"] .chip--active {
    background: var(--accent-50);
    border-color: var(--accent-500);
    color: var(--accent-700);
    font-weight: 600;
}

/* invoice/receivable 탭 */
body[data-theme="c"] .invoice-tabs,
body[data-theme="c"] .rcv-tabs { border-bottom-color: var(--border); }
body[data-theme="c"] .invoice-tabs .tab--active,
body[data-theme="c"] .rcv-tabs .tab--active {
    background: var(--bg-surface) !important;
    color: var(--accent-700) !important;
    border-color: var(--border) var(--border) var(--bg-surface) var(--border) !important;
}
body[data-theme="c"] .invoice-tabs .tab__count,
body[data-theme="c"] .rcv-tabs .tab__count { background: var(--border-subtle); color: var(--text-secondary); }
body[data-theme="c"] .invoice-tabs .tab--active .tab__count { background: var(--accent-600); color: #fff; }

/* 페이지 헤더 보조 텍스트 */
body[data-theme="c"] .page-header p,
body[data-theme="c"] .page-header__subtitle { color: var(--text-muted); }
body[data-theme="c"] .text-muted { color: var(--text-muted) !important; }

/* 페이지네이션 톤 */
body[data-theme="c"] .pager { box-shadow: 0 1px 3px rgba(120, 83, 42, 0.04); }


/* ====================================================================
   GDrive 첨부 카드 — rental-admin 패턴 차용
   ==================================================================== */
.gdrive-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 10px);
    margin-bottom: 16px;
    overflow: hidden;
}

/* 헤더 — 제목 + 부연설명 + 우측 [Drive 열기] [폴더 ID] */
.gdrive-card__header {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}
.gdrive-card__title {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.95rem; min-width: 0;
}
.gdrive-card__title .bi-google {
    color: #4285f4;        /* Google 브랜드 블루 */
    font-size: 1.1rem;
}
.gdrive-card__title .text-muted {
    font-size: 0.84rem; font-weight: 400;
}
.gdrive-card__sub {
    font-size: 0.7rem; padding: 2px 7px; margin-left: 4px;
    background: #e0e7ff; color: #3730a3; border-radius: 999px;
}
.gdrive-card__toolbar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.gdrive-card__toolbar .btn {
    font-size: 0.78rem; padding: 4px 10px;
}
.gdrive-card__folder-id { font-size: 0.74rem; }
.gdrive-card__folder-id code {
    background: #e2e8f0; padding: 1px 6px; border-radius: 3px;
    font-size: 0.74rem; color: #475569;
}

/* 본문 */
.gdrive-card__body { padding: 14px 16px; }

.gdrive-card__loading {
    text-align: center; padding: 14px; font-size: 0.85rem;
}

/* 파일 목록 영역 */
.gdrive-card__files-header {
    display: flex; align-items: center; gap: 6px;
    font-size: 0.86rem; color: var(--text-secondary);
    margin-bottom: 8px; padding: 0 2px;
}
.gdrive-card__files-header .bi-files { color: #f59e0b; }
.gdrive-card__count { font-family: var(--font-mono); }

/* 정렬 기준 선택 (수정요청 #343) */
.gdrive-card__sort-wrap {
    display: inline-flex; align-items: center; gap: 4px;
    margin-left: 6px; color: var(--text-muted); cursor: pointer;
}
.gdrive-card__sort {
    width: auto; padding: 1px 20px 1px 6px;
    font-size: 0.76rem; line-height: 1.5;
    background-position: right 4px center;
}

/* 테이블 */
.gdrive-files-table { font-size: 0.86rem; margin-bottom: 0; }
.gdrive-files-table__manage-col { width: 110px; }   /* 관리 열 — 인라인 width 대체(ui_check) */
.gdrive-files-table thead th {
    font-size: 0.7rem; padding: 6px 10px;
    background: #f8fafc; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.04em;
}
/* 셀 단위 border 가 일부 셀에서 끊어 보이는 증상 방지 — 행 단위 box-shadow 로 일관 라인 */
.gdrive-files-table tbody td {
    padding: 5px 10px;          /* 8px → 5px (행 간격 컴팩트) */
    vertical-align: middle;
    line-height: 1.3;
    border-bottom: 0;
    box-shadow: inset 0 -1px 0 var(--border-subtle, #e2e8f0);
}
.gdrive-files-table tbody tr:hover td { background: #f8fafc; }
.gdrive-files-table tbody tr:last-child td { box-shadow: none; }

/* td 는 table-cell 유지(행 구분선 정렬) — 아이콘+이름 정렬은 내부 wrapper 에서 flex */
.gdrive-files-table__name { min-width: 0; }
.gdrive-files-table__name-flex { display: flex; align-items: center; gap: 8px; min-width: 0; }
/* 폴더 행 이름(span) — 파일명(a)과 동일하게 한 줄 유지(세로 줄바꿈 방지, 수정요청 #330) */
.gdrive-files-table__name-flex > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gdrive-files-table__name i { font-size: 1.05rem; flex-shrink: 0; }
.gdrive-files-table__name a {
    color: var(--text-primary); text-decoration: none; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-size: 0.84rem;
}
.gdrive-files-table__name a:hover { color: #2563eb; text-decoration: underline; }
/* 폴더 이름(span) 도 파일명(a) 과 동일하게 한 줄 + 말줄임 — 좁은 열에서 한글이 세로로 쪼개지는 것 방지 (수정요청 #330) */
.gdrive-files-table__name-flex span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* 업로더·수정일 — 한 줄 가로 배치 (· 구분) */
.gdrive-files-table__meta {
    font-size: 0.74rem; line-height: 1.3; white-space: nowrap;
}
.gdrive-files-table__uploader::after {
    content: ' · '; opacity: 0.5; margin: 0 2px;
}
.gdrive-files-table__date { opacity: 0.85; }

/* 동작 버튼들 컴팩트 */
.gdrive-files-table .btn-sm {
    padding: 2px 6px;
    font-size: 0.78rem;
}

/* 체크박스 컬럼 */
.gdrive-files-table__check-col {
    width: 28px; padding-left: 8px; padding-right: 4px;
    text-align: center; vertical-align: middle;
}
.gdrive-card__check-row, .gdrive-card__check-all { cursor: pointer; }

/* 일괄 다운로드 바 (헤더 우측) */
.gdrive-card__files-header { display: flex; align-items: center; }
.gdrive-card__bulk { display: flex; gap: 6px; }
.gdrive-card__bulk .btn-sm {
    padding: 2px 8px; font-size: 0.78rem;
    display: inline-flex; align-items: center; gap: 4px;
}
.gdrive-card__bulk-count { font-family: var(--font-mono); }

/* bulk 다운로드 진행 상태 (압축중/받는중/완료) */
.gdrive-card__bulk-status {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 4px 10px;
    background: linear-gradient(90deg, #eff6ff, #f0fdfa);
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    font-size: 0.82rem; font-weight: 500;
    color: #1e40af;
    white-space: nowrap;
}
.gdrive-card__spin {
    display: inline-block;
    animation: gdrive-spin 0.9s linear infinite;
    color: #2563eb;
}
@keyframes gdrive-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* 첨부 유무 배지 — 목록 셀 안 (건명 옆) */
.att-badge {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 1px 6px;
    margin-left: 6px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    color: #1e40af;
    font-size: 0.72rem; font-weight: 500;
    line-height: 1.4;
    vertical-align: middle;
}
.att-badge .bi-paperclip { font-size: 0.78rem; opacity: 0.85; }

/* 로딩 — 노랑 강조 (잘 보이게) */
.gdrive-card__loading {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 14px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 8px;
    font-size: 0.86rem; font-weight: 500;
    color: #b45309;
    margin-bottom: 8px;
}
.gdrive-card__loading.is-slow {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

/* 빈 상태 */
.gdrive-card__empty {
    text-align: center; padding: 18px;
    background: #f8fafc; border: 1px dashed var(--border);
    border-radius: 8px;
    font-size: 0.88rem; color: var(--text-muted);
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.gdrive-card__empty .bi { font-size: 1.1rem; opacity: 0.6; }

/* 본문 좌우 분할 — 좌(파일 목록 7) / 우(업로드 박스 5) */
.gdrive-card__split {
    /* 파일 목록 위(전체폭) · 업로드 박스 아래로 세로 배치 — 좌우 폭 협소 해소(수정요청) */
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    align-items: start;
}
.gdrive-card__split-left { min-width: 0; }
.gdrive-card__split-right { min-width: 0; }

@media (max-width: 900px) {
    .gdrive-card__split {
        grid-template-columns: 1fr;
    }
}

/* ── 컴팩트 모드 (att_compact=True) — 드롭존 축소·좌우 폭 조정 ── */
.attachments-box--compact .gdrive-card__split {
    grid-template-columns: 1fr;
    gap: 10px;
}
.attachments-box--compact .gdrive-upload { padding: 8px 10px; }
.attachments-box--compact .gdrive-upload__icon,
.attachments-box--compact .gdrive-upload__title,
.attachments-box--compact .gdrive-upload__hint,
.attachments-box--compact .gdrive-upload__footer { display: none; }
.attachments-box--compact .gdrive-card__dropzone { padding: 12px 10px; }
.attachments-box--compact .gdrive-card__dropzone i { font-size: 1.2rem; }
.attachments-box--compact .gdrive-card__dropzone-text { font-size: 0.8rem; }
.attachments-box--compact .gdrive-upload__pick-btn { padding: 5px 10px; font-size: 0.82rem; }
.attachments-box--compact .gdrive-card__empty { padding: 14px 8px; min-height: 0; }
.attachments-box--compact .gdrive-card__loading { min-height: 0; padding: 12px; }

/* 우측: 업로드 박스 — 그라데이션 + 입체감 */
.gdrive-upload {
    background: linear-gradient(135deg, #f0f7ff 0%, #e6f0ff 100%);
    border: 1px solid #bfdbfe;
    border-radius: 12px;
    padding: 18px 16px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.06);
}
.gdrive-upload__icon {
    width: 48px; height: 48px;
    margin: 0 auto 8px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}
.gdrive-upload__title {
    font-size: 1rem; font-weight: 700;
    color: #1e3a8a; margin-bottom: 2px;
}
.gdrive-upload__hint {
    font-size: 0.74rem; color: #64748b; margin-bottom: 14px;
}
.gdrive-upload__pick-btn {
    width: 100%; margin-top: 10px;
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(37, 99, 235, 0.2);
}
.gdrive-upload__pick-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(37, 99, 235, 0.3);
}
.gdrive-upload__footer {
    margin-top: 12px;
    font-size: 0.7rem;
    padding-top: 8px;
    border-top: 1px dashed rgba(59, 130, 246, 0.2);
}

/* 드롭존 — 업로드 박스 안 */
.gdrive-card__dropzone {
    padding: 14px 12px; text-align: center;
    background: rgba(255, 255, 255, 0.7);
    border: 2px dashed #93c5fd;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
}
.gdrive-card__dropzone:hover { background: #fff; border-color: #2563eb; }
.gdrive-card__dropzone.is-dragover {
    background: #dbeafe; border-color: #1d4ed8;
    transform: scale(1.02);
    box-shadow: inset 0 0 0 2px rgba(29, 78, 216, 0.15);
}
.gdrive-card__dropzone:focus { outline: 2px solid #2563eb; outline-offset: 2px; }
.gdrive-card__dropzone i {
    font-size: 1.4rem; color: #2563eb; display: block; margin-bottom: 4px;
    opacity: 0.85;
}
.gdrive-card__dropzone-text {
    font-size: 0.84rem; color: #1e3a8a; font-weight: 500;
}
.gdrive-card__pick-link {
    color: #2563eb; font-weight: 600; text-decoration: underline; cursor: pointer;
}
.gdrive-card__dropzone-hint {
    font-size: 0.72rem; color: #64748b; margin-top: 2px;
}

/* 권한 없음 */
.gdrive-card__no-perm {
    padding: 18px 14px;
    background: #f1f5f9; border: 1px dashed var(--border-subtle, #e2e8f0);
    border-radius: 12px;
    font-size: 0.86rem; color: var(--text-muted);
    text-align: center;
    line-height: 1.5;
}
.gdrive-card__no-perm i { font-size: 1.4rem; opacity: 0.5; display: block; margin-bottom: 6px; }

/* 진행률 */
.gdrive-card__progress {
    margin-top: 10px;
    background: rgba(255, 255, 255, 0.8); border: 1px solid #bfdbfe;
    border-radius: 8px; padding: 8px 12px;
}
.gdrive-card__progress-bar {
    height: 5px; background: linear-gradient(90deg, #2563eb, #3b82f6);
    border-radius: 999px;
    width: 0%; transition: width 0.3s ease;
    margin-bottom: 4px;
}
.gdrive-card__progress-text { font-size: 0.74rem; color: #1e3a8a; }

/* OCR 결과 모달 */
.gdrive-ocr-modal-backdrop {
    position: fixed; inset: 0; z-index: 1080;
    background: rgba(15, 23, 42, 0.55);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    animation: ocrFadeIn 0.15s ease-out;
}
.gdrive-ocr-modal {
    background: #fff; border-radius: 14px;
    width: 100%; max-width: 540px; max-height: 90vh;
    overflow: hidden; display: flex; flex-direction: column;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.25);
    animation: ocrSlideUp 0.2s ease-out;
}
@keyframes ocrFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes ocrSlideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.gdrive-ocr-modal__header {
    display: flex; align-items: center; gap: 8px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(90deg, #fffbeb 0%, #fff 100%);
    font-size: 0.95rem;
}
.gdrive-ocr-modal__header strong {
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gdrive-ocr-modal__close {
    background: transparent; border: 0; color: #64748b;
    font-size: 1.2rem; cursor: pointer; padding: 0 6px;
    line-height: 1;
}
.gdrive-ocr-modal__close:hover { color: var(--text-primary); }
.gdrive-ocr-modal__body {
    padding: 8px 14px; flex: 1; overflow: auto;
}
.gdrive-ocr-modal__body table th { border-bottom: 1px solid #f1f5f9; }
.gdrive-ocr-modal__body table td { border-bottom: 1px solid #f1f5f9; }
.gdrive-ocr-modal__footer {
    display: flex; gap: 8px; justify-content: flex-end;
    padding: 12px 18px; border-top: 1px solid var(--border);
    background: #f8fafc;
}

/* OCR 적용 시 input 강조 (1.5초) */
.gdrive-ocr-applied {
    background-color: #fef3c7 !important;
    box-shadow: 0 0 0 2px #fbbf24;
    transition: all 0.4s ease-out;
}

/* 다크 테마 (B) */
body[data-theme="b"] .gdrive-card { background: var(--bg-surface); border-color: var(--border); }
body[data-theme="b"] .gdrive-card__header { background: rgba(255,255,255,0.03); }
body[data-theme="b"] .gdrive-card__folder-id code { background: rgba(255,255,255,0.06); color: var(--text-secondary); }
body[data-theme="b"] .gdrive-ocr-modal { background: var(--bg-surface); }
body[data-theme="b"] .gdrive-ocr-modal__header { background: rgba(245, 158, 11, 0.08); }
body[data-theme="b"] .gdrive-ocr-modal__footer { background: rgba(255,255,255,0.02); }
body[data-theme="b"] .gdrive-files-table thead th { background: rgba(255,255,255,0.02); }
body[data-theme="b"] .gdrive-files-table tbody tr:hover { background: rgba(255,255,255,0.04); }
body[data-theme="b"] .gdrive-card__empty,
body[data-theme="b"] .gdrive-card__no-perm { background: rgba(255,255,255,0.02); }
body[data-theme="b"] .gdrive-card__dropzone { background: rgba(255,255,255,0.02); border-color: var(--border); }
body[data-theme="b"] .gdrive-card__dropzone:hover { background: rgba(59,130,246,0.08); }

/* ── 대시보드 — 최근 영업이력 표 (컴팩트) ── */
.recent-logs-table thead th { padding: 9px 14px; font-size: 0.72rem; }
.recent-logs-table tbody td {
    padding: 8px 14px;
    line-height: 1.35;
    vertical-align: middle;
}
.recent-logs-table tbody td strong { line-height: 1.3; }
.recent-logs-table tbody td > .text-muted {
    font-size: 0.76rem !important;
    margin-top: 1px !important;
    line-height: 1.3;
}
.recent-logs__client {
    color: var(--text-secondary); font-size: 0.82rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    max-width: 140px;
}
.recent-logs-table .recent-logs__th-meta {
    font-size: 0.7rem; letter-spacing: 0.02em; white-space: nowrap;
}
.recent-logs__date {
    font-size: 0.73rem !important;
    color: var(--text-muted); white-space: nowrap; line-height: 1.25;
}
.recent-logs__no { font-size: 0.77rem !important; white-space: nowrap; }
.recent-logs__no a { font-weight: 500; }
.recent-logs__sp {
    font-size: 0.81rem; color: var(--text-secondary); white-space: nowrap;
}

/* ───────── 비-시간순 리스트 페이지 공용 chip 필터 ─────────
   고객사·LED단가·프로젝트 등 시간순이 아닌 리스트의 둥근 pill 버튼 필터.
   시간순(인바운드·계약·견적·세금계산서)은 .timeline-tabs 사용. */
.period-chips {
    display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.83rem;
}
.period-chips__label { color: var(--text-muted); font-weight: 500; }
.period-chips .chip {
    padding: 4px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--border);
    color: var(--text-primary); cursor: pointer; transition: all 0.15s; white-space: nowrap;
    font-size: 0.83rem; text-decoration: none;
}
.period-chips .chip:hover { background: #eff6ff; border-color: #93c5fd; }
.period-chips .chip--active {
    background: #2563eb; border-color: #2563eb; color: #fff; font-weight: 600;
}
.period-chips .chip--active:hover { background: #1e40af; border-color: #1e40af; color: #fff; }
.period-chips .chip__count {
    display: inline-block; margin-left: 4px; font-size: 0.74rem; padding: 0 6px;
    background: rgba(0,0,0,0.06); color: inherit; border-radius: 999px; font-weight: 600;
}
.period-chips .chip--active .chip__count { background: rgba(255,255,255,0.25); color: #fff; }

/* ───────── 시간순(timeline) 리스트 페이지 공용 탭 ─────────
   인바운드/계약/견적서/세금계산서 등 시간순으로 진행되는 리스트의 상단 상태 탭. */
.timeline-tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); flex-wrap: wrap; }
.timeline-tabs .tab {
    padding: 8px 14px; text-decoration: none; color: var(--text-muted);
    border: 1px solid transparent; border-bottom: none; border-radius: 8px 8px 0 0;
    font-size: 0.88rem; font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
    margin-bottom: -2px;
}
.timeline-tabs .tab:hover { background: #f1f5f9; color: var(--text-primary); }
.timeline-tabs .tab--active {
    background: #fff; color: var(--text-primary); font-weight: 700;
    border-color: var(--border) var(--border) #fff var(--border);
}
.timeline-tabs .tab__count {
    font-size: 0.74rem; padding: 1px 7px; background: #e2e8f0; color: #475569;
    border-radius: 999px; font-weight: 600;
}
.timeline-tabs .tab--active .tab__count { background: #2563eb; color: #fff; }

/* ====================================================================
   영업업체 표시 — 발주처(고객사) 아래 둘째 줄. 프로젝트/계약 목록 공통.
   form.html dual-section--partner 와 주황 톤 일치.
   ==================================================================== */
.partner-client {
    margin-top: 2px;
    font-size: 0.78rem;
    color: #92400e;
    line-height: 1.3;
}
.partner-client__label {
    font-weight: 600;
    margin-right: 3px;
    color: #b45309;
}
.partner-client a {
    color: inherit;
    text-decoration: none;
}
.partner-client a:hover {
    text-decoration: underline;
}
.partner-client__pct {
    color: var(--text-muted, #64748b);
    font-size: 0.72rem;
    margin-left: 4px;
}

/* 사이드바 아코디언 서브그룹 — 관리 메뉴 등에서 사용 */
.sidebar__subgroup-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: transparent;
    border: 0;
    color: var(--text-on-dark, #cbd5e1);
    border-radius: var(--radius-sm, 6px);
    font-size: 0.86rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-fast, 0.12s);
    padding: 4px 12px;       /* 7px → 4px (관리 4개 메인메뉴 행간 축소) */
}
.sidebar__subgroup-toggle:hover {
    background: var(--bg-sidebar-hover, rgba(255,255,255,0.05));
    color: #fff;
}
.sidebar__subgroup-caret {
    font-size: 0.78rem;
    color: var(--text-on-dark-muted, #94a3b8);
    transition: transform var(--transition-fast, 0.12s);
    width: 14px;
    flex-shrink: 0;
}
.sidebar__subgroup-toggle.is-open .sidebar__subgroup-caret {
    transform: rotate(90deg);
}
.sidebar__subgroup-content {
    display: flex;
    flex-direction: column;
    gap: 1px;                 /* 2px → 1px */
    padding: 1px 0 4px 24px;  /* 들여쓰기 — caret + icon 만큼 (상하 여백 축소) */
}
.sidebar__link--sub {
    font-size: 0.82rem;
    padding: 3px 10px;        /* 6px → 3px (관리 서브메뉴 행간 축소) */
}

/* 사이드바 도메인 그룹 헤더 (접기 가능 · 다중 펼침) — 영업/유통영업/제품·자재/현장·AS/경영지원 */
.sidebar__group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: transparent;
    border: 0;
    cursor: pointer;
    /* group-label 과 동일 톤 (라이트블루 대문자 라벨) */
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #93c5fd;
    font-weight: 700;
    text-align: left;
    padding: 12px 12px 4px;
    transition: color var(--transition-fast, 0.12s);
}
.sidebar__group-toggle:hover { color: #dbeafe; }
.sidebar__group-caret {
    font-size: 0.7rem;
    color: var(--text-on-dark-muted, #94a3b8);
    transition: transform var(--transition-fast, 0.12s);
    flex-shrink: 0;
}
.sidebar__group-toggle.is-open .sidebar__group-caret { transform: rotate(90deg); }
.sidebar__group-content { display: flex; flex-direction: column; }
/* 테마 b/c — group-label 과 동일하게 맞춤 */
body[data-theme="b"] .sidebar__group-toggle {
    color: var(--accent-500);
    font-family: 'JetBrains Mono', SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.16em;
}
body[data-theme="c"] .sidebar__group-toggle {
    color: #d6b082;
    font-family: 'JetBrains Mono', SFMono-Regular, Menlo, monospace;
    letter-spacing: 0.16em;
}

/* 조달청계약 표시 — 계약/세금계산서 목록 등에서 프로젝트번호 옆에 작게 */
.g2b-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    margin-left: 4px;
    vertical-align: middle;
    white-space: nowrap;
}

/* ====================================================================
   Mobile responsive — 768px 이하 (핸드폰).
   Phase A: 공통 인프라 (사이드바 햄버거, 패딩, 터치, 폼).
   Phase B: 프로젝트 목록 카드 뷰 (data-table--mobile-card).
   ==================================================================== */

/* 햄버거 버튼 — 데스크탑 숨김, 모바일 표시 */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 36px);
    left: 10px;
    z-index: 9999;
    width: 42px; height: 42px;
    border: 1px solid var(--border, #cbd5e1);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    font-size: 1.4rem;
    color: var(--text-primary, #1e293b);
    cursor: pointer;
    align-items: center; justify-content: center;
}
.mobile-sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 9000;
    opacity: 0;
    transition: opacity 0.18s ease;
}
.mobile-sidebar-backdrop.is-open {
    opacity: 1;
}

/* 검색 하이라이트 — search-highlight.js 가 ?q 단어를 <mark class="search-hl"> 로 감쌈 (전역) */
.search-hl { background: #fff176; color: inherit; padding: 0 1px; border-radius: 2px; }

/* 모바일 상세 — 수정/삭제 액션을 본문 하단으로 (mobile-detail-actions.js 가 생성) */
.mobile-detail-actions { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border-subtle, #eef2f7);
    display: flex; flex-direction: column; gap: 8px; }
.mobile-detail-actions .js-mobile-actions-bottom { display: flex; gap: 8px; flex-wrap: wrap; }
.mobile-detail-actions form { margin: 0; flex: 1 1 40%; display: flex; }
.mobile-detail-actions .btn { flex: 1 1 40%; justify-content: center; padding: 11px 8px; font-size: 0.95rem; }
.mobile-detail-actions form .btn { flex: 1; width: 100%; }

@media (max-width: 768px) {
    /* env-strip 압축 — hint 숨기고 라벨만 */
    .env-strip { padding: 3px 8px; font-size: 0.7rem; }
    .env-strip__hint { display: none; }

    /* 햄버거 + backdrop 활성 */
    .mobile-menu-toggle { display: flex; }
    /* 사이드바 열렸을 때 — 햄버거 숨김(브랜드 로고 가림 방지). 닫기는 backdrop 탭 / 링크 클릭 */
    body.mobile-sidebar-open .mobile-menu-toggle { display: none; }
    .mobile-sidebar-backdrop.is-open { display: block; }

    /* 사이드바 — 화면 밖에서 슬라이드 인 */
    .sidebar {
        position: fixed;
        top: 0; left: 0;
        height: 100vh; height: 100dvh;
        width: 260px;
        z-index: 9500;
        transform: translateX(-100%);
        transition: transform 0.22s ease;
        box-shadow: 4px 0 16px rgba(0,0,0,0.18);
    }
    .sidebar.is-open { transform: translateX(0); }

    /* body 스크롤 잠금 (사이드바 열렸을 때) */
    body.mobile-sidebar-open { overflow: hidden; }

    /* 메인 — 사이드바 차지하던 공간 회수, 패딩 축소, 햄버거 공간 확보 */
    .app-main {
        padding: 56px 12px 16px;
        max-width: 100%;
    }
    .app-shell--no-sidebar .app-main {
        padding-left: 12px; padding-right: 12px;
    }
    /* 햄버거 없는 페이지(상세 등 — {% block mobile_menu %} 비움)는 상단 빈 여백 제거 */
    body:not(:has(.mobile-menu-toggle)) .app-main { padding-top: 14px; }

    /* 페이지 헤더 — 모바일 폰트 축소 */
    .page-header h1 { font-size: 1.25rem !important; }
    .page-header { flex-wrap: wrap; gap: 8px; }

    /* 입력 폼 — iOS 자동 줌 방지 (16px 이상) */
    input.form-control,
    select.form-select,
    textarea.form-control {
        font-size: 16px;
    }

    /* 터치 타겟 — sm 버튼도 모바일에서 충분히 크게 */
    .btn-sm {
        padding: 6px 10px;
        min-height: 36px;
        min-width: 36px;
    }
    .btn {
        min-height: 40px;
    }

    /* 테이블 — 모바일에선 폰트·간격 축소 */
    .data-table { font-size: 0.82rem; }
    .data-table th, .data-table td { padding: 8px 6px; }

    /* 일보 목록 — 모바일에선 상세 필터(출처/프로젝트/상태) 숨김. 검색만. (#9) */
    .jl-adv-filter { display: none !important; }

    /* 필터 칩 row — 줄바꿈 허용 */
    .filter-row { flex-wrap: wrap; gap: 8px; }

    /* 페이지네이션 등 보조 영역 */
    .pagination { flex-wrap: wrap; }
}

/* ====================================================================
   Phase B — 데이터 테이블 모바일 카드 뷰
   대상: .data-table--mobile-card 클래스가 붙은 테이블만 변환.
   각 <td> 는 data-label 속성으로 라벨 표시 (생략 시 라벨 없음).
   ==================================================================== */
@media (max-width: 768px) {
    .data-table--mobile-card,
    .data-table--mobile-card thead,
    .data-table--mobile-card tbody,
    .data-table--mobile-card tr,
    .data-table--mobile-card td {
        display: block;
        width: 100%;
    }
    .data-table--mobile-card thead {
        display: none; /* 컬럼 헤더 숨김 — 각 td 가 자체 라벨 표시 */
    }
    .data-table--mobile-card tbody tr {
        border: 1px solid var(--border, #e2e8f0);
        border-radius: 10px;
        margin-bottom: 10px;
        padding: 10px 12px;
        background: #fff;
        box-shadow: 0 1px 2px rgba(0,0,0,0.04);
        position: relative;
    }
    .data-table--mobile-card tbody tr.project-row--contracted {
        border-left: 4px solid #10b981;
    }
    .data-table--mobile-card td {
        border: none !important;
        padding: 3px 0 !important;
        text-align: left !important;
    }
    /* 라벨|값 을 flex 로 — 값(제목 등)이 길어 줄바꿈돼도 라벨 아래로 흐르지 않고 값 칸 안에서 정렬 */
    .data-table--mobile-card td[data-label] {
        display: flex;
        align-items: baseline;
        gap: 8px;
    }
    .data-table--mobile-card td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 64px;
        font-size: 0.72rem;
        font-weight: 600;
        color: var(--text-muted, #64748b);
        white-space: nowrap;
    }
    /* 값 영역 — 남은 폭 차지 + 내부에서만 줄바꿈 */
    .data-table--mobile-card td[data-label] > * { min-width: 0; }
    /* 라벨 없는 td — 인라인 표시 (체크박스/화살표/★/관리 버튼 등) */
    .data-table--mobile-card td:not([data-label]) {
        display: inline-block;
        width: auto;
        padding: 0 4px !important;
        vertical-align: middle;
    }
    /* 펼침 행 (project-detail-row) — 카드 폭 풀로 사용, td colspan 무시 */
    .data-table--mobile-card tr.project-detail-row {
        padding: 0;
        margin-top: -10px;
        margin-bottom: 10px;
        background: #f8fafc;
        border-top: 0;
        border-radius: 0 0 10px 10px;
    }
    .data-table--mobile-card tr.project-detail-row td {
        padding: 10px !important;
    }
    /* 카드 내 chevron caret — 모바일에선 의미 약함, 숨김 */
    .data-table--mobile-card .project-row__caret { display: none; }
    /* 모바일 카드에서만 숨길 셀 (예: 일보 목록 출처·프로젝트번호 — PC 는 유지) */
    .data-table--mobile-card td.jl-hide-mobile,
    .data-table--mobile-card th.jl-hide-mobile { display: none !important; }
}


/* ── 일보 첨부 컴포넌트 (cr-attach.js, 신규/수정 공통) ── */
.cr-attach-drop { border: 2px dashed var(--border, #cbd5e1); border-radius: 10px; padding: 14px; transition: background .15s, border-color .15s; }
.cr-attach-drop.is-over { background: #eff6ff; border-color: #2563eb; }
.cr-attach-drop__hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 10px; text-align: center; }
.cr-attach-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 10px; }
.cr-attach-preview:empty { display: none; }
.cr-attach-cell { position: relative; border: 1px solid var(--border, #e2e8f0); border-radius: 6px; padding: 6px; background: #fff; }
.cr-attach-thumb { height: 90px; border-radius: 4px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #f1f5f9; }
.cr-attach-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cr-attach-thumb--video { background: #000; color: #fff; }
.cr-attach-thumb--video i { color: #fff; }
.cr-attach-thumb i { font-size: 2rem; color: #94a3b8; }
.cr-attach-rm { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; padding: 0; border: none; border-radius: 50%; background: rgba(220,38,38,0.92); color: #fff; cursor: pointer; font-size: 0.8rem; line-height: 1; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.cr-attach-name { font-size: 0.7rem; margin-top: 4px; word-break: break-all; color: var(--text-muted); }

/* ── Pixelhue 영업보호 (protection) ── */
.prot-chip { display:inline-flex; align-items:center; gap:5px; padding:5px 12px; border-radius:16px; font-size:0.82rem; text-decoration:none; background:var(--surface-2, #f1f5f9); color:var(--text-secondary, #475569); border:1px solid var(--border); }
.prot-chip.is-active { background:#2563eb; color:#fff; border-color:#2563eb; }
.prot-chip strong { font-weight:700; }
.prot-field { width:100%; height:36px; padding:0 10px; border:1px solid var(--border); border-radius:6px; font-size:0.92rem; background:var(--surface, #fff); color:var(--text-primary); }  /* 폼 높이 표준 36px (2026-07-20) */
textarea.prot-field { height:auto; min-height:76px; padding:8px 10px; }
select.prot-field[multiple] { height:auto; }
.prot-label { font-size:0.85rem; font-weight:600; color:var(--text-muted); display:block; margin-bottom:6px; }
.prot-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(220px, 1fr)); gap:14px; }
.prot-info dt { font-size:0.78rem; color:var(--text-muted); margin-bottom:2px; }
.prot-info dd { font-size:0.95rem; margin:0 0 12px; color:var(--text-primary); }

/* ── 유통영업 B/O 폼 추가 (고객사 typeahead · 필요장비 멀티행) ── */
.prot-client { position: relative; }
.prot-client-results { position: absolute; z-index: 40; left: 0; right: 0; top: 100%; background: var(--surface, #fff); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,0.1); max-height: 260px; overflow-y: auto; margin-top: 2px; }
.prot-client-item { padding: 7px 12px; font-size: 0.9rem; cursor: pointer; }
.prot-client-item:hover { background: var(--surface-2, #f1f5f9); }
.eq-row { display: grid; grid-template-columns: 1fr 1fr 90px 36px; gap: 8px; align-items: center; margin-bottom: 8px; }
.eq-del { border: 1px solid var(--border); background: var(--surface, #fff); color: #dc2626; border-radius: 6px; height: 38px; cursor: pointer; font-size: 1rem; line-height: 1; }
.eq-del:hover { background: #fef2f2; }
.eq-head { display: grid; grid-template-columns: 1fr 1fr 90px 36px; gap: 8px; font-size: 0.78rem; color: var(--text-muted); margin-bottom: 4px; padding: 0 2px; }

/* typeahead 드롭다운이 surface-card(overflow:hidden)에 잘리지 않도록 — 업체검색 카드 전용 */
.surface-card.allow-pop { overflow: visible; }
.prot-client-results { z-index: 60; }

/* B/O 필요장비 모델 typeahead (견적품목 검색) */
.eq-prod { position: relative; }
.eq-prod-results { position: absolute; z-index: 60; left: 0; right: 0; top: 100%; background: var(--surface, #fff); border: 1px solid var(--border); border-radius: 6px; box-shadow: 0 4px 14px rgba(0,0,0,0.1); max-height: 240px; overflow-y: auto; margin-top: 2px; }
.eq-prod-item { padding: 7px 10px; font-size: 0.85rem; cursor: pointer; }
.eq-prod-item:hover { background: var(--surface-2, #f1f5f9); }

/* ====================================================================
   ⌘K 전역 검색 (커맨드 팔레트) — 2026-07-20
   토큰 변수만 사용 → A/B/C 테마 자동 대응 (CONVENTIONS §2)
   ==================================================================== */
.cmdk-overlay {
    position: fixed; inset: 0; z-index: 1100;
    display: none;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
    padding: 12vh 16px 0;
}
.cmdk-overlay.is-open { display: flex; justify-content: center; align-items: flex-start; }
body.cmdk-open { overflow: hidden; }

.cmdk {
    width: 100%; max-width: 640px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: cmdk-in 140ms ease;
}
@keyframes cmdk-in {
    from { opacity: 0; transform: translateY(-8px) scale(0.99); }
    to   { opacity: 1; transform: none; }
}
.cmdk__head {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
}
.cmdk__head .bi-search { color: var(--text-muted); }
.cmdk__input {
    flex: 1; border: 0; outline: 0; background: transparent;
    font-size: 1rem; color: var(--text-primary);
}
.cmdk__input::placeholder { color: var(--text-muted); }
.cmdk__kbd {
    font-family: var(--font-mono); font-size: 0.68rem;
    color: var(--text-muted);
    border: 1px solid var(--border-default);
    border-radius: 5px; padding: 2px 6px; white-space: nowrap;
}
.cmdk__list { max-height: 55vh; overflow-y: auto; padding: 6px; }
.cmdk__group-label {
    font-size: 0.7rem; font-weight: 700; color: var(--text-muted);
    padding: 10px 12px 4px; letter-spacing: 0.02em;
}
.cmdk__item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 12px; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 0.9rem;
}
.cmdk__item.is-active { background: var(--accent-50); }
.cmdk__item.is-active .cmdk__item-title { color: var(--accent-700); }
.cmdk__item-icon { color: var(--text-muted); font-size: 0.95rem; flex-shrink: 0; }
.cmdk__item-title {
    color: var(--text-primary); font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cmdk__item-sub {
    margin-left: auto; padding-left: 12px;
    color: var(--text-muted); font-size: 0.76rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 45%; flex-shrink: 0;
}
.cmdk__empty {
    text-align: center; color: var(--text-muted);
    padding: 28px 0; font-size: 0.88rem;
}

/* 사이드바 트리거 버튼 — 어두운 사이드바 위 반투명 */
.sidebar__search-btn {
    display: flex; align-items: center; gap: 8px;
    margin: 0 12px 10px; padding: 7px 10px;
    border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.75); font-size: 0.8rem;
    cursor: pointer; width: calc(100% - 24px);
}
.sidebar__search-btn:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.sidebar__search-btn .cmdk__kbd {
    margin-left: auto; border-color: rgba(255, 255, 255, 0.25); color: inherit;
}
/* 상단바 레이아웃용 트리거 */
.topnav__search-btn {
    display: flex; align-items: center; gap: 7px;
    padding: 6px 10px; border-radius: 8px;
    border: 1px solid var(--border-default);
    background: transparent; color: var(--text-muted);
    font-size: 0.82rem; cursor: pointer;
}
.topnav__search-btn:hover { color: var(--text-primary); }
