:root {
    --background: #f5f7f4;
    --surface: #ffffff;
    --surface-muted: #edf1ea;
    --text: #1d2722;
    --muted: #66736b;
    --line: #d8dfd6;
    --primary: #1f6f50;
    --primary-dark: #15523b;
    --accent: #8c5b1f;
    --danger: #b3261e;
    --success: #1e7a46;
    --shadow: 0 8px 24px rgba(29, 39, 34, 0.08);
    color-scheme: light;
    font-family: "Segoe UI", "Noto Sans KR", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

html, body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);
}

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

button, input {
    font: inherit;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.68;
}

.app-frame {
    min-height: 100vh;
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 64px;
    padding: 12px clamp(16px, 4vw, 40px);
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(10px);
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    font-weight: 800;
}

.brand-mark {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 18px;
}

.brand-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top-nav {
    display: inline-flex;
    gap: 8px;
}

.top-nav a, .secondary-link, .download-button, .filter-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    font-weight: 700;
}

.secondary-link, .download-button {
    color: var(--primary-dark);
}

.page-shell {
    width: min(1180px, 100%);
    margin: 0 auto;
    padding: 28px clamp(14px, 4vw, 36px) 96px;
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.page-heading h1 {
    margin: 4px 0 0;
    font-size: clamp(1.55rem, 3vw, 2.3rem);
    line-height: 1.15;
    letter-spacing: 0;
}

.eyebrow {
    margin: 0;
    color: var(--accent);
    font-size: 0.88rem;
    font-weight: 800;
}

.filter-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.field-label {
    color: var(--muted);
    font-weight: 800;
}

.date-input {
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    font-weight: 700;
}

.period-toggle {
    display: inline-grid;
    grid-template-columns: repeat(2, minmax(86px, 1fr));
    gap: 6px;
    padding: 4px;
    border-radius: 8px;
    background: var(--surface-muted);
}

.period-button {
    min-height: 38px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--muted);
    font-weight: 800;
}

.period-button.selected {
    background: var(--primary);
    color: #fff;
}

.alert-message {
    margin: 14px 0;
    padding: 12px 14px;
    border-radius: 8px;
    font-weight: 700;
}

.error-message {
    border: 1px solid rgba(179, 38, 30, 0.28);
    background: #fff3f1;
    color: var(--danger);
}

.success-message {
    border: 1px solid rgba(30, 122, 70, 0.24);
    background: #edf8f1;
    color: var(--success);
}

.record-form {
    display: grid;
    gap: 22px;
}

.hall-section h2, .report-section h2 {
    margin: 0 0 12px;
    font-size: 1.16rem;
    line-height: 1.25;
    letter-spacing: 0;
}

.floor-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.floor-card, .summary-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.floor-card {
    display: grid;
    gap: 14px;
    padding: 16px;
}

.floor-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.floor-card-header h3 {
    margin: 0;
    font-size: 1.12rem;
}

.floor-card-header span, .current-count {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.counter-row {
    display: grid;
    grid-template-columns: 44px minmax(156px, 1fr) 68px;
    align-items: center;
    gap: 10px;
}

.counter-label {
    font-weight: 900;
}

.stepper {
    display: grid;
    grid-template-columns: 46px minmax(58px, 1fr) 46px;
    min-height: 46px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-muted);
}

.stepper button {
    border: 0;
    background: var(--surface-muted);
    color: var(--primary-dark);
    font-size: 1.35rem;
    font-weight: 900;
}

.stepper input {
    width: 100%;
    min-width: 0;
    border: 0;
    border-inline: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    text-align: center;
    font-weight: 900;
}

.sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 10;
    margin: 10px -4px 0;
    padding: 12px 4px;
    background: linear-gradient(to top, var(--background) 76%, rgba(245, 247, 244, 0));
}

.primary-action {
    width: 100%;
    min-height: 54px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 900;
}

.entry-section {
    margin-top: 28px;
}

.entry-list {
    display: grid;
    gap: 10px;
}

.entry-card {
    display: grid;
    grid-template-columns: minmax(140px, 1.1fr) minmax(180px, 1fr) auto;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.entry-card div {
    display: grid;
    gap: 4px;
}

.entry-card strong {
    font-size: 1rem;
}

.entry-card span {
    color: var(--muted);
    font-weight: 700;
}

.entry-amounts {
    grid-template-columns: repeat(3, auto);
    justify-content: start;
}

.danger-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid rgba(179, 38, 30, 0.34);
    border-radius: 8px;
    background: #fff7f5;
    color: var(--danger);
    font-weight: 900;
}

.compact-danger-action {
    min-height: 34px;
    padding: 0 10px;
}

.empty-panel {
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--muted);
    font-weight: 800;
    text-align: center;
}

.report-filter {
    align-items: center;
}

.filter-button {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
}

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

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

.summary-card {
    display: grid;
    gap: 6px;
    min-height: 116px;
    padding: 16px;
}

.summary-card span {
    color: var(--muted);
    font-weight: 800;
}

.summary-card strong {
    font-size: 2rem;
    line-height: 1;
}

.summary-card small {
    color: var(--muted);
    font-weight: 700;
}

.summary-card.emphasis {
    border-color: rgba(31, 111, 80, 0.35);
    background: #eef7f1;
}

.report-section {
    margin-top: 24px;
}

.table-wrap, .compact-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.compact-table-wrap {
    width: min(680px, 100%);
}

.data-table {
    width: 100%;
    min-width: 780px;
    border-collapse: collapse;
    white-space: nowrap;
}

.compact-table {
    min-width: 520px;
}

.data-table th, .data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    text-align: right;
}

.data-table th:first-child, .data-table td:first-child, .data-table th:nth-child(2), .data-table td:nth-child(2), .data-table th:nth-child(3), .data-table td:nth-child(3), .data-table th:nth-child(4), .data-table td:nth-child(4), .data-table th:nth-child(5), .data-table td:nth-child(5), .data-table th:nth-child(6), .data-table td:nth-child(6) {
    text-align: left;
}

.data-table thead th {
    background: var(--surface-muted);
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 900;
}

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

.empty-cell, .loading-panel {
    color: var(--muted);
    text-align: center;
    font-weight: 800;
}

.loading-panel {
    padding: 36px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

#blazor-error-ui {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 1000;
    display: none;
    max-width: calc(100vw - 32px);
    padding: 12px 16px;
    border-radius: 8px;
    background: var(--danger);
    color: #fff;
    box-shadow: var(--shadow);
}

#blazor-error-ui .reload {
    margin-left: 10px;
    text-decoration: underline;
}

#blazor-error-ui .dismiss {
    margin-left: 10px;
    cursor: pointer;
}

@media (max-width: 900px) {
    .floor-grid, .summary-grid, .period-summary-grid {
        grid-template-columns: 1fr;
    }

    .counter-row {
        grid-template-columns: 42px minmax(144px, 1fr) 60px;
    }

    .entry-card {
        grid-template-columns: 1fr;
    }

    .entry-amounts {
        grid-template-columns: repeat(3, minmax(0, auto));
    }
}

@media (max-width: 620px) {
    .top-bar {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .top-nav {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .page-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .secondary-link {
        width: 100%;
    }

    .filter-strip {
        display: grid;
        grid-template-columns: 1fr;
    }

    .date-input, .filter-button, .download-button {
        width: 100%;
    }

    .counter-row {
        grid-template-columns: 1fr;
    }

    .current-count {
        text-align: right;
    }
}
