/* =============================================================================
   Cosmetic MS · Refined Luxury Dark Admin
   ============================================================================= */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable.css');
@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    /* Deeper, richer blacks */
    --bg-app:        #08080a;
    --bg-sidebar:    #050507;
    --bg-topbar:     rgba(10, 10, 13, 0.72);
    --bg-surface:    #101014;
    --bg-surface-2:  #16161c;
    --bg-hover:      #1a1a21;

    /* Hairline borders */
    --border:        #1c1c22;
    --border-strong: #2a2a33;
    --hairline:      rgba(201, 167, 105, 0.10);
    --hairline-hi:   rgba(201, 167, 105, 0.22);

    /* Text tuned for dark */
    --text:          #d6d6da;
    --text-strong:   #f5f5f7;
    --text-muted:    #7a7a83;
    --text-dim:      #4a4a52;

    /* Champagne gold, three variants */
    --gold:          #c9a769;
    --gold-hi:       #e0c087;
    --gold-lo:       #8a7040;
    --gold-soft:     rgba(201, 167, 105, 0.10);
    --gold-glow:     rgba(201, 167, 105, 0.30);

    /* Semantic (muted) */
    --success:       #7bc99e;
    --success-soft:  rgba(123, 201, 158, 0.10);
    --danger:        #d4736e;
    --danger-soft:   rgba(212, 115, 110, 0.10);
    --warning:       #d4a05a;
    --info:          #7d9dc7;

    --radius:        4px;
    --radius-lg:     8px;
    --shadow-sm:     0 1px 2px rgba(0,0,0,.5);
    --shadow:        0 8px 24px rgba(0,0,0,.4);
    --shadow-lg:     0 20px 60px rgba(0,0,0,.55),
                     0 0 0 1px rgba(201, 167, 105, 0.06);

    --sidebar-w:     264px;
    --topbar-h:      64px;

    --font-serif:    'Cormorant Garamond', 'Noto Serif KR', serif;
    --font-sans:     'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono:     'JetBrains Mono', 'SF Mono', Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

body {
    font-family: var(--font-sans);
    font-size: 13px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg-app);
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, rgba(201, 167, 105, 0.05), transparent),
        radial-gradient(ellipse 60% 50% at 100% 100%, rgba(201, 167, 105, 0.03), transparent);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.005em;
    font-weight: 400;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; border: 2px solid var(--bg-app); }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

a { color: var(--gold); text-decoration: none; transition: color .2s; }
a:hover { color: var(--gold-hi); }

h1, h2, h3, h4 { margin: 0; color: var(--text-strong); font-weight: 500; letter-spacing: -0.02em; }
h1 { font-size: 22px; font-weight: 400; letter-spacing: -0.03em; }
h2 { font-size: 16px; }
h3 {
    font-size: 10px;
    font-weight: 600;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.22em;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--hairline);
}

/* =============================================================================
   App shell
   ============================================================================= */
.app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas: "sidebar topbar" "sidebar main";
    min-height: 100vh;
}

/* =============================================================================
   Sidebar (depth 3: section > group > leaf)
   ============================================================================= */
aside.sidebar {
    grid-area: sidebar;
    background:
        linear-gradient(180deg, #06060900 0%, var(--bg-sidebar) 40%),
        var(--bg-sidebar);
    border-right: 1px solid var(--hairline);
    padding: 0 0 24px;
    overflow-y: auto;
    position: sticky;
    top: 0;
    height: 100vh;
}

/* Brand */
.brand {
    display: flex;
    align-items: center;
    height: var(--topbar-h);
    padding: 0 24px;
    gap: 14px;
    border-bottom: 1px solid var(--hairline);
    position: relative;
    text-decoration: none;
    color: inherit;
    transition: opacity .2s;
}
.brand:hover { opacity: 0.85; text-decoration: none; }
.brand::after {
    content: "";
    position: absolute;
    left: 24px; right: 24px; bottom: -1px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--hairline-hi) 30%, var(--hairline-hi) 70%, transparent);
}
.brand-mark {
    width: 34px; height: 34px;
    border-radius: 3px;
    background:
        linear-gradient(135deg, var(--gold-hi) 0%, var(--gold-lo) 100%),
        var(--gold);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: 22px;
    color: #0a0a0d;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.35),
        inset 0 -1px 0 rgba(0,0,0,0.3),
        0 0 24px rgba(201, 167, 105, 0.2);
    letter-spacing: -0.02em;
    line-height: 1;
    padding-top: 2px;
}
.brand-name {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: 20px;
    color: var(--text-strong);
    letter-spacing: 0;
    line-height: 1;
    margin-bottom: 3px;
}
.brand-sub {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.32em;
    font-weight: 500;
}

