body {
    margin: 0;
    font-family: sans-serif;
    background: #f6f5f0;
}

/* ========================================
ヘッダー（サイドバー導入によりスマホ幅でのみ表示するバー）
======================================== */

.header {
    background: transparent;
    padding: 0;
    display: flex;
    align-items: center;
}

.header h1 {
    display: none;
}
/* ========================================
ハンバーガーボタン（スマホ幅用）
======================================== */

.hamburger-btn {
    background: transparent;
    border: none;
    width: 28px;
    height: 22px;
    padding: 0;
    margin-right: 16px;
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    justify-content: space-between;
    flex-shrink: 0;
}

.hamburger-btn span {
    display: block;
    height: 3px;
    width: 100%;
    background: white;
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

.hamburger-btn.open span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.hamburger-btn.open span:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.open span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

.menu-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s;
    z-index: 998;
}

.menu-overlay.open {
    opacity: 1;
    visibility: visible;
}

/* ========================================
左サイドバー（かわべ養魚場ブランドカラー）
======================================== */

.side-menu {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 220px;
    background: #1f4d3d;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 999;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 15px rgba(0,0,0,0.2);
}

.side-menu.open {
    transform: translateX(0);
}

.sidebar-logo {
    padding: 28px 16px 20px 16px;
    display: flex;
    justify-content: center;
}

.sidebar-logo img {
    width: 96px;
    height: 96px;
    object-fit: contain;
    background: white;
    border-radius: 0;
    padding: 8px;
}

.side-menu ul {
    list-style: none;
    margin: 0;
    padding: 6px 0 6px 10px;
    flex: 1;
    overflow-y: auto;
}

.side-menu li {
    margin-bottom: 2px;
}

.side-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    color: #cfe3d8;
    text-decoration: none;
    font-size: 13.5px;
    border-radius: 8px 0 0 8px;
}

.menu-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.7;
}

.side-menu li a:hover {
    background: rgba(255,255,255,0.08);
}

.side-menu li a.active {
    background: #f6f5f0;
    color: #1f4d3d;
    font-weight: bold;
}

.sidebar-logout-item {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid rgba(255,255,255,0.15);
}

.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 14px;
    background: transparent;
    color: #cfe3d8;
    text-decoration: none;
    font-size: 13.5px;
    border: none;
    border-radius: 8px 0 0 8px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
}

.sidebar-logout-btn:hover {
    background: rgba(255,255,255,0.08);
}

/* ========================================
デスクトップ・タブレット幅：サイドバー常時表示
======================================== */

@media screen and (min-width: 769px) {

    body.has-sidebar {
        padding-left: 220px;
    }

    body.has-sidebar .side-menu {
        transform: none;
        box-shadow: none;
    }

    body.has-sidebar .hamburger-btn,
    body.has-sidebar .menu-overlay {
        display: none;
    }

}

/* ========================================
全体
======================================== */

.container {
    padding: 20px;
}

/* ========================================
メイン横並び
======================================== */

.main-flex {
    display: flex;
    gap: 20px;
    align-items: stretch;
}

/* ========================================
左：受注入力
======================================== */

.order-form {
    flex: 1;
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
}

/* ========================================
右：カード
======================================== */

.dashboard-area {
    flex: 1;
}

/* ========================================
カードグリッド
======================================== */

.card-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

/* ========================================
カードリンク
======================================== */

.card-link {
    text-decoration: none;
    color: inherit;
}

/* ========================================
カード
======================================== */

.info-card {
    color: white;
    padding: 18px 20px;
    border-radius: 12px;
    min-height: 96px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    cursor: pointer;
    transition:
        transform 0.2s,
        filter 0.2s,
        box-shadow 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    box-sizing: border-box;
}

.info-card:hover {
    transform: translateY(-5px);
    filter: brightness(0.95);
    box-shadow: 0 10px 20px rgba(0,0,0,0.15);
}

.info-card-text {
    flex: 1;
    min-width: 0;
}

.blue {
    background: #2563eb;
    color: white;
}

.blue h2,
.blue .big-number,
.blue p {
    color: white;
}

.white {
    background: white;
    color: #1f2937;
}

.gray h2 {
    color: #6b7280;
}

.gray .big-number {
    color: #16a34a;
}

.dark-slate {
    background: #374151;
    color: white;
}

.dark-slate .card-icon {
    color: #86efac;
    opacity: 1;
}

.dark-slate h2,
.dark-slate .big-number,
.dark-slate p {
    color: white;
}

