/* =========================================
   M2見積システム - メインスタイル
   ネイビー × ホワイト × ライトグレー
   ========================================= */

:root {
  --navy:        #0d2240;
  --navy-dark:   #081829;
  --navy-mid:    #1a3a5c;
  --navy-light:  #1e4976;
  --orange:      #e87722;
  --orange-dark: #cf6610;
  --white:       #ffffff;
  --gray-50:     #f8f9fa;
  --gray-100:    #f1f3f5;
  --gray-200:    #e9ecef;
  --gray-400:    #ced4da;
  --gray-600:    #6c757d;
  --gray-800:    #343a40;
  --sidebar-w:   220px;
  --navbar-h:    54px;
}

/* ─── Base ─── */
* { box-sizing: border-box; }
body {
  font-family: 'Noto Sans JP', 'メイリオ', sans-serif;
  font-size: 14px;
  background: var(--gray-100);
  color: var(--gray-800);
  margin: 0;
}

/* ─── Navbar ─── */
#topNavbar {
  background: var(--navy-dark);
  height: var(--navbar-h);
  z-index: 1050;
  padding: 0 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.brand-m2 {
  color: var(--orange);
  font-weight: 900;
  font-size: 1.1rem;
}
.navbar-brand { font-size: .95rem; letter-spacing: .05em; }

/* ─── Sidebar ─── */
#sidebar {
  position: fixed;
  top: var(--navbar-h);
  left: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--navbar-h));
  background: var(--navy);
  overflow-y: auto;
  z-index: 1040;
  padding: 1rem .75rem;
  transition: transform .25s ease;
}
#sidebar::-webkit-scrollbar { width: 4px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--navy-mid); border-radius: 2px; }

.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}
.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: .6rem .75rem;
  color: rgba(255,255,255,.75);
  text-decoration: none;
  border-radius: 6px;
  font-size: .875rem;
  transition: background .15s, color .15s;
}
.sidebar-nav li a:hover,
.sidebar-nav li.active a {
  background: var(--navy-light);
  color: #fff;
}
.sidebar-nav li a i { font-size: 1rem; flex-shrink: 0; }

/* Sidebar stats */
.sidebar-stats {
  margin-top: 1.5rem;
  padding: .75rem;
  background: var(--navy-dark);
  border-radius: 8px;
  font-size: .8rem;
}
.stat-label {
  color: rgba(255,255,255,.5);
  font-size: .75rem;
  margin-bottom: .5rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  color: rgba(255,255,255,.8);
  padding: .15rem 0;
}
.stat-val { color: #fff; font-weight: 600; }

/* ─── Main content ─── */
#mainContent {
  margin-left: var(--sidebar-w);
  padding-top: var(--navbar-h);
  min-height: 100vh;
}