/* Nav */
.sidebar nav { padding: 20px 0 40px; }
.nav-section { padding: 12px 20px 4px; }
.nav-section .nav-title {
    padding: 4px 4px 10px;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.28em;
    color: var(--text-dim);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}
.nav-section .nav-title::after {
    content: "";
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, var(--hairline), transparent);
}

/* Leaf item (level 1) */
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    color: var(--text-muted);
    font-size: 12.5px;
    border-radius: var(--radius);
    margin: 1px 0;
    transition: color .18s, background .18s;
    position: relative;
    line-height: 1.4;
    cursor: pointer;
    user-select: none;
}
.nav-item:hover { color: var(--text); background: rgba(255,255,255,0.02); text-decoration: none; }
.nav-item.active { color: var(--gold-hi); }
.nav-item.active::before {
    content: "";
    position: absolute;
    left: -20px;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 16px;
    background: var(--gold);
    box-shadow: 0 0 8px var(--gold-glow);
}
.nav-item .num {
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-dim);
    font-variant-numeric: tabular-nums;
    min-width: 22px;
    letter-spacing: 0;
    font-weight: 500;
}
.nav-item.active .num { color: var(--gold); }

/* Group (level 1 with children) */
.nav-group > .nav-item .caret {
    margin-left: auto;
    transition: transform .2s;
    color: var(--text-dim);
    font-size: 9px;
}
.nav-group.open > .nav-item .caret { transform: rotate(90deg); color: var(--gold); }
.nav-group.open > .nav-item { color: var(--text); }
.nav-children {
    max-height: 0;
    overflow: hidden;
    transition: max-height .28s cubic-bezier(0.4, 0, 0.2, 1);
    margin-left: 10px;
    border-left: 1px solid var(--hairline);
    padding-left: 12px;
}
.nav-group.open > .nav-children { max-height: 400px; }

/* Leaf item (level 2, inside group) */
.nav-children .nav-leaf {
    display: block;
    padding: 6px 10px;
    color: var(--text-muted);
    font-size: 12px;
    border-radius: var(--radius);
    line-height: 1.4;
    transition: color .18s, background .18s;
    position: relative;
}
.nav-children .nav-leaf::before {
    content: "";
    position: absolute;
    left: -13px;
    top: 50%;
    width: 6px;
    height: 1px;
    background: var(--hairline);
}
.nav-children .nav-leaf:hover {
    color: var(--text);
    background: rgba(255,255,255,0.02);
    text-decoration: none;
}
.nav-children .nav-leaf.active {
    color: var(--gold-hi);
}
.nav-children .nav-leaf.active::before {
    background: var(--gold);
    box-shadow: 0 0 6px var(--gold-glow);
    width: 8px;
}

/* =============================================================================
   Topbar
   ============================================================================= */
header.topbar {
    grid-area: topbar;
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--hairline);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    gap: 12px;
}
.menu-toggle {
    display: none;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all .2s;
    line-height: 0;
}
.menu-toggle:hover { border-color: var(--gold); color: var(--gold-hi); }
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(4px);
    z-index: 100;
    opacity: 0;
    transition: opacity .25s;
}
body.sidebar-open .sidebar-overlay { display: block; opacity: 1; }
.crumb-bar { color: var(--text-muted); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; }
.crumb-bar b { color: var(--text); font-weight: 500; }

.user-menu { display: flex; align-items: center; gap: 12px; }
.user-menu .user {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 14px 6px 6px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 12px;
}
.user-menu .avatar {
    width: 28px; height: 28px; border-radius: 50%;
    background: linear-gradient(135deg, var(--gold-hi), var(--gold-lo));
    display: flex; align-items: center; justify-content: center;
    color: #0a0a0d; font-weight: 600; font-size: 12px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.25);
}
.user-menu .user > div { line-height: 1.2; }
.user-menu .user b { color: var(--text-strong); font-weight: 500; }
.user-menu .role {
    display: inline-block;
    font-size: 9px;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin-top: 2px;
}
.user-menu a.logout {
    color: var(--text-muted);
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 100px;
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: all .2s;
}
.user-menu a.logout:hover {
    color: var(--text);
    border-color: var(--text-dim);
    background: var(--bg-surface);
    text-decoration: none;
}

