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

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --warning: #f59e0b;
  --success: #16a34a;
  --bg: #f1f5f9;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* Header */
header {
  background: var(--primary);
  color: #fff;
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
  overflow: hidden;
}
.logo { font-size: 18px; font-weight: 700; white-space: nowrap; flex-shrink: 0; }
.app-version { font-size: 10px; font-weight: 400; color: rgba(255,255,255,0.55); margin-left: 6px; vertical-align: middle; letter-spacing: 0.02em; }
nav {
  display: flex;
  gap: 4px;
  flex: 1 1 0;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE/Edge */
  flex-wrap: nowrap;
}
nav::-webkit-scrollbar { display: none; }  /* Chrome/Safari */
.nav-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.8);
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;   /* 幅が足りなくても文字を縦積みにしない */
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.nav-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.nav-btn.active { background: rgba(255,255,255,0.25); color: #fff; font-weight: 600; }

/* Language toggle */
.lang-btn {
  margin-left: auto;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 4px 12px;
  border-radius: 99px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  transition: background 0.15s;
  white-space: nowrap;
}
.lang-btn:hover { background: rgba(255,255,255,0.28); }

/* Language select dropdown */
.lang-select {
  flex-shrink: 0;
  margin-left: auto;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.4);
  color: #fff;
  padding: 4px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s;
  white-space: nowrap;
  max-width: 130px;
}
.lang-select:hover { background: rgba(255,255,255,0.28); }
.lang-select option { background: #1e293b; color: #fff; }

/* Main */
main { max-width: 1200px; margin: 0 auto; padding: 20px 16px; }

/* Pages */
.page { display: none; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.page-header h2 { font-size: 20px; font-weight: 700; }

.export-btns { display: flex; gap: 6px; }
.btn-export {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
  padding: 6px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  transition: background 0.15s;
}
.btn-export:hover { background: #dcfce7; }

/* Filters */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input[type="text"],
.filters select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--surface);
}
.checkbox-label { display: flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }

/* Alert */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.alert-warning { background: #fef9c3; border: 1px solid #fde047; color: #854d0e; }
.hidden { display: none !important; }

/* Table */
.table-wrap { overflow-x: auto; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { background: #f8fafc; font-weight: 600; font-size: 13px; color: var(--text-muted); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8fafc; }

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 600;
}
.badge-ok { background: #dcfce7; color: #166534; }
.badge-low { background: #fee2e2; color: #991b1b; }
.badge-in { background: #dbeafe; color: #1e40af; }
.badge-out { background: #fce7f3; color: #9d174d; }
.badge-transfer { background: #e0f2fe; color: #0369a1; }
.badge-adjust { background: #fef9c3; color: #854d0e; }
.badge-stocktake-open { background: #fef3c7; color: #92400e; }
.badge-stocktake-done { background: #dcfce7; color: #166534; }

/* 入出庫履歴：棚卸調整行 */
.history-row-adjust { background: #fefce8; }
.history-row-adjust:hover { background: #fef9c3 !important; }
.adjust-plus  { color: #2563eb; font-weight: 700; }
.adjust-minus { color: #dc2626; font-weight: 700; }
.qty-unit { color: #94a3b8; font-size: 12px; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 560px;
}

/* Forms */
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-muted); }
.label-note { font-size: 11px; font-weight: 400; color: #94a3b8; }
.lot-row { display: flex; gap: 8px; align-items: center; }
.lot-row input { flex: 1; }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color 0.15s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 120px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 16px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s, opacity 0.15s;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #e2e8f0; color: var(--text); }
.btn-secondary:hover { background: #cbd5e1; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.85; }
.btn-cancel {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  padding: 4px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s;
}
.btn-cancel:hover { background: #ffedd5; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { width: 100%; padding: 12px; font-size: 15px; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.4); }
.modal-content {
  position: relative;
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
  margin-bottom: 20px;
}
.modal-header h3 { font-size: 18px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-content form { padding: 0 24px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 20px 24px; }

/* History type filter */
.tx-type-btns { display: flex; gap: 6px; align-items: center; }
.tx-filter-btn { background: #e2e8f0; color: var(--text); }
.tx-filter-btn:hover { background: #cbd5e1; }
.tx-filter-btn.active { background: var(--primary); color: #fff; }

/* ── 同期待ちキューパネル ────────────────────────────────────── */
.queue-panel {
  position: fixed;
  top: 0; right: 0;
  width: 360px; max-width: 95vw;
  height: 100dvh;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  z-index: 500;
  display: flex; flex-direction: column;
}
.queue-panel-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 499;
}
.queue-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  background: #1e293b; color: #fff;
  font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}
.queue-panel-close {
  background: none; border: none; color: #fff;
  font-size: 22px; cursor: pointer; line-height: 1;
  padding: 0 4px;
}
.queue-panel-list {
  flex: 1; overflow-y: auto;
  padding: 8px 0;
}
.queue-empty {
  text-align: center; color: var(--text-muted);
  padding: 40px 20px; font-size: 14px;
}
.queue-item {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.queue-item:hover { background: #f8fafc; }
.queue-item-desc {
  font-size: 13px; font-weight: 600;
  color: var(--text); margin-bottom: 6px;
  line-height: 1.4;
}
.queue-item-desc:has(⚠) { color: #dc2626; }
.queue-item-meta {
  display: flex; align-items: center; justify-content: space-between;
}
.queue-item-time {
  font-size: 11px; color: var(--text-muted);
}
.queue-item-cancel {
  background: none; border: 1px solid #fca5a5;
  color: #dc2626; border-radius: 6px;
  padding: 2px 10px; font-size: 11px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
}
.queue-item-cancel:hover { background: #fee2e2; }
.queue-panel-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; flex-shrink: 0;
}
.queue-panel-footer .btn { flex: 1; }

/* ── オフライン・同期バナー ──────────────────────────────────── */
.offline-banner {
  background: #1e293b;
  color: #f8fafc;
  text-align: center;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  position: sticky;
  top: 56px;
  z-index: 90;
}
.offline-queue-badge {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #f59e0b;
  color: #1e293b;
  border: none;
  border-radius: 99px;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 150;
  transition: background 0.15s, transform 0.1s;
}
.offline-queue-badge:hover {
  background: #fbbf24;
  transform: scale(1.04);
}
@media (max-width: 600px) {
  .offline-queue-badge {
    bottom: 16px;
    right: 16px;
    padding: 9px 14px;
    font-size: 12px;
  }
}
.sync-banner {
  background: #2563eb;
  color: #fff;
  text-align: center;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  position: sticky;
  top: 56px;
  z-index: 90;
}

/* ── 部門トグルボタン（資材マスタフォーム） ─────────────────────── */
.dept-toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.dept-toggle-btn {
  background: #f1f5f9;
  border: 2px solid #cbd5e1;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.dept-toggle-btn:hover { background: #e2e8f0; border-color: #94a3b8; }
.dept-toggle-btn.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

/* ── 部門バッジ（資材マスタ一覧） ───────────────────────────────── */
.dept-badge {
  display: inline-block;
  background: #dbeafe;
  color: #1d4ed8;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  margin: 1px 2px;
}

/* ── 部門別在庫カード（ダッシュボード） ─────────────────────────── */
.dept-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 4px;
}
.dept-card {
  flex: 1 1 160px;
  min-width: 140px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 16px 18px;
}
.dept-card-name {
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  margin-bottom: 6px;
}
.dept-card-value {
  font-size: 22px;
  font-weight: 800;
  color: #1e293b;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}
.dept-card-bar-wrap {
  background: #e2e8f0;
  border-radius: 4px;
  height: 6px;
  margin-bottom: 6px;
  overflow: hidden;
}
.dept-card-bar {
  height: 100%;
  background: #2563eb;
  border-radius: 4px;
  transition: width 0.4s ease;
  min-width: 2px;
}
.dept-card-meta {
  font-size: 11px;
  color: #94a3b8;
}

/* ── アップデートバナー ────────────────────────────────────────── */
.update-banner {
  background: #0f766e;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  position: sticky;
  top: 56px;
  z-index: 95;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.update-banner-btn {
  background: #fff;
  color: #0f766e;
  border: none;
  border-radius: 6px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
}
.update-banner-btn:hover { opacity: 0.85; }

/* History tab bar */
.hist-tab-bar {
  display: flex; gap: 4px;
  background: #e8edf5;
  border-radius: 14px;
  padding: 5px;
  margin-bottom: 20px;
  width: fit-content;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.10);
}
.hist-tab {
  display: flex; align-items: center; gap: 6px;
  background: none; border: none;
  padding: 9px 26px;
  font-size: 13px; font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 10px;
  transition: all 0.2s cubic-bezier(.4,0,.2,1);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.hist-tab-icon { font-size: 15px; line-height: 1; }
.hist-tab:hover:not(.active) {
  color: var(--text);
  background: rgba(255,255,255,0.6);
}
.hist-tab.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 2px 10px rgba(37,99,235,0.18), 0 1px 3px rgba(0,0,0,0.08);
}
.hist-tab.active .hist-tab-icon {
  filter: drop-shadow(0 0 3px rgba(37,99,235,0.3));
}

/* DOI range setting tabs */
.doi-range-tabs { display: flex; gap: 6px; }
.doi-range-btn {
  display: flex; flex-direction: column; align-items: center;
  background: #e2e8f0; color: var(--text);
  border: 2px solid transparent; border-radius: var(--radius);
  padding: 6px 16px; cursor: pointer; font-size: 14px; font-weight: 700;
  transition: all 0.15s;
}
.doi-range-btn:hover { background: #cbd5e1; }
.doi-range-btn.active {
  background: #eff6ff; color: var(--primary);
  border-color: var(--primary);
}
.doi-range-hint {
  font-size: 10px; font-weight: 400; color: var(--text-muted); margin-top: 2px; white-space: nowrap;
}
.doi-range-btn.active .doi-range-hint { color: var(--primary); opacity: 0.8; }

/* Sticky horizontal scrollbar (fixed at viewport bottom) */
.sticky-hscroll-fixed {
  position: fixed;
  bottom: 0;
  overflow-x: auto;
  overflow-y: hidden;
  height: 14px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  z-index: 200;
}
.sticky-hscroll-fixed > div { height: 1px; }

/* Transfer button */
.btn-transfer { background: #f0fdf4; color: #15803d; border: 1px solid #86efac; }
.btn-transfer:hover { background: #dcfce7; border-color: #4ade80; }

/* Inventory LOT badges */
.lot-cell { line-height: 1.8; }
.lot-badge {
  display: inline-flex; align-items: center; gap: 3px;
  background: #eff6ff; border: 1px solid #bfdbfe;
  color: #1e40af; border-radius: 4px;
  font-size: 11px; padding: 2px 6px; margin: 1px 2px;
  white-space: nowrap;
}
.lot-badge-qty {
  background: #2563eb; color: #fff;
  border-radius: 3px; padding: 0 4px;
  font-weight: 700; font-size: 11px;
}
/* LOT内の在庫日数 */
.lot-days {
  border-radius: 3px; padding: 0 4px;
  font-weight: 700; font-size: 11px;
}
.lot-days-fresh { background: #dcfce7; color: #15803d; }   /* ～30日：緑 */
.lot-days-mid   { background: #fef9c3; color: #854d0e; }   /* ～90日：黄 */
.lot-days-old   { background: #fee2e2; color: #991b1b; }   /* 90日超：赤 */

/* Analytics */
.period-btns { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.period-label { font-size: 12px; color: var(--text-muted); }
.period-btn { background: #e2e8f0; color: var(--text); }
.period-btn:hover { background: #cbd5e1; }
.period-btn.active { background: var(--primary); color: #fff; }
.period-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }

.analytics-cards {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.analytics-card {
  flex: 1;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.danger-card { border-left: 4px solid var(--danger); }
.card-label { font-size: 12px; color: var(--text-muted); font-weight: 600; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.04em; }
.card-value { font-size: 26px; font-weight: 700; color: var(--text); }
.danger-card .card-value { color: var(--danger); }

.analytics-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.analytics-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.analytics-row .analytics-panel { margin-bottom: 0; }
.panel-title { font-size: 13px; font-weight: 700; color: var(--text-muted); margin-bottom: 16px; text-transform: uppercase; letter-spacing: 0.04em; }

.chart-wrap-donut { position: relative; height: 260px; }
.chart-wrap-bar   { position: relative; height: 280px; }
.chart-wrap-line  { position: relative; height: 300px; }

/* DOI color coding */
.doi-low  { color: #dc2626; font-weight: 700; }   /* < 30日: 残少 */
.doi-mid  { color: #16a34a; font-weight: 600; }   /* 30-90日: 適正 */
.doi-high { color: #64748b; }                     /* > 90日: 過多 */
.doi-none { color: #94a3b8; }

/* Responsive */
@media (max-width: 600px) {
  /* スマホではタブを2段目に降ろす。
     1段目にロゴ・言語・ログアウトが並ぶと、タブに数十pxしか残らず潰れるため。 */
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    overflow: visible;
    gap: 8px;
    padding-top: 8px;
  }
  .logo { font-size: 15px; }
  .lang-select { max-width: 104px; font-size: 11px; }
  nav {
    order: 10;              /* 1段目の要素より後ろ＝2段目へ */
    flex: 1 0 100%;
    margin: 0 -16px;        /* ヘッダーの左右paddingを打ち消して画面端まで使う */
    padding: 0 12px 8px;
    gap: 2px;
  }
  .nav-btn { padding: 7px 9px; font-size: 12px; }
  th, td { padding: 8px 10px; font-size: 12px; }
  .card { padding: 16px; }
}

@media (max-width: 720px) {
  .analytics-row { grid-template-columns: 1fr; }
  .chart-wrap-donut { height: 220px; }
  .chart-wrap-bar   { height: 220px; }
  .chart-wrap-line  { height: 240px; }
  .analytics-cards  { gap: 10px; }
  .card-value       { font-size: 20px; }
}

/* ── 棚卸し ─────────────────────────────────────────────────── */
.stocktake-meta-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  margin-bottom: 14px; font-size: 13px;
}
.stocktake-meta-item { color: var(--text-muted); }
.stocktake-diff-count {
  background: #fef3c7; color: #92400e;
  border-radius: 99px; padding: 2px 10px;
  font-weight: 700; font-size: 12px;
}

.stocktake-filter-bar {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 10px; font-size: 13px; flex-wrap: wrap;
}
.stocktake-progress-text {
  margin-left: auto; color: var(--text-muted);
  font-size: 12px; font-weight: 600;
}

/* 棚卸し入力フィールド */
.stocktake-qty-input {
  width: 80px; padding: 4px 8px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; text-align: right;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.stocktake-qty-input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,0.15);
}
.stocktake-note-input {
  width: 120px; padding: 4px 8px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 12px;
}
.stocktake-note-input:focus { outline: none; border-color: var(--primary); }

/* 差異セル */
.stocktake-diff-ok    { color: #16a34a; font-weight: 700; text-align: center; }
.stocktake-diff-plus  { color: #2563eb; font-weight: 700; text-align: center; background: #eff6ff; }
.stocktake-diff-minus { color: #dc2626; font-weight: 700; text-align: center; background: #fef2f2; }
.stocktake-diff-none  { color: #94a3b8; text-align: center; }

/* 単価改訂の予約 */
.price-rev-input-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.price-rev-input-row input[type="number"] { flex: 1; min-width: 120px; }
.price-rev-input-row input[type="datetime-local"] { flex: 1.4; min-width: 190px; }
.price-rev-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.price-rev-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: var(--radius);
  font-size: 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
}
.price-rev-item.applied { background: #f1f5f9; border-color: var(--border); color: var(--text-muted); }
.price-rev-when { font-weight: 700; white-space: nowrap; }
.price-rev-price { margin-left: auto; white-space: nowrap; font-weight: 700; }
.price-rev-cancel {
  border: none;
  background: #fee2e2;
  color: #991b1b;
  border-radius: var(--radius);
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.price-rev-cancel:hover { background: #fecaca; }
.price-rev-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 700;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  white-space: nowrap;
}

/* システム在庫列：見出しを2行にして列幅を詰める（スマホでの視認性優先） */
.stocktake-sysqty-th {
  line-height: 1.25;
  text-align: right;
  width: 1%;             /* 内容ぴったりの幅に縮める */
}
/* 「システム」「在庫」を各1行に固定（3行に割れないようにする） */
.stocktake-sysqty-th span {
  display: block;
  white-space: nowrap;
}
.stocktake-sysqty {
  text-align: right;
  font-weight: 700;
  white-space: nowrap;
}

/* 行のハイライト */
.stocktake-row-ok   { background: #f0fdf4; }
.stocktake-row-plus { background: #eff6ff; }
.stocktake-row-minus { background: #fff5f5; }

/* カテゴリ区切り行 */
.stocktake-cat-header td {
  background: #e8edf5;
  color: #374151;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  letter-spacing: 0.04em;
  border-top: 2px solid #cbd5e1;
}

/* 差異なしボタン */
.stocktake-nodiff-btn {
  background: #f1f5f9; color: #475569;
  border: 1px solid #cbd5e1;
  padding: 3px 10px; font-size: 12px; font-weight: 600;
  border-radius: 6px; cursor: pointer; white-space: nowrap;
  transition: all 0.15s;
}
.stocktake-nodiff-btn:hover {
  background: #dcfce7; color: #166534; border-color: #86efac;
}
.stocktake-nodiff-done {
  font-size: 12px; font-weight: 700;
  color: #16a34a; white-space: nowrap;
}

/* ── ログイン画面 ───────────────────────────────────────────── */
/* このアプリは元々ログインが無く、nginxのBasic認証で塞いでいた。
   他アプリと操作を揃えるため、アプリ自身のログイン画面に切り替えた。 */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-overlay.hidden { display: none; }

.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
  padding: 28px 24px;
  width: 100%;
  max-width: 340px;
}
.login-box .login-logo {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  margin-bottom: 22px;
}
.login-box label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.login-box input {
  width: 100%;
  font-size: 16px;           /* スマホで勝手に拡大されないよう16px以上にする */
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  background: var(--surface);
  color: var(--text);
}
.login-box input:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.login-box .btn { width: 100%; padding: 12px; font-size: 1rem; }

.login-error {
  color: var(--danger);
  font-size: 0.84rem;
  min-height: 1.3em;
  margin: -8px 0 12px;
}

.logout-btn {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 0.82rem;
  cursor: pointer;
  margin-left: 8px;
}
.logout-btn:hover { background: rgba(255, 255, 255, 0.28); }
.logout-btn.hidden { display: none; }