.info-card h2 {
    margin: 0;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.big-number {
    margin-top: 8px;
    font-size: 30px;
    font-weight: bold;
}

.card-icon {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.5;
    opacity: 0.45;
    color: #1f2937;
}

/* ========================================
フォーム
======================================== */

.product-box {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 20px;
}

.form-group {
    flex: 1;
    margin-bottom: 20px;
}

/* 商品・数量・単位の3列（トップページの注文行）
   商品名は長いので広めに、数量は狭めに調整 */
.product-row.form-row {
    align-items: start;
}

.product-row .form-group:nth-child(1) {
    flex: 2.4;
}

.product-row .form-group:nth-child(2) {
    flex: 0.6;
}

.product-row .form-group:nth-child(3) {
    flex: 0.9;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
}

select,
input:not([type="checkbox"]):not([type="radio"]) {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    box-sizing: border-box;
}

/* チェックボックス・ラジオボタンは上記の「幅100%」対象から外し、
   ネイティブのサイズのまま表示する（そのままだと巨大化・中央寄りに
   表示されて配置が崩れてしまうため） */
input[type="checkbox"],
input[type="radio"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    accent-color: #16a34a;
}

/* ========================================
ボタン
======================================== */

button {
    background: #16a34a;
    color: white;
    border: none;
    padding: 14px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    width: 100%;
    transition: 0.2s;
}

button:hover {
    background: #15803d;
}

/* ========================================
テーブル
======================================== */

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    table-layout: auto;
}

table th {
    background: #16a34a;
    color: white;
    text-align: left;
    padding: 14px;
    font-size: 14px;
    white-space: nowrap;
}

table td {
    padding: 12px 14px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
    white-space: nowrap;
    vertical-align: middle;
}

table th.col-qty,
table td.col-qty,
table th.col-num,
table td.col-num {
    text-align: right;
}

table th.col-unit,
table td.col-unit {
    text-align: left;
}

table th.col-date,
table td.col-date {
    width: 120px;
}

table th.col-item,
table td.col-item {
    white-space: normal;
    min-width: 160px;
}

table th.col-note,
table td.col-note {
    white-space: normal;
    min-width: 260px;
}

.note-input {
    width: 100%;
    min-width: 240px;
    min-height: 54px;
    padding: 6px 8px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    resize: vertical;
}

.note-input:focus {
    outline: none;
    border-color: #16a34a;
}

table tr:hover {
    background: #f9fafb;
}

.customer-link {
    color: #16a34a;
    text-decoration: none;
    font-weight: bold;
}

.customer-link:hover {
    text-decoration: underline;
}

/* ========================================
状態バッジ
======================================== */

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
}

.status-badge.status-received {
    background: #dbeafe;
    color: #1d4ed8;
}

.status-badge.status-shipping {
    background: #ffedd5;
    color: #c2410c;
}

.status-badge.status-done {
    background: #dcfce7;
    color: #15803d;
}

.status-badge.status-cancelled {
    background: #fee2e2;
    color: #b91c1c;
}

/* ========================================
休館表示
======================================== */

.holiday-text {
    margin-top: 4px;
    font-size: 12px;
    opacity: 0.9;
}

/* ========================================
スマホ
======================================== */

