/* ============================================================
   みえるDM v2 管理画面 共通CSS
   version: v3
   v2: フォント13px基準、余白改善、モバイル対応、コピー機能
   v3: 新規作成画面の中央寄せ
   ============================================================ */
:root {
  --c-bg: #eef1f6;
  --c-sidebar: #1B2A4A;
  --c-sidebar-hover: rgba(255,255,255,.08);
  --c-sidebar-active: rgba(91,159,232,.15);
  --c-accent: #5B9FE8;
  --c-primary: #2563EB;
  --c-primary-dark: #1d4ed8;
  --c-success: #16a34a;
  --c-success-dark: #15803d;
  --c-danger: #dc2626;
  --c-danger-dark: #b91c1c;
  --c-warning: #ea580c;
  --c-warning-dark: #c2410c;
  --c-text: #333;
  --c-text-light: #64748b;
  --c-text-muted: #94a3b8;
  --c-white: #fff;
  --c-card: #fff;
  --c-border: #e5e7eb;
  --c-border-light: #f1f5f9;
  --c-bg-light: #f8fafc;
  --c-info: #1478A5;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --font: 'Noto Sans JP', sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 13px; background: var(--c-bg); color: var(--c-text); }

/* --- レイアウト --- */
.app-wrap { display: flex; min-height: 100vh; }
.sidebar { width: 200px; background: var(--c-sidebar); color: var(--c-white); flex-shrink: 0; display: flex; flex-direction: column; position: fixed; top: 0; left: 0; height: 100vh; z-index: 100; transition: transform .25s; }
.sidebar-logo { padding: 12px 16px; border-bottom: 1px solid rgba(255,255,255,.1); display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.sidebar-logo img { height: 28px; border-radius: 4px; }
.sidebar-close { display: none; background: none; border: none; color: rgba(255,255,255,.6); font-size: 20px; cursor: pointer; padding: 0 4px; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 10px 16px; color: rgba(255,255,255,.7); cursor: pointer; font-size: 12px; transition: all .15s; border-left: 3px solid transparent; text-decoration: none; }
.nav-item:hover { background: var(--c-sidebar-hover); color: var(--c-white); text-decoration: none; }
.nav-item.active { background: var(--c-sidebar-active); color: var(--c-accent); border-left-color: var(--c-accent); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; opacity: .7; }
.nav-item.active svg { opacity: 1; }
.sidebar-footer { margin-top: auto; padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-footer a { display: block; text-align: center; color: var(--c-text-muted); font-size: 11px; text-decoration: none; margin-bottom: 8px; }
.sidebar-footer button { background: rgba(255,255,255,.1); color: rgba(255,255,255,.7); border: none; padding: 6px 12px; border-radius: 4px; cursor: pointer; font-size: 11px; width: 100%; font-family: var(--font); }
.sidebar-overlay { display: none; }
.hamburger { display: none; background: var(--c-sidebar); color: #fff; border: none; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 18px; cursor: pointer; position: fixed; top: 10px; left: 10px; z-index: 90; }
.main { flex: 1; padding: 24px 28px; margin-left: 200px; overflow-x: auto; }
.page-title { font-size: 16px; font-weight: 700; color: var(--c-sidebar); margin-bottom: 4px; }
.page-sub { font-size: 12px; color: #888; margin-bottom: 14px; }

/* --- ログイン --- */
.login-wrap { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--c-sidebar); }
.login-card { width: 380px; background: var(--c-white); border-radius: var(--radius-lg); box-shadow: 0 4px 24px rgba(0,0,0,.08); overflow: hidden; }
.login-header { padding: 32px 32px 0; text-align: center; }
.login-header img { height: 52px; margin-bottom: 8px; border-radius: 8px; }
.login-header p { font-size: 12px; color: #888; margin-top: 4px; }
.login-body { padding: 20px 32px 32px; }

/* --- フォーム --- */
.fg { margin-bottom: 12px; }
.fg label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 5px; color: #555; }
.fg .req::after { content: " *"; color: var(--c-danger); font-size: 11px; }
.fg input, .fg select, .fg textarea { width: 100%; padding: 8px 12px; border: 1px solid #ddd; border-radius: var(--radius-sm); font-size: 13px; font-family: var(--font); }
.fg input:focus, .fg select:focus, .fg textarea:focus { border-color: var(--c-accent); outline: none; box-shadow: 0 0 0 3px rgba(91,159,232,.12); }
.fg input:disabled, .fg select:disabled { background: #f5f5f5; color: #999; }
.fg .note { font-size: 11px; color: #999; margin-top: 3px; }
.form-section { font-size: 15px; font-weight: 500; margin: 0 0 16px; padding-bottom: 10px; border-bottom: 1px solid var(--c-border); color: var(--c-sidebar); }

/* --- ボタン --- */
.btn { font-family: var(--font); font-size: 12px; font-weight: 500; border: none; padding: 7px 14px; border-radius: var(--radius-sm); cursor: pointer; transition: all .15s; display: inline-flex; align-items: center; gap: 5px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--c-primary); color: var(--c-white); }
.btn-primary:hover:not(:disabled) { background: var(--c-primary-dark); }
.btn-success { background: var(--c-success); color: var(--c-white); }
.btn-success:hover:not(:disabled) { background: var(--c-success-dark); }
.btn-danger { background: var(--c-danger); color: var(--c-white); }
.btn-danger:hover:not(:disabled) { background: var(--c-danger-dark); }
.btn-warning { background: var(--c-warning); color: var(--c-white); }
.btn-warning:hover:not(:disabled) { background: var(--c-warning-dark); }
.btn-ghost { background: transparent; color: #555; border: 1px solid #ddd; }
.btn-ghost:hover:not(:disabled) { background: #f5f5f5; }
.btn-sm { padding: 5px 10px; font-size: 11px; }
.btn-block { width: 100%; justify-content: center; }

/* --- カード・テーブル --- */
.card { background: var(--c-card); border-radius: var(--radius); padding: 18px 22px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.04); border: 1px solid var(--c-border); }
.card h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--c-sidebar); display: flex; align-items: center; gap: 6px; }
.card-accent-blue { border-left: 3px solid var(--c-primary); }
.card-accent-green { border-left: 3px solid var(--c-success); }
.card-accent-orange { border-left: 3px solid var(--c-warning); }
.tbl-wrap { overflow-x: auto; overflow-y: auto; max-height: 520px; }
table { width: 100%; border-collapse: collapse; font-size: 11px; }
th { padding: 7px 8px; text-align: left; background: var(--c-bg-light); color: var(--c-text-light); font-weight: 500; font-size: 10px; border-bottom: 2px solid #e2e8f0; cursor: default; white-space: nowrap; user-select: none; position: sticky; top: 0; z-index: 4; }
th.sortable { cursor: pointer; }
th.sortable:hover { background: #eef2f7; color: var(--c-text); }
td { padding: 6px 8px; border-bottom: 1px solid var(--c-border-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
tr:hover td { background: var(--c-bg-light); }
tr.row-warn { background: #fde8e8; }
tr.row-warn:hover td { background: #fcd6d6; }

/* --- メッセージ・バッジ --- */
.error { color: var(--c-danger); font-size: 12px; margin-top: 4px; }
.success { color: var(--c-success); font-size: 12px; margin-top: 4px; }
.loading { text-align: center; padding: 30px; color: var(--c-text-muted); }
.badge { display: inline-flex; align-items: center; gap: 3px; padding: 3px 10px; border-radius: 12px; font-size: 10px; font-weight: 600; }
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.b-active { background: #dcfce7; color: #166534; }
.b-active::before { background: #639922; }
.b-sched { background: #e0e7ff; color: #3730a3; }
.b-sched::before { background: #378ADD; }
.b-closed { background: #f1f5f9; color: var(--c-text-light); }
.b-closed::before { background: #888780; }
.b-archive { background: #f1f5f9; color: var(--c-text-muted); }
.b-archive::before { background: #B4B2A9; }

/* --- 一覧用 --- */
.actions { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.search-box { padding: 7px 12px; border: 1px solid #ddd; border-radius: var(--radius-sm); font-size: 12px; width: 260px; font-family: var(--font); }
.search-box:focus { border-color: var(--c-accent); outline: none; box-shadow: 0 0 0 3px rgba(91,159,232,.12); }
.ev-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.ev-tab { padding: 6px 16px; font-size: 12px; font-weight: 500; color: var(--c-text-light); cursor: pointer; font-family: var(--font); background: #f1f5f9; border: 1px solid var(--c-border); border-radius: 20px; display: inline-flex; align-items: center; gap: 5px; transition: all .15s; }
.ev-tab.active { color: var(--c-white); background: var(--c-sidebar); border-color: var(--c-sidebar); }
.ev-tab:hover:not(.active) { color: var(--c-text); background: #e2e8f0; }
.ev-tab .count { font-size: 10px; background: rgba(0,0,0,.1); padding: 1px 6px; border-radius: 8px; }
.ev-tab.active .count { background: rgba(255,255,255,.2); }
.count-info { font-size: 12px; color: var(--c-text-light); margin-bottom: 10px; }

/* --- 一覧列幅 --- */
.col-job { width: 72px; }
.col-branch { width: 30px; }
.col-name { width: 130px; }
.col-date { width: 78px; }
.col-status { width: 62px; }
.col-data { width: 70px; }
.col-qr { width: 52px; text-align: right; }
.col-chk { width: 30px; text-align: center; }
.col-action { width: 50px; }
.col-id { width: 55px; }
.col-cname { width: 150px; }
.col-contact { width: 90px; }
.col-email { width: 170px; }
.col-phone { width: 105px; }
.col-fax { width: 105px; }
.col-copy { width: 32px; text-align: center; }

/* --- データ検証ラベル --- */
.data-ok { color: var(--c-success); font-size: 10px; font-weight: 500; }
.data-ng { color: var(--c-danger); font-size: 10px; font-weight: 500; }
.data-warn { color: var(--c-warning); font-size: 10px; font-weight: 600; }
.data-none { color: var(--c-danger); font-size: 10px; font-weight: 500; }

/* --- 詳細ヘッダー --- */
.det-header { background: linear-gradient(135deg, #1B2A4A 0%, #2d4a7a 100%); color: var(--c-white); border-radius: var(--radius); padding: 18px 22px; margin-bottom: 14px; }
.det-h-top { font-size: 11px; opacity: .6; margin-bottom: 3px; }
.det-h-mid { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.det-h-badge { display: inline-flex; align-items: center; gap: 3px; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.det-h-badge.green { background: rgba(72,168,104,.25); color: #86efac; }
.det-h-badge.red { background: rgba(239,68,68,.25); color: #fca5a5; }
.det-h-badge.blue { background: rgba(59,130,246,.25); color: #93c5fd; }
.det-h-badge.gray { background: rgba(148,163,184,.25); color: #cbd5e1; }
.sum-cards { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.sum-card { flex: 1; min-width: 100px; background: var(--c-white); border: 1px solid #e2e8f0; border-radius: var(--radius); padding: 14px; text-align: center; }
.sum-card .num { font-size: 22px; font-weight: 700; color: var(--c-sidebar); }
.sum-card .label { font-size: 11px; color: var(--c-text-muted); margin-top: 3px; }

/* --- 情報行（詳細画面・グリッド版） --- */
.info-grid { display: grid; grid-template-columns: 140px 1fr; gap: 0; }
.info-grid .info-row { display: contents; }
.info-grid .info-row .lbl { padding: 9px 0; font-size: 13px; color: var(--c-text-light); border-bottom: 1px solid var(--c-border-light); display: flex; align-items: center; }
.info-grid .info-row .val { padding: 9px 0; font-size: 13px; border-bottom: 1px solid var(--c-border-light); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* --- 情報行（詳細画面・フレックス版・後方互換） --- */
.info-row { display: flex; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--c-border-light); font-size: 13px; }
.info-row .lbl2 { width: 140px; flex-shrink: 0; color: var(--c-text-light); font-size: 13px; }
.info-row .val2 { flex: 1; color: var(--c-text); font-size: 13px; }

/* --- ステップ・インポート --- */
.step-label { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: 700; }
.step-1 { background: #dbeafe; color: #1e40af; }
.step-2 { background: #dcfce7; color: #166534; }
.import-status { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 10px; }
.import-status.ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.import-status.warn { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.csv-preview { max-height: 100px; overflow-y: auto; background: var(--c-bg-light); padding: 8px; border-radius: 4px; font-size: 11px; font-family: monospace; margin: 5px 0; border: 1px solid var(--c-border); }
.copy-box { display: flex; align-items: center; gap: 8px; background: var(--c-bg-light); border: 1px solid var(--c-border); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 12px; font-family: monospace; word-break: break-all; }
.copy-box span { flex: 1; }
.verify-status { display: flex; gap: 16px; margin: 8px 0; font-size: 13px; align-items: center; flex-wrap: wrap; }

/* --- コピー機能（顧客一覧） --- */
td.copyable { cursor: pointer; position: relative; }
td.copyable:hover { background: #eef4fb !important; }
td.copyable:hover::after { content: '📋'; position: absolute; right: 4px; top: 50%; transform: translateY(-50%); font-size: 10px; opacity: .5; }
td.copyable.copied { background: #f0fdf4 !important; }
td.copyable.copied::after { content: '✓'; color: var(--c-success); font-weight: 700; opacity: 1; }
.row-copy { background: none; border: 1px solid #ddd; border-radius: 4px; padding: 2px 6px; font-size: 10px; color: var(--c-text-light); cursor: pointer; font-family: var(--font); white-space: nowrap; }
.row-copy:hover { background: #f0f4f8; color: var(--c-text); border-color: #bbb; }
.row-copy.copied { background: #f0fdf4; color: var(--c-success); border-color: #bbf7d0; }

/* --- トースト通知 --- */
.copy-toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(60px); background: var(--c-sidebar); color: #fff; padding: 8px 20px; border-radius: 20px; font-size: 12px; font-family: var(--font); z-index: 999; opacity: 0; transition: all .3s; max-width: 360px; text-align: center; pointer-events: none; }
.copy-toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* --- その他 --- */
.section-divider { border: none; border-top: 1px solid var(--c-border); margin: 14px 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 20px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px 20px; }
.back-link { color: var(--c-primary); cursor: pointer; font-size: 13px; margin-bottom: 12px; display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.create-form { max-width: 700px; margin: 0 auto; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.detail-link { color: var(--c-primary); text-decoration: none; font-size: 11px; font-weight: 500; }
.detail-link:hover { text-decoration: underline; }
.cust-link { color: var(--c-primary); cursor: pointer; font-size: 12px; }
.cust-link:hover { text-decoration: underline; }
.preview-btn { background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.2); padding: 6px 14px; border-radius: var(--radius-sm); font-size: 12px; cursor: pointer; font-family: var(--font); white-space: nowrap; }
.preview-btn:hover { background: rgba(255,255,255,.25); }
.report-card { background: var(--c-bg-light); border: 1px solid #e2e8f0; border-radius: var(--radius-sm); padding: 12px; margin-top: 8px; }
.warn-box { background: #fffbeb; border: 1px solid #fde68a; border-radius: var(--radius-sm); padding: 8px 14px; font-size: 12px; color: #92400e; margin-bottom: 10px; }

/* ===== モバイル対応（768px以下） ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-close { display: block; }
  .sidebar-overlay.show { display: block; position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,.4); z-index: 99; }
  .hamburger { display: block; }
  .main { margin-left: 0; padding: 16px; padding-top: 50px; }
  .det-header { padding: 14px 16px; }
  .det-h-mid { font-size: 14px; gap: 6px; }
  .preview-btn { margin-top: 8px; }
  .sum-cards { flex-wrap: wrap; }
  .sum-card { min-width: calc(50% - 6px); }
  .sum-card .num { font-size: 18px; }
  .card { padding: 14px 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .info-row .lbl { padding: 8px 0 2px; border-bottom: none; font-size: 11px; font-weight: 500; }
  .info-row .val { padding: 2px 0 10px; }
  input[type="text"], input[type="email"] { max-width: 100% !important; width: 100%; }
  .search-box { width: 100%; }
  .tbl-wrap { max-height: 400px; }
  table { table-layout: auto; }
  .copy-box { flex-direction: column; align-items: stretch; gap: 6px; }
  .create-form { max-width: 100%; }
}