/* =============================================================================
   Main
   ============================================================================= */
main.main {
    grid-area: main;
    padding: 32px 40px 48px;
    overflow-x: auto;
    max-width: 100%;
}
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--hairline);
    position: relative;
}
.page-header::after {
    content: "";
    position: absolute;
    left: 0; bottom: -1px;
    width: 40px; height: 1px;
    background: var(--gold);
    box-shadow: 0 0 8px var(--gold-glow);
}
.page-header h1 {
    font-family: var(--font-serif);
    font-weight: 400;
    font-size: 28px;
    color: var(--text-strong);
    letter-spacing: -0.02em;
    line-height: 1.1;
}
.page-header .crumb {
    color: var(--text-dim);
    font-size: 10px;
    margin-top: 6px;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    font-weight: 500;
}

/* =============================================================================
   Buttons
   ============================================================================= */
.btn, button.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bg-surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    cursor: pointer;
    font: inherit;
    font-size: 11.5px;
    line-height: 1.4;
    letter-spacing: 0.04em;
    transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    text-transform: uppercase;
    font-weight: 500;
}
.btn:hover {
    border-color: var(--gold);
    color: var(--gold-hi);
    text-decoration: none;
}
.btn.primary {
    background: linear-gradient(180deg, var(--gold-hi) 0%, var(--gold) 55%, var(--gold-lo) 100%);
    color: #0a0a0d;
    border-color: var(--gold-lo);
    font-weight: 600;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.25),
        inset 0 -1px 0 rgba(0,0,0,0.2),
        0 4px 12px rgba(0,0,0,.4);
}
.btn.primary:hover {
    background: linear-gradient(180deg, #f0d19a 0%, var(--gold-hi) 55%, var(--gold) 100%);
    color: #0a0a0d;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.35),
        0 6px 20px rgba(201, 167, 105, 0.35);
    transform: translateY(-1px);
}
.btn.warn {
    color: var(--danger);
    border-color: rgba(212, 115, 110, 0.4);
}
.btn.warn:hover {
    background: var(--danger-soft);
    color: #e89490;
    border-color: var(--danger);
}
.btn.warn.primary {
    background: linear-gradient(180deg, #e08a86 0%, var(--danger) 100%);
    color: #fff;
}
.btn.ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.btn.ghost:hover { color: var(--text); border-color: var(--border-strong); background: var(--bg-surface); }
.btn-group { display: inline-flex; gap: 6px; }

/* =============================================================================
   Forms
   ============================================================================= */
.form-control, input[type=text], input[type=password], input[type=email],
input[type=number], input[type=date], input[type=file], select, textarea {
    padding: 9px 12px;
    background: var(--bg-surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    font: inherit;
    font-size: 12px;
    transition: all .2s;
    width: 100%;
}
.form-control:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-soft);
    background: var(--bg-surface-2);
}
.form-control::placeholder { color: var(--text-dim); }
textarea.form-control { font-family: inherit; resize: vertical; min-height: 64px; line-height: 1.55; }
select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a7a83' stroke-width='1.5'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 13px;
    padding-right: 32px;
}
input[type=checkbox], input[type=radio] {
    accent-color: var(--gold);
    width: 15px; height: 15px;
    cursor: pointer;
}
input[type=date] { color-scheme: dark; }

.search-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    margin-bottom: 18px;
    flex-wrap: wrap;
    position: relative;
}
.search-bar label {
    color: var(--text-muted);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-weight: 500;
}

