:root {
    --app-green: #1f4d3a;
    --app-green-dark: #15382a;
    --app-green-soft: #e8f0ec;
    --app-bg: #f5f7f6;
    --app-border: #d8e1dc;
    --app-text: #1d2a24;
    --app-muted: #65746d;
    --app-gold: #b89243;
    --app-danger: #a83f35;
}

* {
    letter-spacing: 0;
}

body.app-body {
    min-height: 100vh;
    background: var(--app-bg);
    color: var(--app-text);
    font-family: "Yu Gothic", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
}

.mobile-header {
    background: var(--app-green);
    color: #fff;
    padding: 18px 0 16px;
    border-bottom: 4px solid var(--app-gold);
}

.mobile-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.offline-status-bar {
    padding: 8px 14px;
    background: #fff8e8;
    border-bottom: 1px solid var(--app-border);
    color: var(--app-text);
    font-size: 0.92rem;
    font-weight: 800;
    text-align: center;
}

.mobile-container {
    max-width: 780px;
}

.screen-kicker {
    color: rgba(255, 255, 255, 0.76);
    font-size: 0.78rem;
    font-weight: 700;
}

.dashboard-body .screen-kicker,
.section-label {
    color: var(--app-muted);
    font-size: 0.78rem;
    font-weight: 700;
}

.page-title {
    color: #fff;
    font-size: 1.58rem;
    font-weight: 800;
}

.page-title.dark {
    color: var(--app-text);
}

.header-link {
    white-space: nowrap;
    border-color: rgba(255, 255, 255, 0.55);
}

.app-card,
.dashboard-section,
.summary-card {
    background: #fff;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(31, 77, 58, 0.08);
}

.app-card {
    padding: 16px;
}

.card-heading,
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.section-title {
    color: var(--app-text);
    font-size: 1.08rem;
    font-weight: 800;
}

.state-badge {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 5px 10px;
    border-radius: 999px;
    background: #eef1ef;
    color: var(--app-muted);
    font-size: 0.82rem;
    font-weight: 800;
    white-space: nowrap;
}

.state-badge-active {
    background: var(--app-green-soft);
    color: var(--app-green);
}

.state-badge-light {
    background: #fff8e8;
    color: #7a5b1a;
}

.qr-reader {
    position: relative;
    min-height: 292px;
    overflow: hidden;
    border: 2px dashed #b7c8bf;
    border-radius: 8px;
    background: #f9fbfa;
}

.qr-reader video {
    width: 100% !important;
}

.qr-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 24px;
    color: var(--app-muted);
    text-align: center;
    pointer-events: none;
}

.qr-reader.is-scanning .qr-placeholder {
    display: none;
}

.qr-placeholder i {
    color: var(--app-green);
    font-size: 3rem;
}

.mobile-action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.touch-btn {
    min-height: 58px;
    font-weight: 800;
}

.touch-btn-sm {
    min-height: 48px;
    font-weight: 800;
}

.btn-primary {
    --bs-btn-bg: var(--app-green);
    --bs-btn-border-color: var(--app-green);
    --bs-btn-hover-bg: var(--app-green-dark);
    --bs-btn-hover-border-color: var(--app-green-dark);
    --bs-btn-active-bg: var(--app-green-dark);
    --bs-btn-active-border-color: var(--app-green-dark);
}

.btn-outline-primary {
    --bs-btn-color: var(--app-green);
    --bs-btn-border-color: var(--app-green);
    --bs-btn-hover-bg: var(--app-green);
    --bs-btn-hover-border-color: var(--app-green);
}

.btn-accent {
    --bs-btn-color: #fff;
    --bs-btn-bg: var(--app-gold);
    --bs-btn-border-color: var(--app-gold);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #9d7a2e;
    --bs-btn-hover-border-color: #9d7a2e;
}

.app-alert {
    border-radius: 8px;
    font-weight: 700;
}

.alert-loading {
    background: #eef5f1;
    border-color: #cdded5;
    color: var(--app-green);
}

.manual-csv,
.raw-result {
    border-color: var(--app-border);
    font-family: Consolas, "Yu Gothic UI", monospace;
    font-size: 0.92rem;
}

