/* ─── リセット & 基本 ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy: #1a3a5c;
  --navy-light: #2a5280;
  --accent: #e8a020;
  --bg: #f4f6f9;
  --white: #ffffff;
  --border: #d0d7e2;
  --text: #1e2a38;
  --text-light: #5a6a7e;
  --success: #28a745;
  --error: #dc3545;
  --sidebar-w: 220px;
}

body {
  font-family: 'Helvetica Neue', 'Hiragino Sans', 'Meiryo', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ─── ログイン ───────────────────────────────────────────── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
}

.login-container {
  background: var(--white);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo h1 {
  font-size: 28px;
  color: var(--navy);
  font-weight: 700;
}
.login-logo p {
  color: var(--text-light);
  font-size: 13px;
  margin-top: 4px;
}

.login-form .form-group { margin-bottom: 16px; }
.login-form label {
  display: block;
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.login-form input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  transition: border-color 0.2s;
}
.login-form input:focus {
  outline: none;
  border-color: var(--navy);
}
.login-note {
  text-align: center;
  color: var(--text-light);
  font-size: 12px;
  margin-top: 16px;
}

/* ─── サイドバー（管理画面） ────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: scroll;           /* 常時スクロールバー表示 */
}
/* スクロールバーを目立つデザインに */
.sidebar::-webkit-scrollbar { width: 7px; }
.sidebar::-webkit-scrollbar-track { background: rgba(0,0,0,0.25); }
.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.45);
  border-radius: 4px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.7);
}

.sidebar-logo {
  padding: 14px 14px;           /* 上下パディングを詰める */
  font-size: 14px;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.12);
  color: #fff;
  flex-shrink: 0;
}

.sidebar ul {
  list-style: none;
  padding: 6px 0;               /* 上下余白を詰める */
  flex: 1;
}
.sidebar ul li a {
  display: block;
  padding: 7px 14px;            /* 各項目の上下パディングを詰める */
  color: rgba(255,255,255,0.82);
  font-size: 12.5px;            /* フォントを少し小さく */
  transition: background 0.15s, color 0.15s;
  line-height: 1.4;
}
.sidebar ul li a:hover,
.sidebar ul li.active a {
  background: rgba(255,255,255,0.12);
  color: #fff;
  text-decoration: none;
}
.sidebar ul li.separator {
  border-top: 1px solid rgba(255,255,255,0.12);
  margin: 5px 0;
}

/* ─── メインコンテンツ（管理） ───────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  padding: 28px 32px;
  min-height: 100vh;
}

/* ─── トップヘッダー（顧客） ────────────────────────────── */
.top-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  height: 52px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.header-logo {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}
.header-right { display: flex; align-items: center; gap: 16px; }
.header-user {
  font-size: 13px;
  color: rgba(255,255,255,0.9);
  white-space: nowrap;
}
.header-user strong { color: #fff; font-weight: 700; }
.header-nav { display: flex; gap: 6px; }
.header-nav a {
  color: rgba(255,255,255,0.8);
  padding: 6px 14px;
  border-radius: 5px;
  font-size: 13px;
  transition: background 0.15s;
}
.header-nav a:hover,
.header-nav a.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
  text-decoration: none;
}

/* ─── 顧客メイン ────────────────────────────────────────── */
.customer-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ─── 共通 ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
}
.page-header h2 {
  font-size: 20px;
  color: var(--navy);
  font-weight: 700;
}
.hint { color: var(--text-light); font-size: 12px; }
.section-title {
  font-size: 15px;
  color: var(--navy);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--navy);
}

/* ─── カード ────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 20px;
  margin-bottom: 20px;
}
.card h3 {
  font-size: 14px;
  color: var(--navy);
  margin-bottom: 14px;
}

/* ─── ボタン ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, transform 0.1s;
  line-height: 1;
}
.btn:hover { opacity: 0.88; text-decoration: none; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary { background: var(--navy); color: #fff; }
.btn-secondary { background: #e8edf3; color: var(--navy); }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--navy);
  color: var(--navy);
}
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-block { width: 100%; }

.btn-remove {
  background: none;
  border: 1px solid var(--error);
  color: var(--error);
  cursor: pointer;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
}
.btn-remove:hover { background: #fde8ea; }

/* ─── フォーム ──────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-group label {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 600;
}
.form-group input,
.form-group select,
.form-group textarea {
  padding: 8px 10px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.2s;
  font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--navy);
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}
.form-group-btn { justify-content: flex-end; }

.inline-form .form-row { align-items: flex-end; }

/* ─── アラート ──────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 13px;
}
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error   { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ─── テーブル ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  font-size: 13px;
}
.data-table thead {
  background: var(--navy);
  color: #fff;
}
.data-table th {
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
}
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f7f9fb; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--text-light); padding: 24px; }
.row-inactive { opacity: 0.5; }
.table-info { color: var(--text-light); font-size: 12px; margin: 8px 0; }

/* ─── バッジ ────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.badge-admin    { background: var(--navy); color: #fff; }
.badge-customer { background: #e8edf3; color: var(--navy); }

/* ─── 統計カード ────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white);
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 20px;
  text-align: center;
}
.stat-label { font-size: 12px; color: var(--text-light); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--navy); }

/* ─── モーダル ──────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal-content {
  background: var(--white);
  border-radius: 10px;
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0,0,0,0.2);
}
.modal-content h3 { font-size: 16px; color: var(--navy); margin-bottom: 16px; }
.modal-subtitle { color: var(--text-light); font-size: 12px; margin-bottom: 16px; margin-top: -10px; }
.modal-content .form-group { margin-bottom: 14px; }
.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  justify-content: flex-end;
}

/* ─── フィルターバー ────────────────────────────────────── */
.filter-bar { margin-bottom: 16px; }
.filter-bar .form-group { min-width: 260px; }