.form-row { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.form-row label { min-width: 120px; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; }
.form-row .form-control { flex: 1; }

/* =============================================================================
   Tables
   ============================================================================= */
table.grid {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    font-size: 12px;
    box-shadow: var(--shadow-sm);
}
table.grid thead th {
    background: var(--bg-surface-2);
    color: var(--text-muted);
    padding: 13px 14px;
    text-align: left;
    font-weight: 500;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    border-bottom: 1px solid var(--hairline-hi);
    white-space: nowrap;
    font-family: var(--font-sans);
}
table.grid thead th.center { text-align: center; }
table.grid tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text);
    line-height: 1.4;
}
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid tbody tr { transition: background .15s; }
table.grid tbody tr:hover { background: rgba(201, 167, 105, 0.025); }
table.grid td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: var(--font-mono);
    font-size: 11.5px;
    letter-spacing: -0.02em;
}
table.grid td.center { text-align: center; }
table.grid .empty {
    text-align: center;
    color: var(--text-dim);
    padding: 80px 0;
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 15px;
    letter-spacing: 0.02em;
}
table.grid tbody td .form-control { padding: 5px 8px; font-size: 12px; }

/* Inline row states */
table.grid tbody tr.row-new {
    background: linear-gradient(90deg, var(--gold-soft) 0%, transparent 100%);
    border-top: 1px solid var(--hairline-hi);
}
table.grid tbody tr.row-new:hover { background: linear-gradient(90deg, rgba(201, 167, 105, 0.16) 0%, transparent 100%); }
table.grid tbody tr.row-active {
    background: var(--gold-soft);
    box-shadow: inset 3px 0 0 var(--gold);
}
table.grid tbody tr.row-total {
    background: var(--bg-surface-2);
    font-weight: 500;
    color: var(--gold-hi);
    border-top: 1px solid var(--hairline-hi);
}
table.grid tbody tr.row-total td.num { color: var(--gold-hi); font-weight: 600; }

/* form-style key-value table */
table.form {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    font-size: 12px;
    margin-bottom: 16px;
}
table.form th, table.form td {
    padding: 11px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.form tr:last-child th, table.form tr:last-child td { border-bottom: none; }
table.form th {
    background: var(--bg-surface-2);
    color: var(--text-muted);
    font-weight: 500;
    text-align: left;
    width: 150px;
    font-size: 10.5px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    border-right: 1px solid var(--border);
}
table.form td { color: var(--text); }
table.form td .form-control { width: 100%; }

/* =============================================================================
   Pagination
   ============================================================================= */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin: 22px 0 6px;
}
.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    padding: 7px 11px;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius);
    font-size: 11.5px;
    font-family: var(--font-mono);
    transition: all .2s;
}
.pagination a:hover {
    color: var(--gold-hi);
    border-color: var(--gold);
    text-decoration: none;
}
.pagination .cur {
    color: var(--gold);
    border-color: var(--gold);
    background: var(--gold-soft);
    font-weight: 600;
}

/* =============================================================================
   Flash / chips
   ============================================================================= */
.flash-list { list-style: none; margin: 0 0 18px; padding: 0; }
.flash-list li {
    padding: 12px 16px;
    margin-bottom: 8px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-left: 2px solid var(--info);
    border-radius: var(--radius);
    font-size: 12px;
    color: var(--text);
}
.flash-list li.error   { border-left-color: var(--danger); background: var(--danger-soft); color: #e89490; }
.flash-list li.success { border-left-color: var(--success); background: var(--success-soft); color: #a8dcc1; }

.chip {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    border: 1px solid;
    font-family: var(--font-sans);
}
.chip.success { color: var(--success); background: var(--success-soft); border-color: rgba(123, 201, 158, 0.3); }
.chip.danger  { color: var(--danger); background: var(--danger-soft); border-color: rgba(212, 115, 110, 0.3); }
.chip.warning { color: var(--warning); background: rgba(212, 160, 90, 0.1); border-color: rgba(212, 160, 90, 0.3); }
.chip.muted   { color: var(--text-muted); background: var(--bg-surface-2); border-color: var(--border-strong); }
.chip.gold    { color: var(--gold-hi); background: var(--gold-soft); border-color: var(--hairline-hi); }

/* =============================================================================
   Login
   ============================================================================= */
body.popup { background: var(--bg-app); }
body.popup body {
    background-image:
        radial-gradient(ellipse 60% 60% at 50% 30%, rgba(201, 167, 105, 0.08), transparent);
}
.login-wrap {
    max-width: 400px;
    margin: 110px auto;
    padding: 48px 42px 40px;
    background: linear-gradient(180deg, var(--bg-surface) 0%, #0a0a0d 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}
.login-wrap::before {
    content: "";
    position: absolute;
    top: 0; left: 20%; right: 20%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    box-shadow: 0 0 20px var(--gold-glow);
}
.login-mark {
    width: 60px; height: 60px;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--gold-hi) 0%, var(--gold-lo) 100%);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: 34px;
    color: #0a0a0d;
    margin: 0 auto 24px;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.4),
        0 0 40px var(--gold-glow);
    letter-spacing: -0.02em;
    line-height: 1;
    padding-top: 4px;
}
.login-wrap h1 {
    text-align: center;
    font-family: var(--font-serif);
    font-weight: 400;
    font-size: 26px;
    margin: 0 0 4px;
    letter-spacing: 0;
    color: var(--text-strong);
}
.login-wrap .subtitle {
    text-align: center;
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.32em;
    margin-bottom: 34px;
    font-weight: 500;
}
.login-wrap .form-control {
    padding: 13px 16px;
    margin-bottom: 12px;
    font-size: 13px;
    background: var(--bg-surface-2);
}
.login-wrap .btn.primary {
    width: 100%;
    padding: 13px;
    margin-top: 8px;
    font-size: 11px;
    letter-spacing: 0.32em;
}

/* =============================================================================
   Popup (form windows)
   ============================================================================= */
body.popup .app-shell { display: block; grid-template: none; min-height: auto; }
body.popup .sidebar, body.popup .topbar { display: none; }
body.popup main.main { padding: 28px 32px; max-width: 100%; }

.actions-bottom {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--hairline);
}

