<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <title>水稲共済細目書（{{ year }}年度）</title>
    <style>
        @page {
            size: A4 portrait;
            margin: 15mm;
            @bottom-center {
                content: counter(page) " / " counter(pages);
                font-size: 8pt;
                color: #666;
            }
        }
        body {
            font-family: "Noto Sans CJK JP", "Hiragino Kaku Gothic ProN", sans-serif;
            font-size: 9pt;
            line-height: 1.4;
            margin: 0;
        }
        h1 {
            text-align: center;
            font-size: 14pt;
            margin: 0 0 10pt 0;
        }
        table {
            width: 100%;
            border-collapse: collapse;
        }
        th, td {
            border: 1px solid #333;
            padding: 3pt 5pt;
            vertical-align: top;
        }
        th {
            background-color: #f0f0f0;
            font-size: 8pt;
            text-align: center;
            white-space: nowrap;
        }
        td {
            font-size: 8.5pt;
        }
        .num {
            text-align: right;
        }
        .empty {
            color: #999;
        }
    </style>
</head>
<body>
    <h1>水稲共済細目書（{{ year }}年度）</h1>

    <table>
        <thead>
            <tr>
                <th>漢字地名</th>
                <th>耕地-分筆</th>
                <th>本地面積(m2)</th>
                <th>作付品目</th>
                <th>品種</th>
                <th>圃場名称</th>
            </tr>
        </thead>
        <tbody>
            {% for row in rows %}
            <tr>
                <td>{{ row.kanji_name }}</td>
                <td>{{ row.k_s_num }}</td>
                <td class="num">{{ row.area|default:"—" }}</td>
                <td>{% if row.crop %}{{ row.crop }}{% else %}<span class="empty">—</span>{% endif %}</td>
                <td>{% if row.variety %}{{ row.variety }}{% else %}<span class="empty">—</span>{% endif %}</td>
                <td>{% if row.field_name %}{{ row.field_name }}{% else %}<span class="empty">—</span>{% endif %}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</body>
</html>