/* ─── 見積セクション ────────────────────────────────────── */
.quote-section {
  background: var(--white);
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.quote-section h2 {
  font-size: 16px;
  color: var(--navy);
  font-weight: 700;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--bg);
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--bg);
}
.section-header h2 { margin-bottom: 0; border: none; padding: 0; }

/* ─── 品目カード ────────────────────────────────────────── */
.item-card {
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 8px;
  background: var(--bg);
}
.item-header {
  display: none;
}
.item-grid {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 8px;
  margin-bottom: 0;
}
.item-grid .form-group {
  margin-bottom: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
/* 数値入力・セレクトが先頭に来るよう上部を揃える */
.item-grid .form-group > input,
.item-grid .form-group > select {
  flex: 0 0 auto;
}
.item-grid .form-group:nth-child(1) { flex: 1.3; }  /* 材質 */
.item-grid .form-group:nth-child(2) { flex: 0.9; }  /* 仕上 */
.item-grid .form-group:nth-child(3) { flex: 0.95; } /* 板厚 */
.item-grid .form-group:nth-child(4) { flex: 0.95; } /* 幅 */
.item-grid .form-group:nth-child(5) { flex: 0.95; } /* 長さ */
.item-grid .form-group:nth-child(6) { flex: 1.1; }  /* 面取り */
.item-grid .form-group:nth-child(7) { flex: 1.4; min-width: 130px; }  /* コーナーカット */
.item-grid .form-group:nth-child(8) { flex: 0.6; }  /* 数量 */
.item-grid .form-group label {
  font-size: 10px;
  margin-bottom: 2px;
  flex: 0 0 auto;
  align-self: flex-start;
}
.item-grid .form-group input,
.item-grid .form-group select { font-size: 13px; padding: 5px 6px; width: 100%; }
.item-num { font-weight: 700; color: var(--navy); font-size: 13px; }

/* 単価・小計インライン */
.result-inline-group {
  flex: 0 0 auto !important;
  min-width: 80px;
  border-left: 1px solid var(--border);
  padding-left: 8px !important;
}
.result-inline-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  white-space: nowrap;
  padding: 5px 0;
}
.result-inline-sub {
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}
/* エラー状態 */
.result-inline-val.has-error {
  color: #fff;
  background: #e53e3e;
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  white-space: normal;
  line-height: 1.3;
}
.result-inline-sub.has-error {
  color: #e53e3e;
  font-size: 11px;
  font-weight: 600;
}

/* ─── カスタム仕上面指定UI ─── */
.face-selector {
  margin-top: 6px;
  padding: 6px 8px;
  background: #f0f4f8;
  border: 1px solid var(--border);
  border-radius: 6px;
  display: none;
}
.face-selector.active { display: block; }
.face-grid {
  display: grid;
  grid-template-columns: 36px 36px 36px 36px;
  grid-template-rows: 20px 36px 20px;
  gap: 2px;
  width: fit-content;
  margin: 0 auto 4px;
}
.face-cell {
  background: #dce3ec;
  border: 1.5px solid #b0bec5;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: #546e7a;
  font-weight: 600;
  user-select: none;
  transition: background 0.15s, color 0.15s;
}
.face-cell.on {
  background: var(--primary);
  border-color: var(--navy);
  color: #fff;
}
.face-cell.side {
  border-style: dashed;
}
.face-label-text {
  font-size: 10px;
  color: var(--text-light);
  text-align: center;
  margin-top: 2px;
}
.face-label-text strong { color: var(--navy); }

.item-result {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
}
.result-placeholder { color: var(--text-light); font-size: 12px; }
.result-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  color: var(--text-light);
  font-size: 12px;
}
.result-unit span:last-child { color: var(--navy); font-weight: 600; }
.result-subtotal {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 6px;
  font-weight: 700;
  color: var(--navy) !important;
  font-size: 13px !important;
}
.result-subtotal span { color: var(--navy) !important; }
.result-error { color: var(--error); font-size: 12px; }

