/* keiri 経理ツール */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warn: #f59e0b;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --bg: #f3f4f6;
    --card: #ffffff;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: -apple-system, "Helvetica Neue", "Hiragino Sans", sans-serif; background: var(--bg); color: var(--text); padding-bottom: 80px; }

a { color: var(--primary); }

/* ヘッダ */
.app-header { background: var(--primary); color: #fff; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; box-shadow: 0 2px 4px rgba(0,0,0,0.1); position: sticky; top: 0; z-index: 100; }
.app-header h1 { margin: 0; font-size: 18px; }
.app-header nav { display: flex; align-items: center; gap: 12px; }
.app-header .me { font-size: 13px; opacity: 0.9; }
.app-header button { background: rgba(255,255,255,0.18); color: #fff; border: none; padding: 6px 12px; border-radius: 8px; font-size: 13px; cursor: pointer; }
.app-header button:hover { background: rgba(255,255,255,0.28); }

/* ページタブ */
.page-tabs { display: flex; background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 48px; z-index: 99; overflow-x: auto; }
.page-tab { flex: 1; min-width: 100px; padding: 12px 8px; background: #fff; border: none; border-bottom: 3px solid transparent; font-size: 14px; cursor: pointer; color: var(--text-muted); }
.page-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: bold; }

.container { max-width: 920px; margin: 0 auto; padding: 16px; }
.container h2 { margin: 8px 0 16px; font-size: 18px; }
.container h3 { font-size: 15px; margin: 18px 0 8px; }
.muted { color: var(--text-muted); font-size: 13px; }

/* フォーム共通 */
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 4px; font-weight: bold; }
.form-row input, .form-row select, .form-row textarea {
    width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; background: #fff; font-family: inherit;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ボタン */
.btn { display: inline-block; padding: 10px 18px; border: none; border-radius: 8px; font-size: 14px; font-weight: bold; cursor: pointer; text-decoration: none; text-align: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 16px 24px; font-size: 16px; }
.btn-block { display: block; width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ログイン画面 */
.login-body { background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { background: #fff; padding: 32px; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,0.2); width: 100%; max-width: 380px; }
.login-card h1 { margin: 0 0 4px; color: var(--primary); }

/* 撮影画面 */
.capture-box { background: var(--card); padding: 24px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); margin-bottom: 16px; border: 2px dashed var(--border); }
.upload-progress { color: var(--primary); font-weight: bold; }
.upload-error { color: var(--danger); font-weight: bold; }

/* 解析結果カード */
.result-card { background: var(--card); padding: 18px; border-radius: 12px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); margin-top: 14px; }
.result-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.result-header h3 { margin: 0; }
.result-grid { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; }
@media (max-width: 720px) { .result-grid { grid-template-columns: 1fr; } }
.result-photo img { width: 100%; border-radius: 8px; cursor: zoom-in; }
.banner-warn { background: #fef3c7; color: #92400e; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; border-left: 4px solid var(--warn); }
.banner-error { background: #fee2e2; color: #991b1b; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 13px; border-left: 4px solid var(--danger); }

/* ステータスバッジ */
.status-badge { padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: bold; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-confirmed { background: #d1fae5; color: #065f46; }
.status-error { background: #fee2e2; color: #991b1b; }
.status-exported { background: #dbeafe; color: #1e40af; }

/* 一覧 */
.filter-row { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; align-items: center; }
.filter-row input, .filter-row select { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.list-summary { background: var(--card); padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; display: flex; gap: 18px; flex-wrap: wrap; }
.list-summary span strong { color: var(--primary); font-size: 16px; margin-right: 4px; }
.receipt-row { background: var(--card); padding: 12px; border-radius: 10px; margin-bottom: 8px; display: grid; grid-template-columns: 60px 1fr auto; gap: 10px; align-items: center; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }
.receipt-row:hover { background: #f9fafb; }
.receipt-row .thumb { width: 60px; height: 60px; object-fit: cover; border-radius: 6px; background: #eee; }
.receipt-row .main { min-width: 0; }
.receipt-row .main .top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.receipt-row .main .vendor { font-weight: bold; }
.receipt-row .main .meta { color: var(--text-muted); font-size: 12px; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt-row .amount { text-align: right; }
.receipt-row .amount .big { font-size: 16px; font-weight: bold; color: var(--primary); }
.receipt-row .amount .small { font-size: 11px; color: var(--text-muted); }
.receipt-row.r-pending { border-left: 4px solid var(--warn); }
.receipt-row.r-error { border-left: 4px solid var(--danger); }
.receipt-row.r-confirmed { border-left: 4px solid var(--success); }

/* モーダル */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 1000; justify-content: center; align-items: center; padding: 16px; }
.modal-bg.show { display: flex; }
.modal { background: #fff; border-radius: 12px; padding: 20px; max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto; position: relative; }
.modal-wide { max-width: 920px; }
.modal h3 { margin-top: 0; }
.close-x { position: absolute; top: 10px; right: 14px; background: transparent; border: none; font-size: 24px; cursor: pointer; color: var(--text-muted); }
.modal-footer { display: flex; gap: 8px; margin-top: 16px; align-items: center; }
