@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;500;700;900&family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
  --brand:      #8D7B68;
  --brand-dark: #6B5A4E;
  --brand-pale: #F2EDE8;
  --sidebar-bg: #23201D;
  --sidebar-w:  220px;
  --bg:         #F7F6F4;
  --surface:    #FFFFFF;
  --border:     #EBEBEA;
  --ink:        #1A1714;
  --ink-2:      #52504C;
  --ink-3:      #96928E;
  --ink-4:      #C5C2BE;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --radius-lg:  16px;
  --radius-md:  10px;
}

/* ── Body layout ── */
body.b2b-body {
  font-family: 'Noto Sans JP', 'Inter', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  display: flex;
}

/* ── Sidebar ── */
.b2b-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 40;
  overflow-y: auto;
}

.b2b-sidebar-logo {
  padding: 22px 18px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.b2b-logo-mark {
  width: 30px; height: 30px;
  background: var(--brand);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.b2b-client-chip {
  margin: 14px 12px 10px;
  padding: 10px 12px;
  background: rgba(255,255,255,.05);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.07);
}
.b2b-client-name {
  font-size: 12px; font-weight: 700;
  color: rgba(255,255,255,.82);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.b2b-client-type {
  font-size: 10.5px; font-weight: 500;
  color: rgba(255,255,255,.3);
  margin-top: 3px;
}

.b2b-nav-label {
  font-size: 9px; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: rgba(255,255,255,.22);
  padding: 12px 18px 6px;
}
.b2b-nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; margin: 1px 8px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: rgba(255,255,255,.48);
  text-decoration: none;
  transition: background .14s, color .14s;
  cursor: pointer; border: none; background: transparent;
  position: relative;
}
.b2b-nav-item:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.82);
}
.b2b-nav-item.active {
  background: rgba(141,123,104,.22);
  color: #fff;
  font-weight: 700;
}
.b2b-nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 5px; bottom: 5px;
  width: 2.5px; background: var(--brand);
  border-radius: 0 2px 2px 0;
}
.b2b-nav-item.disabled {
  opacity: .3; cursor: not-allowed;
  pointer-events: none;
}
.b2b-nav-badge {
  margin-left: auto;
  font-size: 10px; font-weight: 700;
  background: rgba(141,123,104,.4);
  color: rgba(255,255,255,.85);
  padding: 1px 7px; border-radius: 20px;
  min-width: 20px; text-align: center;
}
.b2b-nav-divider {
  height: 1px; background: rgba(255,255,255,.06);
  margin: 8px 16px;
}
.b2b-sidebar-bottom {
  margin-top: auto;
  padding: 8px 8px 16px;
}

/* ── Main column ── */
.b2b-main {
  margin-left: var(--sidebar-w);
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  min-height: 100dvh;
}

/* ── Top bar ── */
.b2b-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 54px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 30;
  flex-shrink: 0;
}
.b2b-page-title {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px;
}
.b2b-page-title .cur { font-weight: 700; color: var(--ink); }
.b2b-page-title .sep { color: var(--ink-4); }
.b2b-page-title .sub { color: var(--ink-3); font-size: 12px; font-weight: 500; }

/* ── Content area ── */
.b2b-content {
  padding: 24px 28px;
  display: flex; flex-direction: column;
  gap: 16px;
  flex: 1;
}

/* ── Buttons ── */
.b2b-btn-p {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand); color: #fff;
  padding: 8px 16px; border-radius: var(--radius-md);
  font-size: 12.5px; font-weight: 700;
  border: none; cursor: pointer; text-decoration: none;
  transition: background .14s; font-family: inherit;
}
.b2b-btn-p:hover { background: var(--brand-dark); }
.b2b-btn-s {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); color: var(--ink-2);
  padding: 7px 14px; border-radius: var(--radius-md);
  font-size: 12px; font-weight: 600;
  border: 1px solid var(--border); cursor: pointer;
  transition: border-color .14s, color .14s; font-family: inherit;
}
.b2b-btn-s:hover { border-color: var(--brand); color: var(--brand); }

/* ── Stat cards ── */
.b2b-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.b2b-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.b2b-stat-label {
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  margin-bottom: 8px;
}
.b2b-stat-num {
  font-family: 'Inter', sans-serif;
  font-size: 32px; font-weight: 800;
  color: var(--ink); line-height: 1;
  margin-bottom: 6px;
}
.b2b-stat-sub { font-size: 11px; font-weight: 500; color: var(--ink-3); }

/* ── Table card ── */
.b2b-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.b2b-card-head {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  flex-wrap: wrap; gap: 10px;
}