@media screen and (max-width: 768px) {

    .main-flex {
        flex-direction: column;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        flex-direction: column;
    }

    /* 受注入力（index）の商品・数量・単位は改行せず横並びのままにする
       （スクロール量を減らすため。デスクトップと同じ比率のまま、
       余白・文字サイズだけスマホ用に小さくする） */
    .product-box .product-row.form-row {
        flex-direction: row;
        gap: 8px;
    }

    .product-box .product-row .form-group {
        margin-bottom: 16px;
    }

    .product-box .product-row .form-group label {
        font-size: 12px;
        margin-bottom: 4px;
    }

    .product-box .product-row select,
    .product-box .product-row input {
        padding: 8px;
        font-size: 14px;
    }

    /* 登録フォームのテーブルなどは従来通り横スクロール */
    table:not(.master-table) {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    /* ========================================
    一覧テーブル（受注一覧・配送一覧・やまめ/ます等の
    カテゴリ別一覧・受注履歴）はスマホでは横スクロール表の
    代わりに「1行=1カード」の縦積みレイアウトに変える
    ======================================== */

    table.master-table {
        display: block !important;
        box-shadow: none;
        background: transparent;
        border-radius: 0;
        /* master.css 側の min-width:700px（管理画面のテーブル用指定）を
           上書きして、スマホ幅でも横スクロールなしでカード表示できるようにする */
        min-width: 0 !important;
        width: 100% !important;
        border: none;
    }

    /* .table-scroll（横スクロール用ラッパー）自体も
       スマホでは横スクロールさせない */
    .table-scroll {
        overflow-x: visible !important;
        width: 100% !important;
    }

    table.master-table th,
    table.master-table td {
        border: none;
    }

    table.master-table thead {
        display: none;
    }

    table.master-table tbody {
        display: block;
    }

    table.master-table tr {
        display: block;
        background: white;
        margin-bottom: 12px;
        border: 1px solid #e5e7eb;
        border-radius: 10px;
        padding: 4px 14px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.05);
    }

    table.master-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 10px 0;
        border-bottom: 1px solid #f3f4f6;
        white-space: normal;
        text-align: right;
        font-size: 14px;
    }

    table.master-table td:last-child {
        border-bottom: none;
    }

    table.master-table td:empty {
        display: none;
    }

    table.master-table td::before {
        content: attr(data-label);
        font-weight: bold;
        color: #6b7280;
        font-size: 12px;
        text-align: left;
        flex-shrink: 0;
    }

    table.master-table td:not([data-label])::before {
        content: "";
    }

    /* 入力欄やボタン、複数ボタンを含むセルはラベルの下に
    縦積みで表示（横だと窮屈になるため） */
    table.master-table td:has(input),
    table.master-table td:has(select),
    table.master-table td:has(textarea),
    table.master-table td:has(button) {
        flex-direction: column;
        align-items: flex-start;
    }

    table.master-table td:has(input)::before,
    table.master-table td:has(select)::before,
    table.master-table td:has(textarea)::before,
    table.master-table td:has(button)::before {
        margin-bottom: 6px;
    }

    /* チェックボックス単体のセル（一覧の「選択」列など）は縦積みにせず、
       ラベルと横並びのまま右側に小さく表示する */
    table.master-table td:has(input[type="checkbox"]):not(:has(input:not([type="checkbox"]))) {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    table.master-table td:has(input[type="checkbox"]):not(:has(input:not([type="checkbox"])))::before {
        margin-bottom: 0;
    }

    /* 配送一覧：同じ取引先で商品が複数行にまたがる場合、
    2品目以降の行は1つのカードの続きに見えるようにつなげる */
    table.master-table tr.group-first-row {
        margin-bottom: 0;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }

    table.master-table tr.group-continue-row {
        margin-top: -1px;
        border-top: none;
        border-top-left-radius: 0;
        border-top-right-radius: 0;
        padding-top: 0;
    }

    table.master-table tr.group-continue-row:last-of-type {
        margin-bottom: 12px;
    }

}
/* ========================================
配送カレンダー
======================================== */

.delivery-calendar {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    padding: 12px 16px;
    margin-bottom: 14px;
}

.delivery-calendar .cal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.delivery-calendar .cal-header span {
    font-size: 15px;
    font-weight: bold;
    color: #1f2937;
}

.delivery-calendar .cal-nav-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 6px;
    background: #f3f4f6;
    color: #1f2937;
    font-size: 14px;
}

.delivery-calendar .cal-nav-btn:hover {
    background: #e5e7eb;
}

.delivery-calendar .cal-weekdays,
.delivery-calendar .cal-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
}

.delivery-calendar .cal-weekdays {
    margin-bottom: 6px;
}

.delivery-calendar .cal-weekday {
    text-align: center;
    font-size: 11px;
    color: #6b7280;
    padding: 2px 0;
}

.delivery-calendar .cal-cell {
    border-radius: 8px;
    padding: 3px 2px;
    min-height: 32px;
    border: 1px solid #e5e7eb;
    text-align: center;
}

.delivery-calendar .cal-cell.is-closed {
    background: #f9fafb;
}

.delivery-calendar .cal-cell.is-today {
    border: 2px solid #16a34a;
}

.delivery-calendar .cal-date {
    font-size: 11px;
    color: #1f2937;
}

.delivery-calendar .cal-cell.is-closed .cal-date {
    color: #9ca3af;
}

.delivery-calendar .cal-count {
    font-size: 12px;
    font-weight: bold;
    color: #1f2937;
    margin-top: 2px;
}

.delivery-calendar .cal-closed-label {
    font-size: 10px;
    color: #9ca3af;
    margin-top: 2px;
}