:root {
    color-scheme: light;
    --sheet-ink: #1e293b;
    --sheet-muted: #64748b;
    --sheet-line: #cbd5e1;
    --sheet-accent: #7c3aed;
    --sheet-accent-dark: #5b21b6;
    --sheet-bg: #f8fafc;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, sans-serif;
    color: var(--sheet-ink);
    background: var(--sheet-bg);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    min-width: 320px;
    background: var(--sheet-bg);
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

/* メインコンテナ: A4比率を意識した横幅・余白設計（スクロール完全ゼロ） */
.sheet-container {
    width: min(100%, 960px);
    margin: 0 auto;
    padding: 12px 16px 24px;
    background: #ffffff;
    min-height: 100vh;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* ヘッダー操作バー (非印刷) */
.sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--sheet-accent);
    margin-bottom: 12px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--sheet-accent);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    margin-bottom: 4px;
}
.back-link:hover {
    text-decoration: underline;
}

.header-badge {
    display: block;
    font-size: 10px;
    font-weight: 800;
    color: var(--sheet-accent);
    letter-spacing: 0.5px;
}

.sheet-header h1 {
    margin: 2px 0 0;
    font-size: 18px;
    color: var(--sheet-accent-dark);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.control-group {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--sheet-muted);
}

.control-group select {
    height: 32px;
    padding: 2px 6px;
    font-size: 12px;
    border: 1px solid var(--sheet-line);
    border-radius: 4px;
    background: #fff;
    outline: none;
}

.print-action-btn {
    height: 34px;
    padding: 0 14px;
    background: var(--sheet-accent);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
    transition: all 0.15s ease;
}
.print-action-btn:hover {
    background: var(--sheet-accent-dark);
    transform: translateY(-1px);
}

/* 印刷用ヘッダー */
.print-paper-header {
    margin-bottom: 8px;
}

.paper-title-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1.5px solid #0f172a;
    padding-bottom: 4px;
    margin-bottom: 4px;
}

.paper-title-row h2 {
    margin: 0;
    font-size: 16px;
    color: #0f172a;
}

.paper-meta {
    font-size: 11.5px;
    color: #475569;
    display: flex;
    gap: 12px;
}

.paper-notice {
    margin: 0 0 6px 0;
    font-size: 11px;
    color: #475569;
    line-height: 1.4;
}

/* 警察届出＆ガイダンス枠 */
.emergency-guidance-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    background: #fdf2f2;
    border: 1px solid #f87171;
    border-radius: 4px;
    padding: 6px 10px;
    margin-bottom: 10px;
    font-size: 11.5px;
    color: #991b1b;
}

.guidance-col {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.guidance-col a {
    color: inherit;
    font-weight: 700;
}

/* テーブルスタイル (スクロールなし・横幅100%均等) */
.sheet-table-section {
    width: 100%;
    margin-bottom: 12px;
}

.card-print-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10.5px;
    line-height: 1.3;
    background: #ffffff;
    table-layout: fixed !important;
}

.card-print-table th,
.card-print-table td {
    border: 1px solid #94a3b8;
    padding: 4px 4px;
    vertical-align: middle;
    word-break: break-all;
    overflow-wrap: anywhere;
}

.card-print-table th {
    background: #ede9fe;
    color: #4c1d95;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
}

.card-print-table td.center {
    text-align: center;
}

.card-print-table td.tel-cell {
    font-weight: 700;
    color: #0f172a;
    font-family: Consolas, monospace;
    white-space: nowrap;
    text-align: center;
}

.card-print-table td.last4-cell {
    font-family: Consolas, monospace;
    font-weight: 700;
    text-align: center;
    background: #f8fafc;
}

.card-print-table td.status-cell {
    text-align: center;
    white-space: nowrap;
    font-size: 10.5px;
}

.card-print-table tr.row-stopped {
    background: #fef2f2;
}
.card-print-table tr.row-reissuing {
    background: #fffbeb;
}

.empty-notice {
    text-align: center;
    padding: 24px;
    color: var(--sheet-muted);
    font-size: 13px;
}

.sheet-footer {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--sheet-muted);
    border-top: 1px solid var(--sheet-line);
    padding-top: 6px;
}

/* ========================================================
   A4用紙専用 印刷用スタイル（改ページ制御・余白ゼロ）
   ======================================================== */
@page {
    size: A4 portrait;
    margin: 8mm 8mm 8mm 8mm;
}

@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }
    .sheet-container {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        min-height: 0 !important;
    }
    .no-print {
        display: none !important;
    }
    .card-print-table th {
        background: #f1f5f9 !important;
        color: #000 !important;
        border: 1px solid #475569 !important;
    }
    .card-print-table td {
        border: 1px solid #64748b !important;
        color: #000 !important;
    }
    .emergency-guidance-box {
        background: #fff !important;
        border: 1.5px solid #000 !important;
        color: #000 !important;
    }
    .card-print-table tr {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