.small-label {
    color: var(--app-muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.table-toolbar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.editable-table-wrap,
.dashboard-table-wrap {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fff;
}

.csv-edit-table {
    min-width: 720px;
}

.csv-edit-table td,
.dashboard-table td {
    min-width: 132px;
    padding: 12px;
    vertical-align: middle;
    border-color: var(--app-border);
}

.csv-edit-table td[contenteditable="true"] {
    background: #fff;
    outline: none;
}

.csv-edit-table td[contenteditable="true"]:focus {
    background: #fff8e8;
    box-shadow: inset 0 0 0 2px var(--app-gold);
}

.csv-edit-table .row-selector {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 48px;
    width: 48px;
    text-align: center;
    background: #f2f6f4;
}

.table-head-row td {
    background: var(--app-green-soft);
    color: var(--app-green-dark);
    font-weight: 800;
}

.empty-cell {
    color: var(--app-muted);
    text-align: center;
}

.dashboard-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.dashboard-sidebar {
    background: var(--app-green);
    color: #fff;
    padding: 24px 18px;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 22px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #fff;
    color: var(--app-green);
    font-weight: 900;
}

.side-nav {
    display: grid;
    gap: 8px;
    margin-top: 22px;
}

.side-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.82);
    font-weight: 800;
    text-decoration: none;
}

.side-nav-button {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: left;
}

.side-nav-item:hover,
.side-nav-item.active {
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.dashboard-main {
    min-width: 0;
    padding: 28px;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.dashboard-actions,
.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.summary-card {
    display: grid;
    gap: 8px;
    padding: 18px;
}

.summary-label {
    color: var(--app-muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.summary-card strong {
    font-size: 1.15rem;
}

.status-ok {
    color: var(--app-green);
}

.dashboard-section {
    padding: 20px;
}

.dashboard-table {
    min-width: 820px;
}

.history-list {
    display: grid;
    gap: 10px;
}

.history-item {
    display: grid;
    grid-template-columns: 80px 1fr 150px;
    gap: 12px;
    align-items: center;
    padding: 12px 14px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fbfcfb;
}

.history-id,
.history-source {
    color: var(--app-muted);
    font-weight: 800;
}

.muted-section {
    background: #fafbfa;
}

.muted-text {
    color: var(--app-muted);
}

@media (max-width: 920px) {
    .dashboard-shell {
        grid-template-columns: 1fr;
    }

    .dashboard-sidebar {
        padding: 16px;
    }

    .side-nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .side-nav-item {
        justify-content: center;
    }

    .dashboard-main {
        padding: 18px;
    }

    .dashboard-header,
    .section-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .page-title {
        font-size: 1.35rem;
    }

    .app-card {
        padding: 14px;
    }

    .mobile-action-grid,
    .table-toolbar,
    .side-nav {
        grid-template-columns: 1fr;
    }

    .qr-reader {
        min-height: 260px;
    }

    .history-item {
        grid-template-columns: 1fr;
    }
}

.issue-mobile .mobile-container {
    max-width: 720px;
}

.menu-card {
    min-height: 62vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.issue-menu-grid {
    display: grid;
    gap: 18px;
}

.issue-type-button {
    min-height: 152px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 14px;
    border: 2px solid var(--app-green);
    border-radius: 8px;
    background: #fff;
    color: var(--app-green);
    font-size: 2rem;
    font-weight: 900;
    text-decoration: none;
    box-shadow: 0 10px 28px rgba(31, 77, 58, 0.1);
}

.issue-type-button i {
    font-size: 2.5rem;
}

.issue-type-button:active,
.issue-type-button:hover {
    background: var(--app-green);
    color: #fff;
}

.quantity-input {
    min-width: 150px;
    min-height: 52px;
    font-size: 1.05rem;
    font-weight: 800;
}

.complete-card {
    padding: 28px 18px;
}

.complete-icon {
    color: var(--app-green);
    font-size: 4rem;
}

.complete-title {
    margin: 10px 0 24px;
    color: var(--app-text);
    font-size: 1.6rem;
    font-weight: 900;
}

.complete-detail {
    display: grid;
    gap: 10px;
    text-align: left;
}

.complete-detail div,
.summary-list div {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fbfcfb;
}

.complete-detail dt,
.summary-list dt {
    color: var(--app-muted);
    font-size: 0.82rem;
    font-weight: 800;
}

.complete-detail dd,
.summary-list dd {
    margin: 0;
    color: var(--app-text);
    font-weight: 800;
    overflow-wrap: anywhere;
}

.issue-summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.issue-summary-card {
    display: grid;
    gap: 16px;
}

.summary-list {
    display: grid;
    gap: 10px;
    margin: 0;
}

.admin-form-main {
    max-width: 900px;
    margin: 0 auto;
}

.admin-form-section {
    margin-top: 24px;
}

@media (max-width: 920px) {
    .issue-summary-grid {
        grid-template-columns: 1fr;
    }
}