/* ── Tabs ── */
.b2b-tab-bar {
  display: flex; gap: 2px;
  background: var(--bg);
  border-radius: 10px; padding: 3px;
  overflow-x: auto;
}
.b2b-tab {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 13px; border-radius: 8px;
  font-size: 12px; font-weight: 600;
  color: var(--ink-3);
  white-space: nowrap;
  border: none; background: none; cursor: pointer;
  transition: all .14s; text-decoration: none;
  font-family: inherit;
}
.b2b-tab:hover { color: var(--ink-2); background: rgba(255,255,255,.7); }
.b2b-tab.active {
  background: var(--surface); color: var(--ink); font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.b2b-tab-count {
  font-size: 10px; font-weight: 700;
  padding: 2px 6px; border-radius: 5px;
  min-width: 18px; text-align: center;
  background: var(--border); color: var(--ink-3);
}
.b2b-tab.active .b2b-tab-count { background: var(--brand); color: #fff; }

/* ── Filter inputs ── */
.b2b-filter-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 11px;
  font-size: 12.5px; font-weight: 500;
  color: var(--ink); outline: none;
  transition: border-color .14s, background .14s;
  font-family: inherit;
}
.b2b-filter-input:focus { background: #fff; border-color: var(--brand); }
.b2b-filter-input::placeholder { color: var(--ink-4); }

/* ── Data table ── */
.b2b-table { width: 100%; border-collapse: collapse; }
.b2b-table thead th {
  padding: 10px 16px;
  font-size: 10px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-4); background: var(--bg);
  border-bottom: 1px solid var(--border);
  text-align: left; white-space: nowrap;
}
.b2b-table thead th:first-child { padding-left: 20px; }
.b2b-table thead th:last-child  { padding-right: 20px; }
.b2b-table tbody tr { transition: background .1s; }
.b2b-table tbody tr:hover { background: #FAFAF9; }
.b2b-table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid #F4F3F1;
  vertical-align: middle;
}
.b2b-table tbody td:first-child { padding-left: 20px; }
.b2b-table tbody td:last-child  { padding-right: 20px; }
.b2b-table tbody tr:last-child td { border-bottom: none; }

/* ── Badge ── */
.b2b-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.b2b-badge-dot { width: 5px; height: 5px; border-radius: 50%; flex-shrink: 0; }
.b2b-badge-wait    { background: #FFFBEB; color: #B45309; }
.b2b-badge-done    { background: #DBEAFE; color: #1D4ED8; }
.b2b-badge-deliv   { background: #D1FAE5; color: #065F46; }
.b2b-badge-check   { background: #EDE9FE; color: #6D28D9; }
.b2b-badge-cancel  { background: #F3F4F6; color: var(--ink-3); }

/* ── Invoice button ── */
.b2b-inv-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 11px; border-radius: 7px;
  font-size: 11px; font-weight: 700;
  border: 1px solid rgba(141,123,104,.35);
  color: var(--brand); background: none;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: all .14s; font-family: inherit;
}
.b2b-inv-btn:hover { background: var(--brand); color: #fff; border-color: transparent; }
.b2b-inv-btn.muted {
  border-color: var(--border); color: var(--ink-3);
}
.b2b-inv-btn.muted:hover { background: var(--ink); color: #fff; border-color: transparent; }
.b2b-inv-btn.disabled {
  border-color: var(--border); color: var(--ink-4);
  pointer-events: none;
}

/* ── Pagination ── */
.b2b-pager {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  display: flex; align-items: center; justify-content: space-between;
}
.b2b-pager-info {
  font-size: 11px; font-weight: 500; color: var(--ink-3);
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .b2b-sidebar { display: none; }
  .b2b-main { margin-left: 0; padding-bottom: 64px; }
  .b2b-content { padding: 14px; }
  .b2b-stats-row { grid-template-columns: repeat(2, 1fr); }
  .b2b-hide-sm { display: none !important; }
  .b2b-topbar { padding: 0 16px; }
}

/* ── PDF attachment button ── */
.b2b-pdf-btn {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 9px; border-radius: 7px;
  font-size: 11px; font-weight: 700;
  white-space: nowrap; transition: all .14s; font-family: inherit;
  cursor: pointer; text-decoration: none;
}
.b2b-pdf-btn.no-pdf {
  border: 1.5px dashed #D97706; color: #D97706; background: #FFFBEB;
}
.b2b-pdf-btn.no-pdf:hover { background: #D97706; color: #fff; border-style: solid; }
.b2b-pdf-btn.has-pdf {
  border: 1.5px solid #059669; color: #059669; background: #ECFDF5;
}
.b2b-pdf-btn.has-pdf:hover { background: #059669; color: #fff; }
.b2b-pdf-reup {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px;
  border: 1px solid var(--border); color: var(--ink-3); background: white;
  font-size: 10px; cursor: pointer; transition: all .14s;
}
.b2b-pdf-reup:hover { border-color: var(--brand); color: var(--brand); }

/* ── Action layout ── */
.b2b-act-group {
  display: flex; flex-direction: column; align-items: flex-end; gap: 5px;
}
.b2b-act-row {
  display: flex; gap: 3px; align-items: center; justify-content: flex-end;
}

/* 詳細 / 変更 / × の共通高さ = 26px */
.b2b-btn-detail {
  height: 26px; padding: 0 9px;
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 700; color: var(--ink-2);
  background: var(--bg); border: 1px solid var(--border); border-radius: 7px;
  cursor: pointer; transition: all .14s; font-family: inherit; white-space: nowrap;
}
.b2b-btn-detail:hover { border-color: var(--brand); color: var(--brand); background: white; }

/* 日時変更（コンパクト） */
.b2b-btn-reschedule {
  height: 26px; padding: 0 9px;
  display: inline-flex; align-items: center;
  font-size: 10px; font-weight: 700; color: var(--brand);
  background: none; border: 1px solid rgba(141,123,104,.4); border-radius: 7px;
  cursor: pointer; transition: all .14s; font-family: inherit; white-space: nowrap;
}
.b2b-btn-reschedule:hover { background: var(--brand-pale); border-color: var(--brand); }

/* キャンセル（正方形アイコン） */
.b2b-btn-cancel {
  height: 26px; width: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 900; line-height: 1; color: #DC2626;
  background: none; border: 1px solid #FECACA; border-radius: 7px;
  cursor: pointer; transition: all .14s; font-family: inherit;
}
.b2b-btn-cancel:hover { background: #FEF2F2; border-color: #FCA5A5; }

/* ── Mobile bottom nav ── */
.b2b-mob-nav {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom);
}
@media (max-width: 768px) { .b2b-mob-nav { display: flex; } }
.b2b-mob-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 9px 0; gap: 3px; font-size: 10px; font-weight: 600;
  color: var(--ink-3); text-decoration: none; font-family: inherit;
}
.b2b-mob-nav a.active { color: var(--brand); }