/* ─── Page header ─── */
.page-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--navy);
  margin: 0;
}
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ─── Buttons ─── */
.btn-orange {
  background: var(--orange);
  color: #fff;
  border: none;
  font-weight: 600;
}
.btn-orange:hover { background: var(--orange-dark); color: #fff; }

.btn-navy {
  background: var(--navy);
  color: #fff;
  border: none;
}
.btn-navy:hover { background: var(--navy-mid); color: #fff; }

/* ─── Cards ─── */
.card {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.card-header {
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  font-size: .875rem;
  border-radius: 8px 8px 0 0 !important;
  padding: .6rem 1rem;
}
.card-header.light {
  background: var(--gray-50);
  color: var(--navy);
  border-bottom: 2px solid var(--navy);
}

/* ─── Form ─── */
.form-label { font-weight: 600; font-size: .8rem; color: var(--gray-600); margin-bottom: .25rem; }
.form-control, .form-select {
  font-size: .875rem;
  border-color: var(--gray-400);
  border-radius: 5px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--navy-light);
  box-shadow: 0 0 0 .2rem rgba(30,73,118,.15);
}
.required::after { content: ' *'; color: #dc3545; font-size: .75rem; }

/* ─── Table ─── */
.table-m2 { font-size: .875rem; }
.table-m2 thead th {
  background: var(--navy);
  color: #fff;
  font-weight: 600;
  border: none;
  white-space: nowrap;
  padding: .6rem .75rem;
}
.table-m2 tbody tr:hover { background: rgba(30,73,118,.05); }
.table-m2 td { padding: .55rem .75rem; vertical-align: middle; border-color: var(--gray-200); }

/* ─── Estimate create layout ─── */
.estimate-layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 0;
  height: calc(100vh - var(--navbar-h) - 60px);
}
.estimate-form-panel {
  overflow-y: auto;
  padding: 1rem;
  background: var(--gray-50);
}
.estimate-preview-panel {
  background: var(--white);
  border-left: 1px solid var(--gray-200);
  overflow-y: auto;
  position: sticky;
  top: 0;
}

/* ─── Step wizard ─── */
.step-nav {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  gap: 0;
}
.step-nav li {
  flex: 1;
  text-align: center;
  padding: .5rem;
  font-size: .8rem;
  font-weight: 600;
  background: var(--gray-200);
  color: var(--gray-600);
  border-right: 2px solid var(--white);
  cursor: pointer;
}
.step-nav li.active {
  background: var(--navy);
  color: #fff;
}
.step-nav li.done {
  background: var(--navy-mid);
  color: rgba(255,255,255,.8);
}
.step-nav li:first-child { border-radius: 6px 0 0 6px; }
.step-nav li:last-child  { border-radius: 0 6px 6px 0; border-right: none; }

/* ─── Detail rows ─── */
.detail-row { display: flex; gap: 4px; align-items: center; margin-bottom: 4px; }
.detail-row .col-category { width: 80px; }
.detail-row .col-name     { flex: 1; min-width: 120px; }
.detail-row .col-qty      { width: 60px; }
.detail-row .col-price    { width: 90px; }
.detail-row .col-amount   { width: 90px; }
.detail-row .col-tax      { width: 80px; }
.detail-row .col-memo     { width: 90px; }
.detail-row .col-del      { width: 28px; }
.detail-header {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
  font-size: .75rem;
  font-weight: 600;
  color: var(--gray-600);
}
.detail-header .col-category { width: 80px; }
.detail-header .col-name     { flex: 1; }
.detail-header .col-qty      { width: 60px; }
.detail-header .col-price    { width: 90px; }
.detail-header .col-amount   { width: 90px; }
.detail-header .col-tax      { width: 80px; }
.detail-header .col-memo     { width: 90px; }
.detail-header .col-del      { width: 28px; }

.input-amount { background: var(--gray-50); font-weight: 600; }

/* ─── Preview panel ─── */
.preview-header {
  background: var(--navy);
  color: #fff;
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .875rem;
  font-weight: 600;
}
.preview-body {
  padding: 1rem;
}

/* ─── PDF / Print preview ─── */
.estimate-paper {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  font-size: 12px;
  font-family: 'Noto Sans JP', 'メイリオ', sans-serif;
  background: #fff;
  padding: 20px;
}
.estimate-paper h1 {
  text-align: center;
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0 0 .5rem;
  letter-spacing: .2em;
}
.estimate-paper .customer-name { font-size: 1.1rem; font-weight: 700; }
.estimate-paper .company-block { text-align: right; font-size: 11px; }
.estimate-paper .total-box {
  background: var(--navy);
  color: #fff;
  padding: .6rem 1rem;
  border-radius: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1rem 0;
}
.estimate-paper .total-box .amount {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--orange);
}
.estimate-paper table { width: 100%; border-collapse: collapse; font-size: 11px; }
.estimate-paper table th {
  background: var(--navy);
  color: #fff;
  padding: 4px 6px;
  font-weight: 600;
}
.estimate-paper table td {
  padding: 4px 6px;
  border-bottom: 1px solid var(--gray-200);
}
.estimate-paper .subtotal-block {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  padding: .5rem .75rem;
  font-size: 12px;
}
.estimate-paper .final-amount {
  font-size: 1.4rem;
  font-weight: 900;
  color: #dc3545;
}
.estimate-paper .section-title {
  font-size: 11px;
  font-weight: 700;
  background: var(--gray-200);
  padding: 3px 6px;
  margin: .5rem 0 .25rem;
  border-left: 3px solid var(--navy);
}

/* ─── Dashboard ─── */
.kpi-card {
  background: var(--white);
  border-radius: 8px;
  padding: 1.25rem;
  border: 1px solid var(--gray-200);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.kpi-card .kpi-label { font-size: .8rem; color: var(--gray-600); }
.kpi-card .kpi-value { font-size: 1.75rem; font-weight: 700; color: var(--navy); }
.kpi-card .kpi-value.orange { color: var(--orange); }

/* ─── Search form ─── */
.search-bar {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

/* ─── Responsive ─── */
@media (max-width: 991px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.show { transform: translateX(0); }
  #mainContent { margin-left: 0; }
  .estimate-layout { grid-template-columns: 1fr; height: auto; }
  .estimate-preview-panel { display: none; }
}

/* ─── Print ─── */
@media print {
  #topNavbar, #sidebar, .no-print, .page-actions { display: none !important; }
  #mainContent { margin-left: 0 !important; padding-top: 0 !important; }
  body { background: #fff; }
  .estimate-paper { padding: 0; max-width: 100%; }
  .card { border: none !important; box-shadow: none !important; }
}

/* ─── Login page ─── */
.login-page {
  min-height: 100vh;
  background: var(--navy-dark);
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: #fff;
  border-radius: 12px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,.3);
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo .brand { font-size: 2rem; font-weight: 900; color: var(--navy); }
.login-logo .brand span { color: var(--orange); }
.login-logo .sub { font-size: .875rem; color: var(--gray-600); }

/* ─── Utilities ─── */
.text-navy { color: var(--navy) !important; }
.text-orange { color: var(--orange) !important; }
.bg-navy { background: var(--navy) !important; }
.border-navy { border-color: var(--navy) !important; }
.fw-700 { font-weight: 700 !important; }
.fs-12 { font-size: 12px !important; }
.fs-13 { font-size: 13px !important; }
.cursor-pointer { cursor: pointer; }