/* =============================================================================
   Dashboard
   ============================================================================= */

/* KPI 4-card row */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}
.kpi-card {
    padding: 22px 24px;
    background: linear-gradient(180deg, var(--bg-surface) 0%, #0d0d11 100%);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
    transition: all .3s;
}
.kpi-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--hairline), transparent);
}
.kpi-card:hover {
    border-color: var(--hairline-hi);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}
.kpi-card.kpi-gold {
    background: linear-gradient(180deg, #1c160c 0%, #0d0a06 100%);
    border-color: rgba(201, 167, 105, 0.25);
}
.kpi-card.kpi-gold::before {
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    box-shadow: 0 0 12px var(--gold-glow);
}
.kpi-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.22em;
    font-weight: 600;
    margin-bottom: 12px;
}
.kpi-value {
    font-family: var(--font-serif);
    font-size: 32px;
    font-weight: 400;
    color: var(--text-strong);
    letter-spacing: -0.02em;
    line-height: 1;
    margin-bottom: 8px;
    font-variant-numeric: tabular-nums;
}
.kpi-card.kpi-gold .kpi-value { color: var(--gold-hi); }
.kpi-unit {
    font-size: 14px;
    color: var(--text-muted);
    margin-left: 4px;
    font-family: var(--font-sans);
    font-weight: 400;
}
.kpi-note {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.02em;
}
.kpi-note b { color: var(--text); font-weight: 600; font-family: var(--font-mono); }

/* Period 3-card row */
.period-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}
.period-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px 20px;
    position: relative;
    overflow: hidden;
    transition: all .3s;
}
.period-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0;
    width: 2px; height: 100%;
    background: var(--gold);
    opacity: 0.5;
}
.period-card:hover { border-color: var(--hairline-hi); }
.period-card:hover::before { opacity: 1; box-shadow: 0 0 12px var(--gold-glow); }

.period-card.period-hi {
    background: linear-gradient(135deg, #14100a 0%, #0a0806 100%);
    border-color: rgba(201, 167, 105, 0.2);
}
.period-card.period-hi::before { opacity: 1; box-shadow: 0 0 12px var(--gold-glow); }

.period-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 20px;
}
.period-title {
    font-family: var(--font-serif);
    font-size: 20px;
    color: var(--text-strong);
    letter-spacing: -0.01em;
    line-height: 1;
}
.period-date {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.16em;
}
.period-body .stat {
    display: flex; align-items: baseline;
    gap: 10px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--hairline);
    margin-bottom: 12px;
}
.period-body .stat-value {
    font-family: var(--font-serif);
    font-size: 44px;
    font-weight: 400;
    color: var(--gold-hi);
    line-height: 1;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}
.period-body .stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
}
.period-body .stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.04em;
}
.period-body .stat-row b {
    color: var(--text-strong);
    font-family: var(--font-mono);
    font-size: 12px;
    margin-left: 4px;
}

