/* ec_reconcile - freee-inspired design */
:root {
    --nav-blue: #2864f0;
    --nav-blue-dark: #1f52c8;
    --nav-blue-light: #3d7af5;
    --nav-active-bg: rgba(255, 255, 255, 0.18);
    --primary: #2864f0;
    --primary-dark: #1f52c8;
    --primary-light: #e8f0fe;
    --bg: #eef1f6;
    --card-bg: #ffffff;
    --surface: #ffffff;
    --dropdown-bg: #ffffff;
    --table-header-bg: #f5f7fa;
    --input-bg: #ffffff;
    --btn-secondary-bg: #ffffff;
    --muted-bg: #f8fafc;
    --text: #333333;
    --text-muted: #6b7280;
    --border: #dce1e8;
    --danger: #e53935;
    --warning: #f59e0b;
    --info: #2864f0;
    --section-bar: #5f6368;
    --focus-ring: rgba(40, 100, 240, 0.15);
}

html.theme-dark {
    color-scheme: dark;
    --nav-blue: #15202b;
    --nav-blue-dark: #0d141c;
    --nav-blue-light: #243447;
    --nav-active-bg: rgba(125, 211, 252, 0.16);
    --primary: #7dd3fc;
    --primary-dark: #38bdf8;
    --primary-light: #1b3344;
    --bg: #0f1419;
    --card-bg: #1a222c;
    --surface: #151c24;
    --dropdown-bg: #1a222c;
    --table-header-bg: #151c24;
    --input-bg: #121820;
    --btn-secondary-bg: #243040;
    --muted-bg: #151c24;
    --text: #e8eef4;
    --text-muted: #9aa8b5;
    --border: #2d3a47;
    --danger: #f87171;
    --warning: #fbbf24;
    --info: #7dd3fc;
    --section-bar: #243040;
    --focus-ring: rgba(125, 211, 252, 0.28);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ===== App Shell (freee top nav) ===== */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar-utility {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    height: 36px;
}

.topbar-utility-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 20px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    font-size: 12px;
    color: var(--text-muted);
}

.topbar-utility-inner a {
    color: var(--text-muted);
}

.topbar-utility-inner a:hover {
    color: var(--primary);
}

.utility-company {
    display: flex;
    align-items: center;
    gap: 6px;
}

.utility-company label {
    color: var(--text-muted);
}

.utility-company select {
    font-size: 12px;
    height: 24px;
    max-width: 180px;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 0 6px;
    color: var(--text);
    background: var(--input-bg);
}

.utility-company-name {
    color: var(--text);
    font-weight: 600;
}

.topbar-nav {
    background: var(--nav-blue);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
    position: sticky;
    top: 0;
    z-index: 200;
}

.topbar-nav-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 16px;
    display: flex;
    align-items: stretch;
    min-height: 64px;
}

.brand-logo {
    display: flex;
    align-items: center;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    padding: 0 20px 0 8px;
    white-space: nowrap;
    letter-spacing: -0.02em;
}

.brand-logo:hover {
    color: #fff;
    opacity: 0.9;
}

.main-nav {
    display: flex;
    align-items: stretch;
    flex: 1;
    gap: 2px;
}

.main-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 14px;
    min-width: 72px;
    color: rgba(255, 255, 255, 0.9);
    font-size: 11px;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 0;
    text-decoration: none;
}

.main-nav-item:hover,
.main-nav-item.active {
    background: var(--nav-active-bg);
    color: #fff;
}

.nav-label {
    white-space: nowrap;
}

/* Nav icons (CSS shapes) */
.nav-icon {
    width: 22px;
    height: 22px;
    display: block;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.95;
}

