* { box-sizing: border-box; }

html { min-width: 320px; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Segoe UI", sans-serif;
    background: #f3f4f6;
    color: #1f2937;
}

a { color: inherit; text-decoration: none; }

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-box {
    width: 100%;
    max-width: 420px;
    background: #fff;
    padding: 28px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, .08);
}

.login-box h1 { margin: 0 0 8px; font-size: 24px; }
.login-desc { margin: 0 0 24px; color: #6b7280; font-size: 14px; }

.login-box label,
.filter-box label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #4b5563;
}

input,
select {
    width: 100%;
    min-width: 0;
    height: 44px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0 12px;
    font-size: 14px;
    background: #fff;
    color: #111827;
}

button {
    border: 0;
    cursor: pointer;
    border-radius: 6px;
    background: #1f2937;
    color: #fff;
    font-weight: 700;
    height: 44px;
    padding: 0 16px;
    font-size: 14px;
}

button:hover,
.filter-actions a:hover,
.admin-menu a:hover { filter: brightness(.96); }

.login-box button { width: 100%; margin-top: 18px; }

.alert {
    padding: 12px;
    margin-bottom: 16px;
    border-radius: 6px;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 14px;
}

.notice {
    margin-bottom: 16px;
    padding: 13px 14px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #374151;
    font-size: 14px;
    font-weight: 700;
}

.notice.success {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #166534;
}

.notice.warning {
    background: #fff7ed;
    border-color: #fed7aa;
    color: #9a3412;
}

.status-guide {
    margin: 18px 0 10px;
    padding: 14px 16px;
    border: 1px solid #bfdbfe;
    border-left: 4px solid #2563eb;
    border-radius: 8px;
    background: #eff6ff;
    color: #1e3a8a;
}

.status-guide strong {
    display: block;
    margin-bottom: 5px;
    color: #1d4ed8;
    font-size: 14px;
}

.status-guide p {
    margin: 0;
    color: #374151;
    font-size: 13px;
    line-height: 1.55;
}

.admin-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
}

.sidebar {
    background: #111827;
    color: #fff;
    padding: 22px 16px;
}

