/* ========================================
   WOODWORK 業務管理システム - 共通スタイル
   ======================================== */

/* CSS Variables */
:root {
  --color-primary: #3E1F00;
  --color-primary-dark: #2A1400;
  --color-primary-light: #5C2E00;
  --color-primary-btn: #5C2E00;
  --color-accent: #8B5E3C;
  --color-accent-light: #D4A574;
  --color-bg: #F5F3F0;
  --color-bg-white: #FFFFFF;
  --color-border: #E0D8CF;
  --color-text: #1A1A1A;
  --color-text-muted: #666666;
  --color-text-light: #999999;
  --color-success: #2E7D32;
  --color-success-bg: #E8F5E9;
  --color-warning: #F57C00;
  --color-warning-bg: #FFF3E0;
  --color-danger: #C62828;
  --color-danger-bg: #FFEBEE;
  --color-info: #1565C0;
  --color-info-bg: #E3F2FD;
  --sidebar-width: 220px;
  --header-height: 56px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.14);
  --transition: 0.18s ease;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; }

/* ========================================
   LAYOUT
   ======================================== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* SIDEBAR → css/sidebar.css で管理 */

/* MAIN CONTENT */
.main-content {
  margin-left: 240px; /* sidebar.css の --sb-width に合わせる */
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0; /* flexアイテムが内部の幅広テーブルに引っ張られて横スクロールが効かなくなるのを防ぐ */
  max-width: 100%;
}

/* HEADER */
.topbar {
  height: var(--header-height);
  background: var(--color-bg-white);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow-sm);
}
.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-primary);
  flex: 1;
}
.topbar-search {
  display: flex;
  align-items: center;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 5px 14px;
  gap: 8px;
  width: 240px;
}
.topbar-search input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: var(--color-text);
  width: 100%;
}
.topbar-search .search-icon { color: var(--color-text-muted); font-size: 13px; }
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  font-size: 13px;
  font-weight: 500;
}
.topbar-user:hover { background: var(--color-bg); }
.topbar-user .user-avatar {
  width: 30px;
  height: 30px;
  background: var(--color-accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
}
.hamburger-btn {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--color-text);
  padding: 4px;
}

/* PAGE BODY */
.page-body {
  padding: 24px;
  flex: 1;
  min-width: 0;
}
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-primary);
}
.breadcrumb {
  font-size: 12px;
  color: var(--color-text-muted);
  margin-bottom: 4px;
}
.breadcrumb span { color: var(--color-primary); font-weight: 500; }

/* ========================================
   CARDS
   ======================================== */
.card {
  background: var(--color-bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  min-width: 0;
  max-width: 100%;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-primary);
}
.card-body { padding: 20px; }