.nav-icon-home {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 24 24'%3E%3Cpath d='M10 20v-6h4v6h5v-8h3L12 3 2 12h3v8z'/%3E%3C/svg%3E");
}
.nav-icon-match {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 24 24'%3E%3Cpath d='M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm2 16H8v-2h8v2zm0-4H8v-2h8v2zm-3-5V3.5L18.5 9H13z'/%3E%3C/svg%3E");
}
.nav-icon-alert {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 24 24'%3E%3Cpath d='M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z'/%3E%3C/svg%3E");
}
.nav-icon-refund {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 24 24'%3E%3Cpath d='M12 5V1L7 6l5 5V7c3.31 0 6 2.69 6 6s-2.69 6-6 6-6-2.69-6-6H4c0 4.42 3.58 8 8 8s8-3.58 8-8-3.58-8-8-8z'/%3E%3C/svg%3E");
}
.nav-icon-lock {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 24 24'%3E%3Cpath d='M18 8h-1V6c0-2.76-2.24-5-5-5S7 3.24 7 6v2H6c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V10c0-1.1-.9-2-2-2zm-6 9c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2zm3.1-9H8.9V6c0-1.71 1.39-3.1 3.1-3.1 1.71 0 3.1 1.39 3.1 3.1v2z'/%3E%3C/svg%3E");
}
.nav-icon-upload {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 24 24'%3E%3Cpath d='M9 16h6v-6h4l-7-7-7 7h4v6zm-4 2h14v2H5v-2z'/%3E%3C/svg%3E");
}
.nav-icon-import {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 24 24'%3E%3Cpath d='M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm4 18H6V4h7v5h5v11z'/%3E%3Cpath d='M8 12h8v2H8zm0 4h8v2H8zm0-8h5v2H8z'/%3E%3C/svg%3E");
}
.nav-icon-return {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 24 24'%3E%3Cpath d='M19 7v4H5.83l3.58-3.59L8 6l-6 6 6 6 1.41-1.41L5.83 13H21V7h-2z'/%3E%3C/svg%3E");
}
.nav-icon-check {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 24 24'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
}
.nav-icon-list {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 24 24'%3E%3Cpath d='M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z'/%3E%3C/svg%3E");
}
.nav-icon-mall {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 24 24'%3E%3Cpath d='M7 18c-1.1 0-1.99.9-1.99 2S5.9 22 7 22s2-.9 2-2-.9-2-2-2zM1 2v2h2l3.6 7.59-1.35 2.45c-.16.28-.25.61-.25.96 0 1.1.9 2 2 2h12v-2H7.42c-.14 0-.25-.11-.25-.25l.03-.12.9-1.63h7.45c.75 0 1.41-.41 1.75-1.03l3.58-6.49A1.003 1.003 0 0020 4H5.21l-.94-2H1zm16 16c-1.1 0-1.99.9-1.99 2s.89 2 1.99 2 2-.9 2-2-.9-2-2-2z'/%3E%3C/svg%3E");
}
.nav-icon-log {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 24 24'%3E%3Cpath d='M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm-5 14H7v-2h7v2zm3-4H7v-2h10v2zm0-4H7V7h10v2z'/%3E%3C/svg%3E");
}
.nav-icon-history {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 24 24'%3E%3Cpath d='M13 3a9 9 0 00-9 9H1l3.89 3.89.07.14L9 12H6c0-3.87 3.13-7 7-7s7 3.13 7 7-3.13 7-7 7c-1.93 0-3.68-.79-4.94-2.06l-1.42 1.42A8.954 8.954 0 0013 21a9 9 0 000-18zm-1 5v5l4.28 2.54.72-1.21-3.5-2.08V8H12z'/%3E%3C/svg%3E");
}
.nav-icon-settings {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 24 24'%3E%3Cpath d='M19.14 12.94c.04-.31.06-.63.06-.94 0-.31-.02-.63-.06-.94l2.03-1.58a.49.49 0 00.12-.61l-1.92-3.32a.488.488 0 00-.59-.22l-2.39.96c-.5-.38-1.03-.7-1.62-.94l-.36-2.54a.484.484 0 00-.48-.41h-3.84c-.24 0-.43.17-.47.41l-.36 2.54c-.59.24-1.13.57-1.62.94l-2.39-.96c-.22-.08-.47 0-.59.22L2.74 8.87c-.12.21-.08.47.12.61l2.03 1.58c-.04.31-.06.63-.06.94s.02.63.06.94l-2.03 1.58a.49.49 0 00-.12.61l1.92 3.32c.12.22.37.29.59.22l2.39-.96c.5.38 1.03.7 1.62.94l.36 2.54c.05.24.24.41.48.41h3.84c.24 0 .44-.17.47-.41l.36-2.54c.59-.24 1.13-.56 1.62-.94l2.39.96c.22.08.47 0 .59-.22l1.92-3.32c.12-.22.07-.47-.12-.61l-2.01-1.58zM12 15.6c-1.98 0-3.6-1.62-3.6-3.6s1.62-3.6 3.6-3.6 3.6 1.62 3.6 3.6-1.62 3.6-3.6 3.6z'/%3E%3C/svg%3E");
}

.nav-icon-pdf {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 24 24'%3E%3Cpath d='M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6zm2 16h-3v-2h3v-2h-3v-2h3V10h-5v8h5v-2zm3-8V3.5L18.5 9H19z'/%3E%3C/svg%3E");
}

/* Settings dropdown */
.nav-settings {
    position: relative;
    margin-left: auto;
}

.nav-settings-btn {
    height: 100%;
}

.settings-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 200px;
    background: var(--dropdown-bg);
    border: 1px solid var(--border);
    border-radius: 0 0 6px 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 300;
    padding: 6px 0;
}

.nav-settings.open .settings-dropdown {
    display: block;
}

.nav-settings.open .nav-settings-btn {
    background: var(--nav-active-bg);
}