/* Chart cards */
.chart-grid { display: grid; gap: 16px; margin-bottom: 20px; }
.chart-grid.two-col { grid-template-columns: 1fr 1fr; }
.chart-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px 20px;
    margin-bottom: 20px;
}
.chart-card:last-child { margin-bottom: 0; }
.chart-grid.two-col > .chart-card { margin-bottom: 0; }
.chart-card.wide { grid-column: span 1; }

.chart-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 18px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--hairline);
}
.chart-card h4 {
    margin: 0 0 3px;
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 500;
    color: var(--text-strong);
    letter-spacing: -0.01em;
}
.chart-card h4 .muted { color: var(--text-dim); font-family: var(--font-mono); font-size: 12px; font-weight: 400; }
.chart-sub {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.14em;
}
.chart-link {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    transition: color .2s;
}
.chart-link:hover { color: var(--gold-hi); text-decoration: none; }

.chart-legend {
    display: flex; gap: 14px;
    font-size: 11px;
    color: var(--text-muted);
}
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i {
    width: 10px; height: 10px;
    border-radius: 2px;
    display: inline-block;
}

.donut-legend {
    display: flex; justify-content: center; gap: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--hairline);
    margin-top: 12px;
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.06em;
}
.donut-legend div { display: inline-flex; align-items: center; gap: 6px; }
.donut-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.donut-legend b {
    color: var(--text-strong);
    margin-left: 4px;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
}

.chart-wrap { position: relative; width: 100%; }

/* Mini table (used in dashboard) */
.mini-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.mini-table thead th {
    padding: 8px 10px;
    font-size: 9.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-weight: 600;
    text-align: left;
    border-bottom: 1px solid var(--hairline);
}
.mini-table thead th.right, .mini-table td.right { text-align: right; }
.mini-table thead th.center, .mini-table td.center { text-align: center; }
.mini-table tbody td {
    padding: 9px 10px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
}
.mini-table tbody tr:last-child td { border-bottom: none; }
.mini-table tbody tr:hover { background: rgba(201, 167, 105, 0.02); }
.mini-table .empty {
    text-align: center;
    padding: 40px 0;
    color: var(--text-dim);
    font-family: var(--font-serif);
    font-style: italic;
    font-size: 14px;
}
.mini-table .mono { font-family: var(--font-mono); font-size: 11px; letter-spacing: -0.02em; }
.mini-table .gold { color: var(--gold-hi); }
.mini-table .muted { color: var(--text-muted); }

/* =============================================================================
   2단 분할 레이아웃 (흐름도 화면 등)
   ============================================================================= */
.split-cols {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}
.split-col {
    flex: 1 1 0;
    /* min-width:0 이 없으면 flex 자식이 내부 table 의 min-width(640px)까지 부풀어
       화면 밖으로 잘려나간다. body 가 overflow-x:hidden 이라 스크롤도 안 되므로
       조작 자체가 불가능해진다. 절대 제거하지 말 것. */
    min-width: 0;
}
/* 목록 셀의 보조 표기 (영문명 등) */
.sub-name { color: var(--text-dim); font-size: 11.5px; }

/* 입력 아래 보조 설명 */
.hint {
    display: block;
    margin-top: 6px;
    color: var(--text-dim);
    font-size: 12px;
    line-height: 1.5;
}

/* 폭 고정 컬럼 (예: 공통코드 대분류 목록) */
.split-col-fixed { flex: 0 0 250px; }
.inline-form { display: flex; gap: 4px; }

/* =============================================================================
   Responsive · 반응형 (기준: Galaxy S8 360px 이상)
   ============================================================================= */

/* --- 태블릿 이하 (~1200px) : 대시보드 그리드 축소 --- */
@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .chart-grid.two-col { grid-template-columns: 1fr; }
}

/* --- 태블릿 (~900px) --- */
@media (max-width: 900px) {
    :root {
        --sidebar-w: 260px;
        --topbar-h: 56px;
    }
    main.main { padding: 22px 20px 40px; }
    .period-grid { grid-template-columns: 1fr; }
    .page-header h1 { font-size: 22px; }
    .kpi-value { font-size: 26px; }
    .kpi-card { padding: 18px 20px; }
    table.form th { width: 110px; font-size: 10px; }
}