/* STAT CARDS */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--color-bg-white);
  border-radius: var(--radius-md);
  padding: 16px;
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}
.stat-card-label {
  font-size: 11.5px;
  color: var(--color-text-muted);
  margin-bottom: 6px;
  font-weight: 500;
}
.stat-card-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 4px;
  white-space: nowrap;
}
.stat-card-sub {
  font-size: 11px;
  color: var(--color-text-muted);
}
.stat-card-sub .positive { color: var(--color-success); font-weight: 600; }
.stat-card-sub .negative { color: var(--color-danger); font-weight: 600; }
.stat-card-icon {
  font-size: 22px;
  margin-bottom: 8px;
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  transition: all var(--transition);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.4;
}
.btn-primary {
  background: var(--color-primary-btn);
  color: #FFFFFF;
}
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-secondary {
  background: var(--color-bg);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-secondary:hover { background: var(--color-border); }
.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { background: #1B5E20; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #8B0000; }
.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}
.btn-outline:hover { background: var(--color-primary); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-block { width: 100%; justify-content: center; }
.btn-icon { padding: 7px 10px; }

/* ========================================
   FORMS
   ======================================== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-primary);
  margin-bottom: 6px;
}
.form-label .required {
  color: var(--color-danger);
  margin-left: 4px;
}
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--color-text);
  background: var(--color-bg-white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  line-height: 1.5;
}
.form-control:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(139,94,60,0.12);
}
.form-control::placeholder { color: var(--color-text-light); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.input-group { display: flex; gap: 0; }
.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ========================================
   TABLES
   ======================================== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-md);
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table thead tr {
  background: var(--color-bg);
  border-bottom: 2px solid var(--color-border);
}
.data-table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: rgba(62,31,0,0.03); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .td-right { text-align: right; }
.data-table .td-center { text-align: center; }
/* ========================================
   EXCEL風 テーブル（案件管理表）
   ======================================== */
.excel-table-wrapper {
  overflow: auto;
  border: 1px solid #B7B7B7;
  border-radius: 2px;
  max-height: 74vh;
  max-width: 100%;
  background: #fff;
}
.excel-table {
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
  font-family: 'Noto Sans JP', Arial, sans-serif;
}
.excel-table th, .excel-table td {
  border: 1px solid #B7B7B7;
  padding: 5px 8px;
  white-space: nowrap;
}
.excel-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #E8EDF3;
  color: #1A1A1A;
  font-weight: 700;
  font-size: 11.5px;
  text-align: center;
  border-bottom: 2px solid #8FA3BD;
}
.excel-table thead tr.excel-group-row th {
  background: #D6E0EC;
  top: 0;
  z-index: 4;
}
.excel-table thead tr.excel-col-row th {
  top: 27px;
  z-index: 3;
}
.excel-table thead th[style*="left:0"] {
  left: 0;
  z-index: 5;
  background: #D6E0EC;
}
.excel-table thead th[style*="left:36px"] {
  left: 36px;
  z-index: 5;
  background: #D6E0EC;
}
.excel-table tbody th.excel-rownum {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #E8EDF3;
  text-align: center;
  font-weight: 700;
  color: var(--color-text-muted);
}
.excel-table td.excel-col-name {
  position: sticky;
  left: 36px;
  z-index: 2;
  background: #fff;
  text-align: left;
  font-weight: 600;
  min-width: 220px;
  max-width: 260px;
  white-space: normal;
}
.excel-table tbody tr:nth-child(even) td:not(.excel-col-name),
.excel-table tbody tr:nth-child(even) th { background: #F7F8FA; }
.excel-table tbody tr:nth-child(even) td.excel-col-name { background: #FAFAF8; }
.excel-table tbody tr:hover td:not(.excel-col-name),
.excel-table tbody tr:hover th { background: #FFF6E0; }
.excel-table tbody tr:hover td.excel-col-name { background: #FFF6E0; }
.excel-table td.excel-num { text-align: right; font-variant-numeric: tabular-nums; }
.excel-table td.excel-center { text-align: center; }
.excel-table td.excel-money { text-align: right; font-variant-numeric: tabular-nums; }
.excel-table td.excel-status-完了 { color: #2E7D32; font-weight: 700; text-align: center; }
.excel-table td.excel-status-進行中,
.excel-table td.excel-status-工事中 { color: #F57C00; font-weight: 700; text-align: center; }
.excel-table td.excel-status-着工前 { color: #1565C0; font-weight: 700; text-align: center; }
.excel-table td.excel-status-中止 { color: #C62828; font-weight: 700; text-align: center; }
.excel-table td.excel-flag-on { background: #FFF3CD !important; color: #8A6D00; font-weight: 700; text-align: center; }
.excel-table td.excel-flag-off { text-align: center; color: #B0B0B0; }
.excel-table td.excel-note { text-align: left; white-space: normal; min-width: 140px; }
.excel-table .excel-diff-minus { color: #C62828; }
.excel-table .excel-diff-plus { color: #1565C0; }
.excel-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.excel-table-legend {
  display: flex;
  gap: 14px;
  font-size: 11.5px;
  color: var(--color-text-muted);
  flex-wrap: wrap;
}
.excel-table-legend span { display: inline-flex; align-items: center; gap: 5px; }
.excel-table-legend i {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px; border: 1px solid #B7B7B7;
}
.table-link {
  color: var(--color-primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.table-link:hover { color: var(--color-accent); }

/* ========================================
   BADGES / STATUS
   ======================================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-info { background: var(--color-info-bg); color: var(--color-info); }
.badge-default { background: #F0EEEC; color: var(--color-text-muted); }
.badge-primary { background: rgba(62,31,0,0.1); color: var(--color-primary); }

/* ========================================
   TABS
   ======================================== */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--color-border);
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
  margin-bottom: 24px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-item {
  padding: 10px 16px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  border-bottom: 2.5px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.tab-item:hover { color: var(--color-primary); }
.tab-item.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ========================================
   SEARCH / FILTER BAR
   ======================================== */
.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.search-input-wrap {
  display: flex;
  align-items: center;
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  gap: 8px;
  flex: 1;
  min-width: 180px;
}
.search-input-wrap input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13.5px;
  color: var(--color-text);
  width: 100%;
}
.search-input-wrap .icon { color: var(--color-text-muted); }
.filter-select {
  padding: 7px 32px 7px 12px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  font-size: 13.5px;
  color: var(--color-text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  outline: none;
  cursor: pointer;
  min-width: 110px;
}
.filter-select:focus { border-color: var(--color-accent); }

/* ========================================
   PAGINATION
   ======================================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
  font-size: 13px;
  color: var(--color-text-muted);
}
.pagination-controls { display: flex; gap: 4px; }
.page-btn {
  padding: 5px 10px;
  border: 1px solid var(--color-border);
  background: var(--color-bg-white);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}
.page-btn:hover { background: var(--color-bg); }
.page-btn.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ========================================
   MODALS
   ======================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.15s ease;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--color-bg-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease;
}
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1000px; }
.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-primary);
}
.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--color-text); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ========================================
   STEPPER / WIZARD
   ======================================== */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
}
.step-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--color-text-muted);
  font-weight: 500;
}
.step-num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--color-border);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.step-item.active .step-num { background: var(--color-primary); color: #fff; }
.step-item.active { color: var(--color-primary); }
.step-item.done .step-num { background: var(--color-success); color: #fff; }
.step-item.done { color: var(--color-success); }
.step-line {
  width: 36px;
  height: 2px;
  background: var(--color-border);
  margin: 0 4px;
}

/* ========================================
   DETAIL ROWS
   ======================================== */
.detail-section {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 16px;
}
.detail-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 12px;
}
.detail-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13.5px;
  align-items: flex-start;
}
.detail-row:last-child { margin-bottom: 0; }
.detail-label {
  color: var(--color-text-muted);
  font-weight: 500;
  min-width: 100px;
  flex-shrink: 0;
}
.detail-value { color: var(--color-text); font-weight: 500; }
.detail-value-large {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-primary);
}

/* ========================================
   NOTICE / ALERTS
   ======================================== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.alert-success { background: var(--color-success-bg); color: var(--color-success); border: 1px solid #A5D6A7; }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); border: 1px solid #FFCC80; }
.alert-danger { background: var(--color-danger-bg); color: var(--color-danger); border: 1px solid #FFCDD2; }
.alert-info { background: var(--color-info-bg); color: var(--color-info); border: 1px solid #90CAF9; }

/* ========================================
   AMOUNTS / MONEY
   ======================================== */
.amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.amount-large { font-size: 24px; font-weight: 700; color: var(--color-primary); }
.amount-positive { color: var(--color-success); }
.amount-negative { color: var(--color-danger); }
.amount-muted { color: var(--color-text-muted); }

/* ========================================
   ALERT NOTE (案内・注意メッセージ)
   ======================================== */
.alert-note {
  background: var(--color-info-bg);
  border: 1px solid var(--color-info);
  color: var(--color-primary);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.6;
}

/* ========================================
   UTILITY
   ======================================== */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--color-text-muted); }
.text-small { font-size: 12px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.see-all-link {
  color: var(--color-info);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.see-all-link:hover { text-decoration: underline; }
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--color-text-muted);
  font-size: 13px;
  gap: 10px;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--color-text-muted);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state-text { font-size: 14px; }
.divider {
  height: 1px;
  background: var(--color-border);
  margin: 16px 0;
}

/* ========================================
   CHARTS
   ======================================== */
.chart-container {
  position: relative;
}

/* ========================================
   TOAST
   ======================================== */
.toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--color-bg-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  min-width: 260px;
  border-left: 4px solid var(--color-success);
  animation: slideInRight 0.25s ease;
}
.toast-error { border-left-color: var(--color-danger); }
.toast-warning { border-left-color: var(--color-warning); }
.toast-info { border-left-color: var(--color-info); }

/* ========================================
   PRINT
   ======================================== */
@media print {
  .sidebar, .topbar, .page-header .btn, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
  .page-body { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
  @page { size: A3 landscape; margin: 8mm; }
  .excel-table-wrapper { max-height: none; overflow: visible; border: 1px solid #000; }
  .excel-table { font-size: 8.5px; }
  .excel-table th, .excel-table td { padding: 2px 4px; }
  .excel-table thead th { position: static; }
  .excel-table tbody th.excel-rownum,
  .excel-table td.excel-col-name { position: static; }
  .excel-table td.excel-center:last-child,
  .excel-table th:last-child { display: none; } /* 操作列を印刷時非表示 */
  .excel-table-toolbar { display: none; }
  .search-bar { display: none !important; }
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 1200px) {
  .stat-cards { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  /* サイドバーレスポンシブ → css/sidebar.css で管理 */
  .main-content { margin-left: 0 !important; }
  .hamburger-btn { display: block; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .stat-cards { grid-template-columns: 1fr 1fr; }
  .page-body { padding: 16px; }
}

/* ========================================
   詳細ページ共通（案件カルテ／顧客詳細 等）
   ======================================== */
.detail-page-header {
  background: var(--color-bg-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.detail-page-header h2 { font-size: 20px; font-weight: 700; color: var(--color-primary); margin-bottom: 6px; }
.detail-page-meta { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--color-text-muted); }
.detail-page-meta strong { color: var(--color-text); }
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.detail-info-section {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}
.detail-info-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--color-border);
}
.detail-info-row {
  display: flex;
  gap: 8px;
  margin-bottom: 9px;
  font-size: 13.5px;
}
.detail-info-row:last-child { margin-bottom: 0; }
.detail-info-label { color: var(--color-text-muted); font-weight: 500; min-width: 110px; flex-shrink: 0; }
.detail-info-value { color: var(--color-text); font-weight: 500; }
@media (max-width: 700px) { .detail-grid { grid-template-columns: 1fr; } }

.detail-section-block {
  background: var(--color-bg-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.detail-section-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.detail-section-block-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.detail-section-block-body { padding: 20px; }

.summary-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
@media (max-width: 900px) { .summary-stat-grid { grid-template-columns: repeat(2, 1fr); } }
.summary-stat-item {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.summary-stat-item .ss-label { font-size: 11.5px; color: var(--color-text-muted); margin-bottom: 6px; font-weight: 500; }
.summary-stat-item .ss-value { font-size: 18px; font-weight: 700; color: var(--color-primary); }

/* ========================================
   折りたたみ式セクション（詳細画面の履歴表示等で共通利用）
   ======================================== */
.collapsible-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--color-primary);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.collapsible-toggle-btn:hover { background: var(--color-bg); }
.collapsible-toggle-btn .caret {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 11px;
}
.collapsible-toggle-btn.collapsed .caret { transform: rotate(-90deg); }
.collapsible-body {
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.collapsible-body.collapsed { display: none; }

/* 案件カルテ／詳細画面：セクションヘッダーに折りたたみボタンを併置 */
.karte-section-block-header .collapsible-toggle-btn,
.detail-section-block-header .collapsible-toggle-btn {
  margin-left: auto;
}

/* ========================================
   支店リスト（顧客詳細ページ）
   ======================================== */
.branch-card {
  background: var(--color-bg);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid var(--color-border);
}
.branch-card:last-child { margin-bottom: 0; }
.branch-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.branch-card-name { font-size: 14px; font-weight: 700; color: var(--color-primary); }
.branch-card-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 16px; font-size: 12.5px; color: var(--color-text-muted); }
.branch-card-grid strong { color: var(--color-text); font-weight: 500; }
@media (max-width: 700px) { .branch-card-grid { grid-template-columns: 1fr; } }

/* ========================================
   案件カルテ：全体金額サマリー（追加工事・減額を含む）
   ======================================== */
.total-amount-box {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
  border-radius: var(--radius-lg);
  padding: 18px 22px;
  color: #fff;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
}
.total-amount-box .tab-label { font-size: 12px; opacity: 0.85; margin-bottom: 4px; }
.total-amount-box .tab-value { font-size: 22px; font-weight: 700; }
.total-amount-box .tab-breakdown { display: flex; gap: 18px; flex-wrap: wrap; }
.total-amount-box .tab-item { min-width: 110px; }

/* 枝分かれ案件（追加工事・減額）リスト */
.branch-project-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: var(--color-bg);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  font-size: 13px;
}
.branch-project-item:last-child { margin-bottom: 0; }
.branch-project-item .bp-name { font-weight: 600; }
.branch-project-item .bp-amount { font-weight: 700; }
.branch-project-item .bp-amount.negative { color: var(--color-danger); }
.branch-project-item .bp-amount.positive { color: var(--color-success); }

/* ========================================
   INVOICE / ESTIMATE PRINT SHEET
   ======================================== */
.doc-sheet {
  background: #fff;
  max-width: 794px;
  margin: 0 auto;
  padding: 40px 48px;
  font-size: 13px;
  line-height: 1.7;
  color: #111;
}
.doc-sheet .doc-title {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  color: var(--color-primary);
  margin-bottom: 28px;
  letter-spacing: 4px;
}
.doc-meta { margin-bottom: 24px; }
.doc-meta-row { display: flex; justify-content: space-between; margin-bottom: 4px; }
.doc-to { font-size: 15px; font-weight: 700; border-bottom: 2px solid #333; padding-bottom: 4px; margin-bottom: 16px; }
.doc-from { text-align: right; font-size: 12px; color: #444; }
.doc-amount-box {
  border: 2px solid #333;
  display: inline-block;
  padding: 10px 20px;
  margin-bottom: 20px;
}
.doc-amount-box .label { font-size: 12px; color: #666; }
.doc-amount-box .value { font-size: 22px; font-weight: 700; }
.doc-items-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.doc-items-table th, .doc-items-table td { border: 1px solid #ccc; padding: 8px 10px; }
.doc-items-table th { background: #f5f5f5; font-weight: 700; text-align: center; }
.doc-items-table .r { text-align: right; }
.doc-items-table .c { text-align: center; }
.doc-totals { margin-left: auto; width: 280px; }
.doc-totals-row { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid #eee; font-size: 13px; }
.doc-totals-row.total { font-size: 16px; font-weight: 700; border-bottom: 2px solid #333; padding: 8px 0; }