.sidebar-brand {
    padding: 0 8px 22px;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.sidebar-brand strong {
    display: block;
    font-size: 18px;
}

.sidebar-brand span {
    display: block;
    margin-top: 6px;
    color: #cbd5e1;
    font-size: 13px;
}

.admin-menu {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 18px;
}

.admin-menu a {
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 6px;
    color: #d1d5db;
    font-size: 14px;
    font-weight: 700;
    white-space: nowrap;
}

.admin-menu a.active {
    background: #2563eb;
    color: #fff;
}

.admin-menu .logout-link {
    margin-top: 8px;
    background: rgba(255, 255, 255, .08);
}

.admin-content { min-width: 0; }

.admin-header {
    min-height: 90px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 22px 28px;
    display: flex;
    align-items: center;
}

.admin-header h1 { margin: 0; font-size: 24px; }
.admin-header p { margin: 7px 0 0; color: #6b7280; font-size: 14px; }

.admin-main {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px;
}

.card,
.filter-box,
.table-card,
.summary-card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, .04);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.summary-card {
    padding: 18px;
}

.summary-card span {
    display: block;
    margin-bottom: 8px;
    color: #6b7280;
    font-size: 13px;
    font-weight: 700;
}

.summary-card strong {
    display: block;
    color: #111827;
    font-size: 26px;
    line-height: 1;
}

.stats-summary-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.dashboard-month-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dashboard-kpi-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.kpi-card {
    position: relative;
    overflow: hidden;
}

.kpi-card::after {
    content: "";
    position: absolute;
    right: 16px;
    top: 18px;
    width: 46px;
    height: 46px;
    border-radius: 999px;
    opacity: .13;
}

.kpi-card.primary::after { background: #2563eb; }
.kpi-card.accent::after { background: #0891b2; }
.kpi-card.warning::after { background: #f97316; }
.kpi-card.success::after { background: #16a34a; }

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(320px, .9fr);
    gap: 16px;
    margin-bottom: 22px;
}

.dashboard-panel {
    padding: 20px;
}

.chart-panel {
    min-height: 390px;
}

.bar-chart {
    height: 270px;
    display: grid;
    grid-template-columns: repeat(12, minmax(28px, 1fr));
    gap: 12px;
    align-items: end;
    padding: 20px 4px 8px;
    border-bottom: 1px solid #e5e7eb;
}

.bar-group {
    min-width: 0;
    display: grid;
    gap: 8px;
    justify-items: center;
}

.bar-stack {
    height: 220px;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: end;
    gap: 5px;
}

.bar {
    width: 13px;
    min-height: 6px;
    border-radius: 6px 6px 0 0;
    display: block;
}

.wide-bar {
    width: 22px;
}

.single-bar-chart {
    margin-bottom: 6px;
}

.api-bar { background: #2563eb; }
.pdf-bar { background: #14b8a6; }

.bar-label {
    color: #6b7280;
    font-size: 12px;
    font-weight: 700;
}

.chart-legend {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-top: 14px;
    color: #4b5563;
    font-size: 13px;
    font-weight: 700;
}

.legend-dot {
    width: 9px;
    height: 9px;
    display: inline-block;
    margin-right: 6px;
    border-radius: 999px;
}

.legend-dot.api { background: #2563eb; }
.legend-dot.pdf { background: #14b8a6; }
.legend-dot.total { background: #111827; }

.stats-month-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 16px;
    padding: 18px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(15, 23, 42, .04);
}

.api-stats-card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 16px;
    align-items: stretch;
}

.api-stats-card {
    width: 100%;
    padding: 18px;
    min-width: 0;
}

.api-stats-card .section-title {
    margin-bottom: 12px;
}

.stats-month-toolbar.compact {
    margin-bottom: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    display: flex;
    background: transparent;
}

.chart-title {
    margin-top: 18px;
}

.stats-month-toolbar h2 {
    margin: 0;
    color: #111827;
    font-size: 20px;
}

.stats-month-toolbar span {
    display: block;
    margin-top: 6px;
    color: #6b7280;
    font-size: 13px;
    font-weight: 700;
}

.month-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.month-nav a {
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 13px;
    border-radius: 6px;
    background: #1f2937;
    color: #fff;
    font-size: 13px;
    font-weight: 800;
}

.month-nav a:nth-child(2) {
    background: #e5e7eb;
    color: #374151;
}

.api-line-chart-card {
    padding: 20px;
}

.description-table-wrap {
    overflow-x: auto;
}

.description-table {
    min-width: 0;
    width: 100%;
    border-collapse: collapse;
}

.description-table th,
.description-table td {
    padding: 11px 12px;
    border: 1px solid #e5e7eb;
    white-space: normal;
    vertical-align: top;
    line-height: 1.45;
}

.description-table th:first-child,
.description-table td:first-child {
    width: 112px;
    font-weight: 800;
    white-space: nowrap;
}

.description-table .danger-text td {
    color: #dc2626;
}

.danger-text {
    color: #dc2626;
}

.api-stats-definition {
    margin: 0;
    display: grid;
    gap: 10px;
}

.api-stats-definition div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #f9fafb;
}

.api-stats-definition dt {
    color: #4b5563;
    font-size: 13px;
    font-weight: 800;
}

.api-stats-definition dd {
    margin: 0;
    color: #111827;
    font-size: 14px;
    font-weight: 800;
}

.api-line-chart-scroll {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
}

.api-line-chart {
    width: 100%;
    min-width: 1040px;
    height: 360px;
    display: block;
}

.chart-grid {
    stroke: #e5e7eb;
    stroke-width: 1;
}

.chart-grid-vertical {
    stroke: #f1f5f9;
}

.chart-axis-label {
    fill: #6b7280;
    font-size: 12px;
    font-weight: 700;
}

.chart-day-label {
    text-anchor: middle;
}

.chart-line {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chart-line-total { stroke: #111827; }
.chart-line-api { stroke: #2563eb; }
.chart-line-pdf { stroke: #14b8a6; }

.api-month-table tr.active-month td {
    background: #f3f4f6;
    font-weight: 800;
}

.js-month-stat-row {
    cursor: pointer;
}

.js-month-stat-row:hover td {
    background: #f9fafb;
}

body.modal-open {
    overflow: hidden;
}

.stats-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px 12px;
}

.stats-modal.open {
    display: flex;
}

.stats-modal-dim {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .6);
}

.stats-modal-box {
    position: relative;
    z-index: 1;
    width: 1420px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 20px 60px rgba(15, 23, 42, .25);
}

.stats-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid #e5e7eb;
}

.stats-modal-header span {
    display: block;
    margin-bottom: 6px;
    color: #f97316;
    font-size: 12px;
    font-weight: 800;
}

.stats-modal-header h2 {
    margin: 0;
    color: #111827;
    font-size: 20px;
}

.stats-modal-close {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 6px;
    background: #f3f4f6;
    color: #374151;
}

.stats-modal-body {
    overflow: auto;
    padding: 10px 12px;
}

.daily-stats-loading {
    padding: 36px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
    font-weight: 700;
}

.daily-stats-table-wrap {
    box-shadow: none;
}

.daily-stats-table {
    min-width: 0;
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.daily-stats-table th,
.daily-stats-table td {
    padding: 8px 5px;
    border-bottom: 1px solid #eee;
    text-align: center;
    font-size: 11px;
    white-space: nowrap;
}

.daily-stats-table th {
    color: #6b7280;
    background: #f9fafb;
    font-weight: 800;
    white-space: normal;
    line-height: 1.25;
}

.stats-modal-footer {
    display: flex;
    justify-content: center;
    padding: 12px 16px 14px;
    border-top: 1px solid #e5e7eb;
}

.stats-modal-footer button {
    min-width: 120px;
    background: #f97316;
}

.donut-wrap {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 20px;
    align-items: center;
    margin-top: 18px;
}

.donut-chart {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: conic-gradient(#2563eb 0 var(--done), #ffedd5 var(--done) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}

.donut-chart::after {
    content: "";
    position: absolute;
    inset: 22px;
    border-radius: 50%;
    background: #fff;
}

.donut-chart strong,
.donut-chart span {
    position: relative;
    z-index: 1;
}

.donut-chart strong {
    display: block;
    font-size: 30px;
    line-height: 1;
}

.donut-chart span {
    margin-top: 6px;
    color: #6b7280;
    font-size: 12px;
    font-weight: 800;
}

.status-breakdown {
    display: grid;
    gap: 12px;
}

.status-breakdown div {
    padding: 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
}

.status-breakdown span,
.progress-head span {
    color: #6b7280;
    font-size: 13px;
    font-weight: 700;
}

.status-breakdown strong {
    display: block;
    margin-top: 6px;
    color: #111827;
    font-size: 20px;
}

.progress-list {
    display: grid;
    gap: 16px;
    margin-top: 24px;
}

.progress-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.progress-head b {
    font-size: 13px;
}

.progress-track {
    height: 10px;
    border-radius: 999px;
    background: #e5e7eb;
    overflow: hidden;
}

.progress-track span {
    height: 100%;
    display: block;
    border-radius: 999px;
}

.progress-track .done { background: #2563eb; }
.progress-track .wait { background: #f97316; }

.filter-box {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) 150px 150px 155px 155px auto;
    gap: 14px;
    align-items: end;
    padding: 18px;
}

.stats-filter-box {
    grid-template-columns: 155px 155px minmax(180px, 1fr) 150px 140px auto;
}

.filter-actions {
    display: flex;
    gap: 8px;
}

.filter-actions a {
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    border-radius: 6px;
    background: #e5e7eb;
    color: #374151;
    font-weight: 700;
    font-size: 14px;
}

.list-meta {
    margin: 18px 0 10px;
    color: #4b5563;
    font-size: 14px;
}

.section-block {
    margin-top: 22px;
}

.section-title {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 10px;
}

.section-title h2 {
    margin: 0;
    color: #111827;
    font-size: 18px;
}

.section-title span {
    color: #6b7280;
    font-size: 13px;
    font-weight: 700;
}

.table-card {
    overflow-x: auto;
}

table {
    width: 100%;
    min-width: 1120px;
    border-collapse: collapse;
}

.stats-table {
    min-width: 720px;
}

th,
td {
    padding: 13px 12px;
    border-bottom: 1px solid #eef0f3;
    text-align: left;
    font-size: 13px;
    white-space: nowrap;
}

th {
    background: #f9fafb;
    color: #4b5563;
    font-weight: 800;
}

tr:last-child td { border-bottom: 0; }
.address-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; padding: 42px; color: #6b7280; }

.badge,
.state {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 72px;
    height: 28px;
    border-radius: 999px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 800;
}

.badge.plus { background: #dcfce7; color: #166534; }
.badge.minus { background: #fee2e2; color: #b91c1c; }
.state.done { background: #dbeafe; color: #1d4ed8; }
.state.wait { background: #ffedd5; color: #c2410c; }
.state.normal { background: #eef2ff; color: #3730a3; }
.state.cache { background: #dcfce7; color: #166534; }
.state.etc { background: #f3f4f6; color: #4b5563; }

.inline-form { margin: 0; }
.small-btn { height: 34px; padding: 0 11px; font-size: 12px; border-radius: 6px; }
.small-btn.gray { background: #6b7280; }

.pagination {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pagination a,
.pagination span {
    min-width: 58px;
    height: 40px;
    padding: 0 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.settings-card {
    padding: 24px;
}

.settings-card h2 {
    margin: 0 0 14px;
    font-size: 20px;
}

.settings-card p {
    margin: 0 0 10px;
    color: #4b5563;
    line-height: 1.6;
}

.settings-list {
    margin: 22px 0 0;
    display: grid;
    gap: 12px;
}

.settings-list div {
    display: grid;
    grid-template-columns: 150px minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
    border-radius: 6px;
    background: #f9fafb;
}

.settings-list dt {
    font-weight: 800;
    color: #111827;
}

.settings-list dd {
    margin: 0;
    color: #4b5563;
    overflow-wrap: anywhere;
}

@media (max-width: 1100px) {
    .filter-box { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-actions { grid-column: span 2; }
    .filter-actions button,
    .filter-actions a { flex: 1; }
    .stats-summary-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .dashboard-month-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .dashboard-grid { grid-template-columns: 1fr; }
    .api-stats-card-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .admin-shell {
        display: block;
    }

    .sidebar {
        position: sticky;
        top: 0;
        z-index: 10;
        padding: 14px;
    }

    .sidebar-brand {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        align-items: center;
        padding: 0 0 12px;
    }

    .sidebar-brand strong { font-size: 16px; }
    .sidebar-brand span { margin-top: 0; }

    .admin-menu {
        margin-top: 12px;
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 2px;
    }

    .admin-menu a {
        min-height: 40px;
        flex: 0 0 auto;
    }

    .admin-header {
        min-height: auto;
        padding: 18px 16px;
    }

    .admin-header h1 { font-size: 21px; }
    .admin-main { padding: 16px; }

    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .stats-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-month-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-panel {
        padding: 16px;
    }

    .bar-chart {
        height: 240px;
        gap: 7px;
    }

    .bar-stack {
        height: 190px;
    }

    .bar {
        width: 9px;
    }

    .donut-wrap {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .summary-card { padding: 15px; }
    .summary-card strong { font-size: 22px; }

    .filter-box {
        grid-template-columns: 1fr;
        padding: 16px;
    }

    .filter-actions {
        grid-column: auto;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .filter-actions button,
    .filter-actions a { width: 100%; }

    .section-title {
        display: block;
    }

    .section-title h2 {
        margin-bottom: 6px;
        font-size: 17px;
    }

    .settings-list div {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .stats-month-toolbar.compact {
        gap: 14px;
    }

    .month-nav {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .month-nav a {
        padding: 0 8px;
    }

    .description-table th,
    .description-table td {
        padding: 10px;
    }
}

@media (max-width: 420px) {
    .login-body { padding: 14px; }
    .login-box { padding: 22px 18px; }
    .admin-main { padding: 14px; }
    .summary-grid { grid-template-columns: 1fr; }
    .stats-summary-grid { grid-template-columns: 1fr; }
    .dashboard-month-grid { grid-template-columns: 1fr; }
    .dashboard-kpi-grid { grid-template-columns: 1fr; }
    .filter-actions { grid-template-columns: 1fr; }
    .month-nav { grid-template-columns: 1fr; }
    .admin-header h1 { font-size: 20px; }
    .bar-chart { gap: 5px; }
    .bar { width: 7px; }
}