.settings-dropdown-item {
    display: block;
    padding: 10px 20px;
    color: var(--text);
    font-size: 13px;
    transition: background 0.1s;
}

.settings-dropdown-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.settings-dropdown-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

/* Reconciliation submenu (hover) */
.nav-submenu {
    position: relative;
}

.nav-submenu-btn {
    height: 100%;
}

.nav-submenu-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 240px;
    background: var(--dropdown-bg);
    border: 1px solid var(--border);
    border-radius: 0 0 6px 6px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    z-index: 300;
    padding: 6px 0;
}

.nav-submenu:hover .nav-submenu-dropdown,
.nav-submenu:focus-within .nav-submenu-dropdown {
    display: block;
}

.nav-submenu:hover .nav-submenu-btn,
.nav-submenu:focus-within .nav-submenu-btn {
    background: var(--nav-active-bg);
}

.nav-submenu-dropdown-item {
    display: block;
    padding: 10px 20px;
    color: var(--text);
    font-size: 13px;
    transition: background 0.1s;
    white-space: nowrap;
}

.nav-submenu-dropdown-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-submenu-dropdown-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

/* Page content */
.page-main {
    flex: 1;
    max-width: 1280px;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px 40px;
}

.page-header {
    padding: 20px 0 8px;
}

.page-header h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}

.page-header-meta {
    margin: 4px 0 0;
    font-size: 12px;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 0.01em;
}

.page-header-meta-item {
    margin-left: 6px;
}

.page-header-meta-sep {
    margin: 0 2px;
    color: #c4c9d1;
}

.content {
    padding: 8px 0 24px;
}

/* Section bar (freee report style) */
.section-bar {
    background: var(--section-bar);
    color: #fff;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 16px;
    border-radius: 2px;
}

.card {
    background: var(--card-bg);
    border-radius: 4px;
    border: 1px solid var(--border);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--card-bg);
    border-radius: 4px;
    border: 1px solid var(--border);
    padding: 20px;
    border-top: 3px solid var(--primary);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.summary-card.danger { border-top-color: var(--danger); }
.summary-card.warning { border-top-color: var(--warning); }
.summary-card.info { border-top-color: var(--info); }

.summary-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.summary-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
}

/* 返品登録画面: フルHD向け固定幅・中央寄せ */
.return-register-layout {
    width: 1200px;
    max-width: 100%;
    margin: 0 auto;
}

.return-register-search .form-control {
    width: 50%;
}

.return-register-layout select.form-control {
    width: 50%;
}

.return-register-layout .summary-grid {
    grid-template-columns: 1fr 1.2fr 2fr 1fr 1fr;
}

/* 返品編集・照合の概要: 5列固定でセルを広めに */
.page-main:has(.return-order-summary-grid) {
    max-width: 1520px;
}

/* 返品一覧: 列が多く折り返しやすいのでページ幅を広げる */
.page-main:has(.return-list-layout) {
    max-width: 1760px;
}

.return-list-layout table.data-table {
    min-width: 1520px;
}

.return-list-layout table.data-table td {
    white-space: nowrap;
}

.return-list-layout .return-list-actions {
    white-space: nowrap;
}

/* 返金リスト: 対象列を1行で表示できるよう、一覧の枠と列幅を広げる */
.page-main:has(.refund-list-layout) {
    max-width: 1760px;
}

.refund-list-layout table.data-table {
    min-width: 1640px;
}

.refund-list-layout table.data-table td:nth-child(2),
.refund-list-layout table.data-table td:nth-child(4),
.refund-list-layout table.data-table td:nth-child(8),
.refund-list-layout table.data-table td:nth-child(9) {
    white-space: nowrap;
}

.refund-list-layout table.data-table th:nth-child(2),
.refund-list-layout table.data-table td:nth-child(2) {
    min-width: 110px;
}

.refund-list-layout table.data-table th:nth-child(4),
.refund-list-layout table.data-table td:nth-child(4),
.refund-list-layout table.data-table th:nth-child(8),
.refund-list-layout table.data-table td:nth-child(8) {
    min-width: 116px;
}

.refund-list-layout table.data-table th:nth-child(9),
.refund-list-layout table.data-table td:nth-child(9) {
    min-width: 126px;
}

.refund-list-layout .badge {
    white-space: nowrap;
}

.return-order-summary-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 16px 18px;
}

.return-order-summary-grid .summary-card {
    padding: 16px 18px;
    min-width: 0;
}