/* --- 모바일 (Galaxy 기준 <=768px) : 사이드바 드로어 전환 --- */
@media (max-width: 768px) {
    /* Grid → 단순 flex */
    .app-shell {
        display: block;
        grid-template: none;
    }
    /* 사이드바를 드로어로 */
    aside.sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 280px;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform .28s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 200;
        box-shadow: none;
    }
    body.sidebar-open aside.sidebar {
        transform: translateX(0);
        box-shadow: 8px 0 40px rgba(0,0,0,.6);
    }
    /* Topbar sticky, 햄버거 노출 */
    header.topbar {
        padding: 0 14px;
        gap: 10px;
    }
    .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
    /* 유저 정보 축약: 이름 숨김, 아바타만 */
    .user-menu .user-text { display: none; }
    .user-menu .user {
        padding: 4px;
        border-radius: 50%;
        gap: 0;
    }
    .user-menu a.logout {
        padding: 6px 12px;
        font-size: 10px;
        letter-spacing: 0.06em;
    }
    .crumb-bar {
        font-size: 10px;
        letter-spacing: 0.12em;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        flex: 1;
    }

    /* Main content 좁게 */
    main.main { padding: 16px 12px 32px; }

    /* 페이지 헤더: 세로 스택 */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 18px;
        padding-bottom: 16px;
    }
    .page-header h1 { font-size: 20px; }
    .page-header .btn-group { flex-wrap: wrap; }

    /* KPI 카드: 2열 유지, 폰트만 축소 */
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 22px; }
    .kpi-card { padding: 16px 14px; }
    .kpi-label { font-size: 9px; letter-spacing: 0.16em; margin-bottom: 8px; }
    .kpi-value { font-size: 22px; }
    .kpi-unit { font-size: 11px; }
    .kpi-note { font-size: 10px; }

    /* Period 카드: 1열 */
    .period-grid { grid-template-columns: 1fr; gap: 10px; margin-bottom: 22px; }
    .period-card { padding: 18px 18px 16px; }
    .period-title { font-size: 17px; }
    .period-body .stat-value { font-size: 34px; }
    .period-body .stat-row { flex-wrap: wrap; gap: 6px 12px; }

    /* Chart cards: 1열, 여백 축소 */
    .chart-grid.two-col { grid-template-columns: 1fr; gap: 12px; }
    .chart-card { padding: 16px 14px 14px; margin-bottom: 12px; }
    .chart-head { flex-direction: column; gap: 6px; align-items: flex-start; padding-bottom: 12px; }
    .chart-card h4 { font-size: 15px; }

    /* 테이블: 가로 스크롤 (JS 로 감싼 .table-scroll) */
    .table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 -12px 12px;
        padding: 0 12px;
    }
    .table-scroll table.grid, .table-scroll table.form {
        min-width: 640px;
    }

    /* 검색바: 세로 스택 */
    .search-bar {
        padding: 12px;
        gap: 6px;
        border-radius: var(--radius);
    }
    .search-bar > * { width: 100%; }
    .search-bar label { display: none; }

    /* 폼: 2컬럼 -> 1컬럼 */
    table.form th, table.form td { display: block; width: auto; border-right: none; }
    table.form th { padding: 8px 12px 4px; }
    table.form td { padding: 4px 12px 10px; border-bottom: 1px solid var(--border); }

    /* 버튼 & 폼 요소 터치 타깃 확장 */
    .btn, button.btn {
        padding: 10px 14px;
        min-height: 40px;
        font-size: 11px;
    }
    .form-control, input, select, textarea {
        font-size: 15px;   /* iOS/Android 확대 방지: 16px 근접 */
        padding: 10px 12px;
    }

    /* 로그인 카드 */
    .login-wrap {
        margin: 40px 16px;
        padding: 36px 24px 28px;
    }

    /* 액션 버튼 하단: 가운데 정렬로 스택 */
    .actions-bottom { flex-wrap: wrap; justify-content: stretch; }
    .actions-bottom .btn { flex: 1; }

    /* 대시보드 미니 테이블 */
    .mini-table thead { display: none; } /* 헤더 숨기고 카드 스타일로... 그러나 심플하게 유지 */
    /* 미니 테이블은 카드 안쪽에 있으므로 래퍼의 음수 마진을 적용하지 않는다 */
    .table-scroll.table-scroll-flush { margin: 0 0 12px; padding: 0; }

    /* --- 2단 분할 → 1단 --------------------------------------------------
       미디어쿼리 없이 두면 각 컬럼이 내부 테이블 최소폭까지 부풀어
       업로드 버튼·우측 컬럼이 화면 밖으로 잘린다. */
    .split-cols {
        flex-direction: column;
        gap: 22px;
    }
    /* flex-direction:column 이므로 flex-basis 가 '높이'로 해석된다. 반드시 해제할 것. */
    .split-col,
    .split-col-fixed { width: 100%; flex: 0 0 auto; }
    .inline-form { flex-wrap: wrap; }

    /* --- 터치 타깃 최소 40x40 (CLAUDE.md 필수 항목) ----------------------- */
    .menu-toggle {
        width: 40px;
        height: 40px;
        padding: 0;
    }
    .nav-item,
    .nav-children .nav-leaf {
        min-height: 40px;
        padding-top: 0;
        padding-bottom: 0;
    }
    .btn, button.btn {
        min-height: 40px;
        padding: 8px 16px;
    }
    .user-menu a.logout {
        min-height: 40px;
        display: inline-flex;
        align-items: center;
    }
    .user-menu .user { min-height: 40px; min-width: 40px; }
    .chart-link, .crumb a { display: inline-flex; align-items: center; min-height: 40px; }
    /* 입력 컨트롤 */
    .form-control, input[type=text], input[type=password], input[type=email],
    input[type=number], input[type=date], input[type=file], select, textarea {
        min-height: 40px;
    }
    /* 테이블 셀 안의 링크: 셀 전체를 탭 영역으로 (여백은 음수 마진으로 상쇄) */
    table.grid tbody td > a:only-child {
        display: block;
        padding: 12px 0;
        margin: -12px 0;
    }

    /* --- 폰트 최소 12px (CLAUDE.md 필수 항목) ---------------------------- */
    .brand-sub,
    .nav-section .nav-title,
    .nav-group > .nav-item .caret,
    .kpi-label,
    .kpi-note,
    .kpi-unit,
    .crumb-bar,
    .crumb-bar b,
    .page-header .crumb,
    .user-menu a.logout,
    .period-date,
    .chart-sub,
    .chart-link,
    .period-body .stat-label,
    .nav-item .num,
    .mini-table .mono,
    table.form th,
    table.grid thead th,
    table.grid td.num,
    .sub-name,
    h3,
    .btn, button.btn {
        font-size: 12px;
    }
    /* 12px 로 올리면 자간 때문에 줄바꿈이 생기는 라벨들은 자간을 줄여 흡수 */
    .brand-sub { letter-spacing: 0.14em; }
    .nav-section .nav-title { letter-spacing: 0.12em; }
    .kpi-label { letter-spacing: 0.1em; }
    .crumb-bar { letter-spacing: 0.08em; }
    .user-menu a.logout { letter-spacing: 0.04em; }
    h3 { letter-spacing: 0.14em; }
    .page-header .crumb { letter-spacing: 0.12em; }
    table.grid thead th { letter-spacing: 0.08em; padding: 12px 10px; }
}

/* --- 소형 (Galaxy S8 360px 부근) --- */
@media (max-width: 400px) {
    main.main { padding: 14px 10px 30px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .kpi-value { font-size: 20px; }
    .period-card { padding: 16px 14px; }
    .period-body .stat-value { font-size: 30px; }
    .page-header h1 { font-size: 18px; }
    aside.sidebar { width: calc(100vw - 60px); max-width: 280px; }
}

/* Table 스크롤 래퍼 (JS 로 자동 감싸짐) */
.table-scroll {
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

/* =============================================================================
   Print
   ============================================================================= */
@media print {
    body { background: #fff; color: #000; background-image: none; }
    aside.sidebar, header.topbar, .page-header .btn-group,
    .search-bar, .actions-bottom, .print-hide { display: none !important; }
    .app-shell { grid-template: none; display: block; }
    main.main { padding: 0; overflow: visible; }
    table.grid, table.form { background: #fff; border-color: #333; box-shadow: none; }
    table.grid thead th { background: #eee; color: #333; }
    table.grid tbody td, table.form th, table.form td { color: #000; border-color: #666; }
    .flash-list { display: none; }
    .page-header h1 { color: #000; }
    h3 { color: #333; border-color: #999; }
}
