<!DOCTYPE html>
<html lang="ja">
<head>
    <meta charset="UTF-8">
    <title>中山間地域等直接支払交付金（{{ year }}年度）</title>
    <style>
        @page {
            size: A4 landscape;
            margin: 10mm;
            @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: 8pt;
            line-height: 1.3;
            margin: 0;
        }
        h1 {
            text-align: center;
            font-size: 13pt;
            margin: 0 0 8pt 0;
        }
        table {
            width: 100%;
            border-collapse: collapse;
        }
        th, td {
            border: 1px solid #333;
            padding: 2pt 4pt;
            vertical-align: top;
        }
        th {
            background-color: #f0f0f0;
            font-size: 7pt;
            text-align: center;
            white-space: nowrap;
        }
        td {
            font-size: 7.5pt;
        }
        .num {
            text-align: right;
        }
        .empty {
            color: #999;
        }
    </style>
</head>
<body>
    <h1>中山間地域等直接支払交付金（{{ year }}年度）</h1>

    <table>
        <thead>
            <tr>
                <th>所在地</th>
                <th>植栽面積(m2)</th>
                <th>作付品目(元)</th>
                <th>協定管理者</th>
                <th>所有者</th>
                <th>作物</th>
                <th>品種</th>
                <th>圃場名称</th>
            </tr>
        </thead>
        <tbody>
            {% for row in rows %}
            <tr>
                <td>{{ row.location }}</td>
                <td class="num">{{ row.planting_area|default:"—" }}</td>
                <td>{{ row.original_crop|default:"—" }}</td>
                <td>{{ row.manager|default:"—" }}</td>
                <td>{{ row.owner|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>
