/* Bestway USA - Domestic Business Dashboard
   Styles carried over from the approved mockups (overview + details views). */

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #F5F6FA;
  color: #1F2937;
  min-height: 100vh;
  display: flex;
}

/* ============ SIDEBAR ============ */
.sidebar {
  width: 240px;
  background: #0F1E3D;
  color: #E5E7EB;
  padding: 22px 18px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  max-height: 100vh;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: #2A3A5C; border-radius: 3px; }

.back-btn {
  display: block;
  width: 100%;
  background: #2563EB;
  color: white;
  border: none;
  padding: 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 18px;
  text-decoration: none;
  text-align: center;
  transition: background 0.2s;
}
.back-btn:hover { background: #1D4ED8; }

.sidebar h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #FFFFFF;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid #2A3A5C;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #A8B2C7;
  margin-bottom: 6px;
  margin-top: 14px;
  letter-spacing: 0.3px;
}
.sidebar label.hero { color: #FBBF24; font-size: 11.5px; margin-top: 0; }
.sidebar select {
  width: 100%;
  background: #1B2A4E;
  color: #FFFFFF;
  border: 1px solid #2A3A5C;
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 12px;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}
.sidebar select:hover, .sidebar select:focus { border-color: #4A6BAF; }
.sidebar select.hero { background: #1E40AF; border-color: #FBBF24; font-weight: 600; }

.quick-date { margin-top: 22px; padding-top: 18px; border-top: 1px solid #2A3A5C; }
.quick-date h3 {
  font-size: 11px; font-weight: 700; letter-spacing: 1px;
  color: #FFFFFF; margin-bottom: 12px;
}
.date-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.date-btn {
  background: #1B2A4E;
  color: #E5E7EB;
  border: 1px solid #2A3A5C;
  border-radius: 6px;
  padding: 8px 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.date-btn:hover { background: #2A3A5C; }
.date-btn.active { background: #2563EB; border-color: #2563EB; color: white; }

.refresh-info {
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid #2A3A5C;
  font-size: 10.5px;
  color: #A8B2C7;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.refresh-info .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #22C55E; margin-top: 4px;
  box-shadow: 0 0 6px #22C55E;
  animation: pulse 2s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.sidebar-account {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #2A3A5C;
  font-size: 11px;
  color: #A8B2C7;
}
.sidebar-account .who { color: #FFFFFF; font-weight: 600; margin-bottom: 8px; }
.sidebar-account button {
  width: 100%;
  background: transparent;
  color: #E5E7EB;
  border: 1px solid #2A3A5C;
  border-radius: 6px;
  padding: 7px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.sidebar-account button:hover { background: #2A3A5C; }

/* ============ MAIN ============ */
.main { flex: 1; padding: 20px 26px; overflow-x: hidden; }

.top-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.top-header.tight { margin-bottom: 12px; }
.header-left { display: flex; align-items: center; gap: 16px; }
.header-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, #2563EB, #1E40AF);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 24px;
}
.header-title { font-size: 24px; font-weight: 700; color: #0F1E3D; }
.header-sub { font-size: 13px; color: #6B7280; margin-top: 2px; }
.header-mid { text-align: right; font-size: 12px; color: #4B5563; }
.header-mid .date { font-weight: 600; color: #0F1E3D; }
.header-mid .refresh { color: #6B7280; font-style: italic; margin-top: 2px; }

.tabs { display: flex; background: #F3F4F6; border-radius: 8px; padding: 3px; }
.tab {
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: #4B5563;
  cursor: pointer;
  transition: all 0.2s;
  display: flex; align-items: center; gap: 6px;
  border: none;
  background: transparent;
  text-decoration: none;
}
.tab.active {
  background: #2563EB;
  color: white;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  font-size: 26px; font-weight: 900;
  color: #C01A2E; letter-spacing: -0.5px; line-height: 1;
}
.brand-sub { font-size: 12px; font-weight: 700; color: #C01A2E; letter-spacing: 3px; }

.export-btn {
  background: #0F1E3D;
  color: white;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  text-decoration: none;
}
.export-btn:hover { background: #1E293B; }

/* ---- Mock-data notice ---- */
.data-notice {
  background: #FEF3C7;
  border: 1px solid #FCD34D;
  color: #92400E;
  border-radius: 8px;
  padding: 9px 16px;
  margin-bottom: 14px;
  font-size: 11.5px;
  font-weight: 600;
}

/* ---- Breadcrumb ---- */
.breadcrumb {
  background: white;
  border-radius: 8px;
  padding: 10px 18px;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  font-size: 12.5px;
  color: #6B7280;
  display: flex;
  align-items: center;
  gap: 8px;
}
.breadcrumb a { color: #2563EB; text-decoration: none; font-weight: 600; cursor: pointer; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb .sep { color: #D1D5DB; }
.breadcrumb .current { color: #0F1E3D; font-weight: 700; }

/* ---- Customer context banner ---- */
.context-banner {
  background: linear-gradient(90deg, #1E40AF, #2563EB);
  color: white;
  padding: 14px 22px;
  border-radius: 10px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 3px 8px rgba(37,99,235,0.15);
}
.context-banner .cust-name { font-size: 20px; font-weight: 800; letter-spacing: -0.3px; }
.context-banner .cust-sub { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.context-banner .cust-tag {
  background: rgba(255,255,255,0.18);
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 11.5px;
  font-weight: 600;
}

/* ---- KPI cards ---- */
.kpi-row { display: grid; gap: 14px; margin-bottom: 18px; }
.kpi-row.five { grid-template-columns: repeat(5, 1fr); }
.kpi-row.four { grid-template-columns: repeat(4, 1fr); }
.kpi-card {
  background: white;
  border-radius: 12px;
  padding: 16px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0,0,0,0.08); }
.kpi-head { display: flex; align-items: center; gap: 10px; }
.kpi-icon {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 17px;
  flex-shrink: 0;
}
.kpi-icon.g { background: #16A34A; }
.kpi-icon.b { background: #2563EB; }
.kpi-icon.p { background: #7C3AED; }
.kpi-icon.y { background: #F59E0B; }
.kpi-icon.t { background: #0D9488; }
.kpi-title { font-size: 11.5px; font-weight: 700; color: #374151; letter-spacing: 0.3px; }
.kpi-title small {
  display: block; font-weight: 500; color: #6B7280;
  margin-top: 2px; font-size: 10px; letter-spacing: 0;
}
.kpi-values { display: flex; gap: 14px; }
.kpi-values.single { justify-content: center; }
.kpi-block { flex: 1; }
.kpi-block-lbl { font-size: 10px; color: #6B7280; font-weight: 600; }
.kpi-block-val {
  font-size: 22px; font-weight: 800; color: #0F1E3D;
  margin-top: 2px; letter-spacing: -0.5px;
}
.kpi-values.single .kpi-block { text-align: center; }
.kpi-var { display: flex; gap: 14px; font-size: 11px; color: #6B7280; }
.kpi-var .v { flex: 1; }
.kpi-var.single .v { flex: none; text-align: center; width: 100%; }
.kpi-var strong { font-weight: 700; }
.up { color: #16A34A; }
.down { color: #DC2626; }
.kpi-row.four .kpi-block-val { font-size: 24px; }
.kpi-row.four .kpi-var .up, .kpi-row.four .kpi-var .down { font-weight: 700; }

/* ---- Panels + charts ---- */
.chart-row { display: grid; gap: 14px; margin-bottom: 18px; }
.chart-row.three { grid-template-columns: 1.15fr 1fr 1.1fr; }
.chart-row.two { grid-template-columns: 1.5fr 1fr; }
.panel {
  background: white;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.panel-title {
  font-size: 13px; font-weight: 700;
  color: #0F1E3D;
  margin-bottom: 12px;
  letter-spacing: 0.2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.panel-title small { font-size: 11px; color: #6B7280; font-weight: 500; letter-spacing: 0; }
.chart-container { position: relative; height: 235px; }
.chart-container.tall { height: 260px; }

.donut-wrap { display: flex; align-items: center; gap: 12px; height: 235px; }
.donut-canvas-wrap { position: relative; width: 165px; height: 165px; flex-shrink: 0; }
.donut-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}
.donut-center .val { font-size: 18px; font-weight: 800; color: #0F1E3D; }
.donut-center .lbl { font-size: 10px; color: #6B7280; font-weight: 600; }
.donut-legend { flex: 1; font-size: 11px; }
.legend-item { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 3px; flex-shrink: 0; }
.legend-txt { line-height: 1.35; }
.legend-txt .lbl-name { font-weight: 600; color: #374151; font-size: 10.5px; }
.legend-txt .lbl-val { color: #0F1E3D; font-weight: 700; font-size: 11px; }

/* ---- Funnel ---- */
.funnel-container { padding: 8px 0; }
.funnel-stage {
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: 8px;
  color: white;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}
.funnel-stage .stage-name { display: flex; align-items: center; gap: 8px; }
.funnel-stage .stage-val { font-weight: 800; font-size: 15px; }
.funnel-stage .pct { font-size: 10.5px; opacity: 0.85; margin-left: 6px; }
.funnel-summary {
  margin-top: 12px; padding: 8px 12px;
  background: #F3F4F6; border-radius: 6px;
  font-size: 11px; color: #4B5563; text-align: center;
}

/* ---- Tables ---- */
.table-row { display: grid; grid-template-columns: 1.3fr 1fr 1.35fr; gap: 14px; }
.sku-panel { margin-bottom: 18px; }
.table-controls {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 10px; gap: 12px;
}
.search-input {
  flex: 1;
  max-width: 280px;
  padding: 8px 12px;
  border: 1px solid #E5E7EB;
  border-radius: 6px;
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}
.search-input:focus { border-color: #2563EB; }
.table-count { font-size: 11.5px; color: #6B7280; font-weight: 600; }

.data-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.data-table th {
  text-align: left;
  padding: 8px 6px;
  font-weight: 700;
  color: #6B7280;
  border-bottom: 2px solid #E5E7EB;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.data-table th.num { text-align: right; }
.data-table td {
  padding: 7px 6px;
  color: #1F2937;
  border-bottom: 1px solid #F3F4F6;
  font-size: 11.5px;
}
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tr:hover td { background: #F9FAFB; }
.data-table tr.clickable { cursor: pointer; }
.data-table tr.total-row td {
  font-weight: 700;
  color: #0F1E3D;
  border-top: 2px solid #E5E7EB;
  border-bottom: none;
  padding-top: 10px;
}
.row-num { color: #9CA3AF; width: 22px; }

.data-table.sortable th {
  cursor: pointer;
  user-select: none;
  background: #FAFBFC;
  position: sticky; top: 0;
  padding: 9px 8px;
}
.data-table.sortable th:hover { color: #2563EB; }
.data-table.sortable th .sort-indicator {
  display: inline-block; margin-left: 4px; opacity: 0.4;
}
.data-table.sortable th.sorted .sort-indicator { opacity: 1; color: #2563EB; }
.data-table.sortable td { padding: 8px 8px; }
.data-table.sortable tr.total-row td { background: #F8FAFC; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge-paid     { background: #DCFCE7; color: #166534; }
.badge-shipped  { background: #DBEAFE; color: #1E40AF; }
.badge-invoiced { background: #EDE9FE; color: #6D28D9; }
.badge-warehouse{ background: #FEF3C7; color: #92400E; }
.badge-received { background: #E5E7EB; color: #4B5563; }
.badge-partial  { background: #FED7AA; color: #C2410C; }
.badge-open     { background: #E0E7FF; color: #3730A3; }
.badge-notinv   { background: #F3F4F6; color: #6B7280; }
.badge-ontrack  { background: #DCFCE7; color: #166534; }
.badge-past30   { background: #FEF3C7; color: #92400E; }
.badge-past60   { background: #FED7AA; color: #C2410C; }
.badge-pastdue  { background: #FEE2E2; color: #991B1B; }
.badge-na       { background: #F3F4F6; color: #9CA3AF; }

/* ---- PO timeline ---- */
.bottom-row { display: grid; grid-template-columns: 1.2fr 1fr; gap: 14px; }
.po-list { display: flex; flex-direction: column; gap: 8px; max-height: 380px; overflow-y: auto; }
.po-item {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #E5E7EB;
  background: #FAFBFC;
  font-size: 11.5px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  width: 100%;
  font-family: inherit;
}
.po-item:hover {
  background: white;
  border-color: #2563EB;
  box-shadow: 0 2px 6px rgba(37,99,235,0.1);
}
.po-num { font-weight: 700; color: #0F1E3D; }
.po-lbl { font-size: 9.5px; color: #6B7280; text-transform: uppercase; letter-spacing: 0.3px; }
.po-val { color: #374151; font-weight: 600; }
.po-val.amt { color: #0F1E3D; font-weight: 800; text-align: right; }

/* ---- Toast ---- */
.toast {
  position: fixed;
  top: 20px; right: 20px;
  background: #0F1E3D;
  color: white;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  display: flex; align-items: center; gap: 10px;
  transform: translateX(120%);
  transition: transform 0.3s ease;
  z-index: 1000;
}
.toast.show { transform: translateX(0); }
.toast .check { color: #22C55E; font-weight: 700; }

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 30, 61, 0.6);
  display: none;
  align-items: center; justify-content: center;
  z-index: 999;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: white;
  border-radius: 12px;
  padding: 26px;
  width: 90%; max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
  animation: modalIn 0.25s ease;
}
@keyframes modalIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal h3 { font-size: 18px; color: #0F1E3D; margin-bottom: 6px; }
.modal .sub { font-size: 12px; color: #6B7280; margin-bottom: 18px; }
.modal .close-btn {
  background: #0F1E3D; color: white;
  border: none; padding: 9px 20px;
  border-radius: 6px; font-size: 12.5px;
  cursor: pointer; margin-top: 16px;
  font-weight: 600;
}
.modal .close-btn:hover { background: #1E293B; }
.modal .note {
  margin-top: 12px; padding: 10px;
  background: #F0F9FF; border-left: 3px solid #2563EB;
  border-radius: 4px; font-size: 12px;
}

.footer-note { text-align: center; color: #9CA3AF; font-size: 11px; padding: 20px 0 10px; }

/* ============ LOGIN ============ */
body.login-page { display: flex; align-items: center; justify-content: center; background: #0F1E3D; }
.login-card {
  background: white;
  border-radius: 14px;
  padding: 34px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.login-card .brand-logo { font-size: 30px; }
.login-card .brand-sub { margin-bottom: 6px; }
.login-card h1 { font-size: 17px; color: #0F1E3D; margin: 18px 0 4px; }
.login-card p.sub { font-size: 12.5px; color: #6B7280; margin-bottom: 22px; }
.login-card label {
  display: block; font-size: 11.5px; font-weight: 700;
  color: #374151; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.3px;
}
.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #E5E7EB;
  border-radius: 7px;
  font-size: 13.5px;
  margin-bottom: 16px;
  outline: none;
  font-family: inherit;
}
.login-card input:focus { border-color: #2563EB; }
.login-card button {
  width: 100%;
  background: #2563EB;
  color: white;
  border: none;
  padding: 11px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}
.login-card button:hover { background: #1D4ED8; }
.login-error {
  background: #FEE2E2; color: #991B1B;
  border-radius: 7px; padding: 10px 12px;
  font-size: 12.5px; margin-bottom: 16px; font-weight: 600;
}
.login-foot { text-align: center; font-size: 10.5px; color: #9CA3AF; margin-top: 18px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 1400px) {
  .kpi-row.five { grid-template-columns: repeat(3, 1fr); }
  .kpi-row.four { grid-template-columns: repeat(2, 1fr); }
  .chart-row.three, .chart-row.two, .table-row, .bottom-row { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  body { flex-direction: column; }
  .sidebar { width: 100%; position: relative; min-height: auto; max-height: none; }
  .kpi-row.five, .kpi-row.four { grid-template-columns: 1fr 1fr; }
  .top-header { flex-wrap: wrap; gap: 12px; }
  .po-item { grid-template-columns: 1fr 1fr; }
}

/* ============ MICROSOFT SIGN-IN ============ */
.ms-btn{
  display:flex;align-items:center;justify-content:center;gap:10px;
  width:100%;background:#2F2F2F;color:#fff;
  border:1px solid #2F2F2F;border-radius:7px;
  padding:12px;font-size:13.5px;font-weight:600;
  cursor:pointer;text-decoration:none;transition:background .15s;
}
.ms-btn:hover{background:#1f1f1f}
.ms-btn svg{flex-shrink:0}
.ms-note{font-size:11.5px;color:#6B7280;margin-top:12px;line-height:1.5}
.or-rule{
  display:flex;align-items:center;gap:10px;
  margin:20px 0 16px;color:#9CA3AF;font-size:11px;
  text-transform:uppercase;letter-spacing:.5px
}
.or-rule::before,.or-rule::after{
  content:"";flex:1;height:1px;background:#E5E7EB
}

/* small inline table buttons */
.mini-btn{
  background:#F3F4F6;color:#374151;border:1px solid #E5E7EB;
  border-radius:5px;padding:4px 10px;font-size:11px;font-weight:600;
  cursor:pointer;font-family:inherit;margin-left:4px
}
.mini-btn:hover{background:#E5E7EB}
.mini-btn.danger{background:#FEE2E2;color:#991B1B;border-color:#FECACA}
.mini-btn.danger:hover{background:#FECACA}

/* ============ STANDALONE ADMIN PAGES (no filter sidebar) ============ */
body.plain-page { display:block; background:#F5F6FA; padding:20px 26px; }
.scroll-x { overflow-x:auto; }
.data-notice.good { background:#DCFCE7; border-color:#86EFAC; color:#166534; }
.data-notice.bad  { background:#FEE2E2; border-color:#FCA5A5; color:#991B1B; }
.data-notice.info { background:#DBEAFE; border-color:#93C5FD; color:#1E40AF; }

/* Microsoft button in its not-yet-configured state */
.ms-btn[disabled]{
  background:#4a4a4a;border-color:#4a4a4a;
  opacity:.6;cursor:not-allowed;font-family:inherit;
}
.ms-btn[disabled]:hover{background:#4a4a4a}
.ms-note.pending{
  background:#FEF3C7;border:1px solid #FCD34D;color:#92400E;
  border-radius:6px;padding:9px 12px;margin-top:12px;font-weight:500;
}
.ms-note.pending strong{color:#78350F}