.return-order-summary-grid .summary-value {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.return-register-layout .summary-value {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.existing-return-notice {
    margin-bottom: 24px;
}

.existing-return-notice-inner {
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.existing-return-notice-text {
    margin: 0;
}

.return-register-layout .form-static {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.summary-value.currency::before {
    content: '¥';
    font-size: 16px;
    margin-right: 2px;
}

.table-wrap { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

table.data-table th {
    background: var(--table-header-bg);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
    color: var(--text);
}

a.sort-link {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

a.sort-link:hover {
    color: var(--primary);
}

a.sort-link.is-active {
    color: var(--primary);
}

.sort-arrow {
    font-size: 10px;
    line-height: 1;
}

table.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

table.data-table.data-table-center th,
table.data-table.data-table-center td {
    text-align: center;
}

table.data-table tr:hover td {
    background: var(--primary-light);
}

table.data-table tr.clickable-row {
    cursor: pointer;
}

table.data-table tr.clickable-row:focus,
table.data-table tr.clickable-row:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge.badge-matched { background: #16a34a; color: #ffffff; }
.badge-danger { background: #dc2626; color: #ffffff; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f3f4f6; color: #4b5563; }
.badge-uncollected { background: #fef9c3; color: #854d0e; }
.badge-closed { background: #7c3aed; color: #ffffff; }

button.api-import-status-error {
    border: 0;
    cursor: pointer;
    font: inherit;
    line-height: inherit;
    padding: 2px 8px;
}

.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    color: #fff;
}

.import-submit-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

.import-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    margin: 0;
}

.import-toggle-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.import-toggle-slider {
    position: relative;
    width: 44px;
    height: 24px;
    background: #cbd5e1;
    border-radius: 999px;
    transition: background 0.15s;
    flex-shrink: 0;
}

.import-toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.25);
    transition: transform 0.15s;
}

.import-toggle.is-on .import-toggle-slider,
.import-toggle-input:checked + .import-toggle-slider {
    background: var(--primary);
}

.import-toggle.is-on .import-toggle-slider::after,
.import-toggle-input:checked + .import-toggle-slider::after {
    transform: translateX(20px);
}

.import-toggle-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.import-toggle-label {
    font-size: 13px;
    font-weight: 500;
}

.import-toggle-state {
    font-size: 12px;
    color: var(--muted, #64748b);
}

.import-toggle.is-on .import-toggle-state {
    color: var(--primary);
    font-weight: 600;
}

.btn-secondary {
    background: var(--btn-secondary-bg);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    cursor: pointer;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    color: var(--text);
    background: var(--input-bg);
}

.search-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.search-form .form-group {
    margin-bottom: 0;
}

.search-form input[type="month"].form-control {
    width: 160px;
}

.diff-amount-trigger {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.diff-amount-trigger:hover {
    opacity: 0.8;
}

.diff-amount-trigger[aria-expanded="true"] {
    font-weight: 600;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-static {
    padding: 8px 0;
    font-size: 14px;
    color: var(--text);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.form-row .form-group {
    margin-bottom: 0;
}

.messages {
    margin-bottom: 16px;
}

.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 13px;
}

.alert-success { background: #d1fae5; color: #065f46; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info { background: #dbeafe; color: #1e40af; }

.text-danger { color: var(--danger) !important; }

.card-match-alert {
    border: 1px solid #fecaca;
    background: #fff7f7;
}

.card-match-alert .card-title {
    color: var(--danger);
    display: flex;
    align-items: center;
    gap: 8px;
}

table.data-table tr.row-match-alert td {
    background: #fee2e2;
    color: #991b1b;
    font-weight: 600;
}

table.data-table tr.row-match-alert:hover td {
    background: #fecaca;
}

table.data-table tr.row-return-match td {
    background: #fef3c7;
    color: #92400e;
}

table.data-table tr.row-return-match:hover td {
    background: #fde68a;
}

.rematch-notices .rematch-export-links {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}
.rematch-notices .rematch-export-links a {
    font-weight: 600;
    text-decoration: underline;
}

.chart-container {
    position: relative;
    height: 300px;
}

.chart-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.filter-bar {
    display: flex;
    gap: 12px;
    align-items: end;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar-form {
    display: flex;
    gap: 12px;
    align-items: end;
    flex-wrap: wrap;
}

.filter-bar-inline .filter-bar-form {
    flex-wrap: nowrap;
    align-items: flex-end;
}

.filter-bar-inline .form-group {
    flex: 0 0 auto;
}

.filter-bar-inline .form-group label {
    white-space: nowrap;
}

.filter-bar-inline input[type="date"].form-control {
    width: 150px;
}

.filter-bar-inline select.form-control {
    width: 120px;
}

.filter-bar-inline .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.filter-bar .form-group { margin-bottom: 0; }

.filter-bar .year-month-cal {
    width: 160px;
}

.trend-cell {
    text-align: center;
    white-space: nowrap;
    width: 2.5em;
}

.trend-arrow {
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
}

.trend-up { color: #16a34a; }
.trend-up-sm { color: #4ade80; }
.trend-flat { color: #94a3b8; }
.trend-down-sm { color: #fb923c; }
.trend-down { color: #ef4444; }

html.theme-dark .trend-up { color: #4ade80; }
html.theme-dark .trend-up-sm { color: #86efac; }
html.theme-dark .trend-flat { color: #94a3b8; }
html.theme-dark .trend-down-sm { color: #fdba74; }
html.theme-dark .trend-down { color: #f87171; }

.filter-bar-with-totals {
    justify-content: space-between;
    align-items: flex-end;
}

.collection-search-totals {
    display: grid;
    grid-template-columns: auto auto minmax(8em, auto);
    gap: 6px 12px;
    align-items: baseline;
    justify-items: end;
    margin-left: auto;
    flex-shrink: 0;
}

.collection-search-total-label,
.collection-search-total-count {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.collection-search-total-count {
    font-variant-numeric: tabular-nums;
}

.collection-search-total-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-card {
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    padding: 40px;
    width: 400px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.login-card h2 {
    text-align: center;
    margin-bottom: 8px;
    color: var(--primary);
}

.login-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 24px;
    font-size: 13px;
}

.auth-heading {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text);
}

.auth-message {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 8px;
}

.match-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.match-compare .card.mismatch {
    border-color: var(--danger);
    background: #fef2f2;
}

.panel-subnav {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
    flex-wrap: wrap;
}

.panel-subnav a {
    padding: 10px 16px;
    font-size: 13px;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s;
}

.panel-subnav a:hover,
.panel-subnav a.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.panel-link-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 20px;
    transition: all 0.15s;
    color: var(--text);
}

.panel-link-card:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 12px rgba(40, 100, 240, 0.12);
    color: var(--text);
}

.panel-link-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 6px;
    color: var(--primary);
}

.panel-link-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.checkbox-group ul {
    list-style: none;
    padding: 0;
}

.checkbox-group li {
    margin-bottom: 6px;
}

.checkbox-group label {
    font-weight: normal;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Import status indicator (freee style) */
.section-bar-sub {
    font-weight: 400;
    font-size: 12px;
    opacity: 0.85;
    margin-left: 12px;
}

.import-summary-strip {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.import-summary-item {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 12px 24px;
    display: flex;
    align-items: baseline;
    gap: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.import-summary-item.done { border-left: 3px solid #2864f0; }
.import-summary-item.missing { border-left: 3px solid #e53935; }
.import-summary-item.warning { border-left: 3px solid #f59e0b; }
.import-summary-item.total { border-left: 3px solid #9ca3af; }

.import-summary-num {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
}

.import-summary-label {
    font-size: 12px;
    color: var(--text-muted);
}

.import-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.import-status-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 18px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s, transform 0.2s;
}

.import-status-card:hover {
    box-shadow: 0 4px 16px rgba(40, 100, 240, 0.1);
    transform: translateY(-1px);
}

.import-status-card.status-done { border-top: 3px solid #2864f0; }
.import-status-card.status-missing { border-top: 3px solid #e53935; }
.import-status-card.status-partial { border-top: 3px solid #f59e0b; }
.import-status-card.status-error { border-top: 3px solid #dc2626; }

.import-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.import-mall-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.import-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 10px;
}

.import-badge-done { background: #e8f0fe; color: #2864f0; }
.import-badge-missing { background: #fee2e2; color: #dc2626; }
.import-badge-partial { background: #fef3c7; color: #d97706; }
.import-badge-error { background: #fecaca; color: #991b1b; }

.import-ring-wrap {
    position: relative;
    width: 88px;
    height: 88px;
    margin: 0 auto 12px;
}

.import-ring {
    width: 88px;
    height: 88px;
    transform: rotate(-90deg);
}

.import-ring-bg {
    fill: none;
    stroke: #eef1f6;
    stroke-width: 3;
}

.import-ring-fill {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
}

.import-ring-fill.status-done { stroke: #2864f0; }
.import-ring-fill.status-missing { stroke: #e53935; }
.import-ring-fill.status-partial { stroke: #f59e0b; }
.import-ring-fill.status-error { stroke: #dc2626; }

.import-ring-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.import-ring-count {
    font-size: 20px;
    font-weight: 700;
    line-height: 1;
    color: var(--text);
}

.import-ring-unit {
    font-size: 10px;
    color: var(--text-muted);
}

.import-card-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 12px;
    padding: 0 4px;
}

.import-week-rate {
    color: var(--primary);
    font-weight: 500;
}

.import-timeline {
    display: flex;
    justify-content: space-between;
    gap: 2px;
    padding: 10px 4px 6px;
    border-top: 1px solid var(--border);
}

.import-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 1;
}

.import-day.is-yesterday .import-day-label {
    font-weight: 700;
    color: var(--primary);
}

.import-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: block;
}

.dot-done { background: #2864f0; box-shadow: 0 0 0 2px rgba(40, 100, 240, 0.2); }
.dot-missing { background: #e5e7eb; border: 1px solid #d1d5db; }
.dot-partial { background: #f59e0b; box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25); }
.dot-error { background: #e53935; box-shadow: 0 0 0 2px rgba(229, 57, 53, 0.2); }

.import-day-label {
    font-size: 9px;
    color: var(--text-muted);
}

.import-last {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.import-last-none {
    color: #d1d5db;
    font-style: italic;
}

.import-file {
    display: block;
    color: #9ca3af;
    margin-top: 2px;
}

@media (max-width: 900px) {
    .topbar-nav-inner {
        flex-direction: column;
        padding: 8px;
    }
    .main-nav {
        flex-wrap: wrap;
        justify-content: flex-start;
    }
    .main-nav-item {
        min-width: 60px;
        padding: 6px 8px;
    }
    .nav-settings {
        margin-left: 0;
    }
    .nav-submenu-dropdown {
        left: auto;
        right: 0;
    }
    .chart-row, .form-row, .match-compare {
        grid-template-columns: 1fr;
    }
    .return-order-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* ===== Search loading modal ===== */
.search-loading-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.45);
}

.search-loading-modal[hidden] {
    display: none !important;
}

.search-loading-dialog {
    min-width: 220px;
    padding: 28px 32px;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    text-align: center;
}

.search-loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: search-loading-spin 0.8s linear infinite;
}

.search-loading-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

@keyframes search-loading-spin {
    to { transform: rotate(360deg); }
}

.dashboard-async-section {
    margin-bottom: 24px;
}

.dashboard-section-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 14px;
}

.dashboard-section-loading::before {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: search-loading-spin 0.8s linear infinite;
    flex-shrink: 0;
}

.dashboard-section-error {
    color: var(--danger);
}

.sortable-th {
    white-space: nowrap;
}

.sortable-th-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: inherit;
    cursor: pointer;
}

.sortable-th-btn:hover,
.sortable-th-btn:focus-visible {
    color: var(--primary);
}

.sortable-th-btn[aria-sort="ascending"],
.sortable-th-btn[aria-sort="descending"] {
    color: var(--primary);
}

.sort-indicator {
    display: inline-block;
    min-width: 12px;
    font-size: 11px;
    line-height: 1;
}

.badge-action {
    border: none;
    cursor: pointer;
    font: inherit;
}

.badge-action:hover,
.badge-action:focus-visible {
    filter: brightness(0.92);
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

tr.collection-detail-row {
    cursor: pointer;
}

tr.collection-detail-row:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.collection-detail-summary dd {
    word-break: break-all;
}

.tracking-modal {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tracking-modal[hidden] {
    display: none !important;
}

.tracking-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
}

.tracking-modal-dialog {
    position: relative;
    width: min(560px, calc(100vw - 32px));
    max-height: calc(100vh - 32px);
    overflow: auto;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.tracking-modal-dialog-sm {
    width: min(480px, calc(100vw - 32px));
}

.tracking-modal-dialog-lg {
    width: min(720px, calc(100vw - 32px));
}

.import-message-body {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 13px;
    line-height: 1.5;
    max-height: min(60vh, 480px);
    overflow: auto;
    margin: 0;
    padding: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    user-select: text;
    -webkit-user-select: text;
}

.tracking-modal-header,
.tracking-modal-body,
.tracking-modal-footer {
    padding: 16px 20px;
}

.tracking-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.tracking-modal-header h2 {
    font-size: 18px;
}

.tracking-modal-close {
    border: none;
    background: none;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: var(--text-muted);
}

.tracking-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    border-top: 1px solid var(--border);
}

.login-card:has(.password-change-dialog) {
    width: min(560px, calc(100vw - 32px));
    padding: 0;
    overflow: hidden;
    border-radius: 12px;
}

.login-card:has(.password-change-dialog) > h2,
.login-card:has(.password-change-dialog) > .subtitle {
    display: none;
}

.password-change-dialog {
    width: 100%;
    max-height: calc(100vh - 32px);
    text-align: left;
}

.password-change-dialog .tracking-modal-header h2 {
    margin: 0;
    color: var(--text);
    text-align: left;
    font-size: 18px;
}

.password-change-dialog .tracking-modal-header p {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 13px;
}

.password-change-dialog .form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text);
    font: inherit;
}

.password-change-error-summary {
    margin-bottom: 16px;
}

.password-change-error-summary p {
    margin-top: 4px;
}

.password-change-dialog .field-error {
    margin-top: 5px;
    color: var(--danger);
    font-size: 12px;
}

.password-change-help {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 12px;
}

.password-change-help ul {
    padding-left: 20px;
}

.password-change-footer {
    align-items: center;
    justify-content: space-between;
    margin: 20px -20px -16px;
}

.password-change-footer a {
    font-size: 13px;
}

.tracking-option-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.tracking-option-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.tracking-form-error {
    color: var(--danger);
    margin-top: 8px;
}

.tracking-confirm-summary {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 8px 12px;
    margin-top: 12px;
}

.tracking-confirm-summary dt {
    color: var(--text-muted);
}

.tracking-modal-summary {
    margin-bottom: 16px;
}

/* PDF変換 */
.pdftools-card {
    max-width: 720px;
}

.pdftools-size-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px 24px;
    margin-bottom: 20px;
}

.pdftools-size-row[hidden],
.pdftools-actions[hidden],
.pdftools-result[hidden] {
    display: none !important;
}

.pdftools-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
}

.pdftools-check input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.pdftools-custom-input {
    width: 88px;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
}

.pdftools-custom-input:disabled {
    background: var(--bg);
    color: var(--text-muted);
}

.pdftools-custom-unit {
    color: var(--text-muted);
    font-weight: 400;
}

.pdftools-dropzone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 48px 20px;
    text-align: center;
    background: var(--muted-bg);
    cursor: pointer;
    margin-bottom: 20px;
    transition: border-color 0.15s, background 0.15s;
}

.pdftools-dropzone:hover,
.pdftools-dropzone.is-dragover,
.pdftools-dropzone:focus {
    border-color: var(--primary);
    background: var(--primary-light);
    outline: none;
}

.pdftools-dropzone-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
}

.pdftools-dropzone-hint {
    font-size: 12px;
    color: var(--text-muted);
}

.pdftools-actions {
    margin-bottom: 16px;
}

.pdftools-notes {
    margin-top: 16px;
    padding-left: 1.2em;
    font-size: 12px;
    line-height: 1.7;
    color: var(--text-muted);
}

.pdftools-notes li {
    margin-bottom: 4px;
}

.pdftools-actions .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pdftools-message {
    margin-bottom: 12px;
    font-size: 13px;
    color: var(--text-muted);
}

.pdftools-message.is-error {
    color: var(--danger);
}

.pdftools-loading[hidden] {
    display: none;
}

.pdftools-loading {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(31, 41, 55, 0.38);
}

.pdftools-loading-panel {
    width: min(280px, 100%);
    padding: 24px 24px 20px;
    border-radius: 18px;
    background: #fffdf7;
    box-shadow: 0 18px 44px rgba(17, 24, 39, 0.28);
    text-align: center;
}

.pdftools-loading-walker {
    position: relative;
    width: 88px;
    aspect-ratio: 3 / 4;
    margin: 0 auto 10px;
    transform-origin: center bottom;
    animation: pdftools-walk-in-place 640ms ease-in-out infinite;
}

.pdftools-loading-walker-frame {
    position: absolute;
    inset: 0;
    background: url('../images/pdf-walker-sprite.png') 0 0 / 400% 100% no-repeat;
    opacity: 0;
}

.pdftools-loading-walker-frame.is-frame-1 { animation: pdftools-walk-frame-1 640ms linear infinite; }
.pdftools-loading-walker-frame.is-frame-2 { background-position: 33.333333% 0; animation: pdftools-walk-frame-2 640ms linear infinite; }
.pdftools-loading-walker-frame.is-frame-3 { background-position: 66.666667% 0; animation: pdftools-walk-frame-3 640ms linear infinite; }
.pdftools-loading-walker-frame.is-frame-4 { background-position: 100% 0; animation: pdftools-walk-frame-4 640ms linear infinite; }
}

.pdftools-loading-title {
    font-size: 15px;
    font-weight: 700;
}

.pdftools-loading-hint {
    margin-top: 2px;
    color: var(--text-muted);
    font-size: 12px;
}

@keyframes pdftools-walk-frame-1 { 0%, 24.999% { opacity: 1; } 25%, 100% { opacity: 0; } }
@keyframes pdftools-walk-frame-2 { 0%, 24.999% { opacity: 0; } 25%, 49.999% { opacity: 1; } 50%, 100% { opacity: 0; } }
@keyframes pdftools-walk-frame-3 { 0%, 49.999% { opacity: 0; } 50%, 74.999% { opacity: 1; } 75%, 100% { opacity: 0; } }
@keyframes pdftools-walk-frame-4 { 0%, 74.999% { opacity: 0; } 75%, 100% { opacity: 1; } }

@keyframes pdftools-walk-in-place {
    0%, 100% { transform: translateY(0) rotate(0); }
    25% { transform: translateY(-4px) rotate(-1deg); }
    50% { transform: translateY(0) rotate(0); }
    75% { transform: translateY(-4px) rotate(1deg); }
}

html.theme-dark .pdftools-loading-panel {
    background: #1f2937;
}

.pdftools-file-list {
    list-style: none;
    margin: 0 0 16px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    min-height: 0;
}

.pdftools-file-list:empty {
    display: none;
}

.pdftools-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    background: #fff;
    cursor: grab;
}

.pdftools-file-item:last-child {
    border-bottom: none;
}

.pdftools-file-item.is-dragging {
    opacity: 0.45;
}

.pdftools-file-item.is-drop-target {
    background: var(--primary-light);
}

.pdftools-file-handle {
    color: var(--text-muted);
    font-size: 12px;
}

.pdftools-file-index {
    min-width: 1.5em;
    color: var(--text-muted);
    font-size: 12px;
}

.pdftools-file-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pdftools-file-item.is-locked {
    background: #fdecea;
    color: var(--danger);
}

.pdftools-file-item.is-locked .pdftools-file-name,
.pdftools-file-item.is-locked .pdftools-file-size,
.pdftools-file-item.is-locked .pdftools-file-status,
.pdftools-file-item.is-locked .pdftools-file-index,
.pdftools-file-item.is-locked .pdftools-file-handle {
    color: var(--danger);
}

.pdftools-file-status {
    font-size: 12px;
    white-space: nowrap;
}

.pdftools-file-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    margin-left: 4px;
    padding: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
}

.pdftools-file-remove:hover {
    background: #f3f4f6;
    color: var(--danger);
}

.pdftools-file-item.is-locked .pdftools-file-remove {
    color: var(--danger);
}

.pdftools-result {
    margin-top: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.pdftools-output-size {
    font-size: 12px;
    color: var(--text-muted);
}

.page-header h1:has(.pdftools-title-switch) {
    display: flex;
    align-items: center;
}

.pdftools-title-switch {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.pdftools-mode-label {
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
}

.pdftools-mode-label.is-active {
    color: var(--text);
}

.pdftools-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.pdftools-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.pdftools-switch-track {
    position: absolute;
    inset: 0;
    background: #d1d5db;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s;
}

.pdftools-switch input:checked + .pdftools-switch-track {
    background: var(--primary);
}

.pdftools-switch-track::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 2px;
    top: 2px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.15s;
}

.pdftools-switch input:checked + .pdftools-switch-track::after {
    transform: translateX(20px);
}

.pdftools-page-item {
    cursor: default;
}

.pdftools-page-thumb {
    width: 96px;
    height: 128px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--card-bg);
    flex-shrink: 0;
}

.pdftools-page-download {
    margin-left: auto;
    flex-shrink: 0;
}

.error-row {
    cursor: pointer;
}

.badge-error {
    background: #fee2e2;
    color: #991b1b;
}

html.theme-dark .badge-success { background: #064e3b; color: #6ee7b7; }
html.theme-dark .badge-warning { background: #422006; color: #fcd34d; }
html.theme-dark .badge-info { background: #1e3a4c; color: #7dd3fc; }
html.theme-dark .badge-secondary { background: #243040; color: #cbd5e1; }
html.theme-dark .badge-uncollected { background: #3f2e05; color: #fde68a; }
html.theme-dark .badge-error,
html.theme-dark .alert-error { background: #3f1515; color: #fca5a5; }
html.theme-dark .alert-success { background: #064e3b; color: #a7f3d0; }
html.theme-dark .alert-warning { background: #422006; color: #fde68a; }
html.theme-dark .alert-info { background: #1e3a4c; color: #bae6fd; }
html.theme-dark .card-match-alert { border-color: #7f1d1d; background: #2a1616; }
html.theme-dark table.data-table tr.row-match-alert td { background: #3f1515; color: #fca5a5; }
html.theme-dark table.data-table tr.row-match-alert:hover td { background: #5b1d1d; }
html.theme-dark table.data-table tr.row-return-match td { background: #3f2e05; color: #fde68a; }
html.theme-dark table.data-table tr.row-return-match:hover td { background: #543c08; }
html.theme-dark .import-badge-done { background: #1e3a4c; color: #7dd3fc; }
html.theme-dark .import-badge-missing { background: #3f1515; color: #fca5a5; }
html.theme-dark .import-badge-partial { background: #422006; color: #fbbf24; }
html.theme-dark .import-badge-error { background: #3f1515; color: #fca5a5; }
html.theme-dark a:hover { color: var(--primary-dark); }
html.theme-dark .checkbox-group { color: var(--text); }


.utility-help-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    height: 24px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--text-muted);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.utility-help-button:hover {
    color: var(--primary);
}

.return-help-role {
    display: inline-block;
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 12px;
}

.return-help-body {
    line-height: 1.7;
}

.return-help-body ol {
    margin: 0 0 16px;
    padding-left: 1.5em;
}

.return-help-body li + li {
    margin-top: 8px;
}