/* ─── 運賃 ─────────────────────────────────────────────── */
.freight-row {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}
.freight-result {
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: var(--bg);
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.freight-label { font-size: 12px; color: var(--text-light); }
.freight-value { font-size: 22px; font-weight: 700; color: var(--navy); }
.freight-box {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 6px;
  padding: 4px 0;
  border-bottom: 1px dashed var(--border);
}
.freight-items { color: var(--text-light); margin-left: 4px; }

/* ─── 合計サマリー ──────────────────────────────────────── */
.summary-grid { max-width: 420px; }
.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.total-row {
  font-size: 18px;
  font-weight: 700;
  color: var(--navy);
  border-bottom: 2px solid var(--navy);
  padding: 10px 0;
}
.action-buttons {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ─── 寸法公差（各寸法の下に配置） ─────────────────────── */
.dim-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dim-tol {
  font-size: 10px;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: #f0f4f8;
  color: var(--text-light);
  width: 100%;
}
.dim-tol:focus { outline: none; border-color: var(--navy); }

/* ─── コーナーカット（コンパクト2×2） ───────────────────── */
.cc-compact-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
}
.cc-2x2 {
  display: grid;
  grid-template-columns: 18px 18px;
  grid-template-rows: 18px 18px;
  gap: 2px;
  padding: 3px;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  background: #f0f4f8;
  flex-shrink: 0;
}
.cc-c {
  background: #dce3ec;
  border: 1.5px solid #90a4ae;
  border-radius: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  font-weight: 700;
  color: #546e7a;
  user-select: none;
  transition: all 0.15s;
}
.cc-c.on  { background: var(--navy); border-color: var(--navy); color: #fff; }
.cc-c:hover { opacity: 0.75; }
.cc-val-inline {
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  overflow: visible;
}
.cc-unit {
  font-size: 11px;
  color: var(--text-light);
  white-space: nowrap;
}
.cc-val-input {
  width: 58px !important;
  font-size: 12px;
  padding: 4px 4px;
}
.cc-status {
  font-size: 10px;
  color: var(--navy);
  font-weight: 600;
}

/* 面取りのメモ */
.dim-note {
  font-size: 9px;
  color: var(--text-light);
  margin-top: 1px;
}

.option-hint {
  font-size: 11px;
  color: var(--text-light);
}
.tol-select {
  font-size: 12px;
  padding: 3px 6px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
}

/* ─── 納期設定 ───────────────────────────────────────────── */
.delivery-section {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.delivery-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
}
.delivery-row .form-group { margin-bottom: 0; }

/* ─── レスポンシブ ──────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; padding: 16px; }
  .item-grid { grid-template-columns: repeat(2, 1fr); }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ─── PDF図面ドロップゾーン（コンパクト） ─────────────────── */
.pdf-drop-zone {
  border: 1px dashed #c5cdd8;
  border-radius: 6px;
  padding: 8px 16px;
  background: #f8fafc;
  transition: border-color 0.2s, background 0.2s;
  cursor: default;
}
.pdf-drop-zone.drag-over {
  border-color: var(--navy-light);
  background: #e8f0fb;
}
.pdf-drop-inner {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  color: var(--text-light);
  font-size: 12px;
}
.pdf-drop-icon { font-size: 18px; line-height: 1; }
.pdf-drop-sub { font-size: 11px; color: #b0bec5; }
.pdf-file-label {
  margin-left: auto;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}
.pdf-parse-status {
  margin-top: 6px;
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 5px;
}
.pdf-parse-status.loading  { background: #e3f0ff; color: #1a6aaa; }
.pdf-parse-status.success  { background: #e6f9ee; color: #1a7a42; }
.pdf-parse-status.error    { background: #fde8e8; color: #b71c1c; }
.badge-beta {
  font-size: 9px;
  font-weight: 600;
  background: #90a4ae;
  color: #fff;
  padding: 1px 5px;
  border-radius: 8px;
  vertical-align: middle;
  margin-left: 4px;
}
.btn-outline {
  background: transparent;
  border: 1px solid #b0bec5;
  color: var(--text-light);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
}
.btn-outline:hover { background: var(--navy-light); color: #fff; border-color: var(--navy-light); }

/* ─── 見積合計サマリー ───────────────────────────────────── */
.summary-totals-wrap {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.summary-meta-box {
  flex: 1;
  min-width: 220px;
  background: #f0f6ff;
  border: 1px solid #c5d8f5;
  border-radius: 8px;
  padding: 14px 18px;
}
.summary-meta-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.summary-meta-label {
  font-size: 12px;
  color: #5a6a7e;
  white-space: nowrap;
}
.summary-meta-val {
  font-size: 15px;
  font-weight: 700;
  color: #1a3a5c;
}
.summary-grid {
  flex: 0 0 320px;
}

/* 4F 板厚セレクト */
.thick-select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #b0bec5;
  border-radius: 5px;
  font-size: 13px;
  background: #fffde7;
  color: #1a3a5c;
  font-weight: 600;
}
.thick-select:focus { outline: 2px solid #1565c0; border-color: #1565c0; }
