:root {
  --sidebar:#111827;
  --sidebar-active:#5b2a2f;
  --sidebar-text:#b9c3d2;
  --bg:#f5f7fa;
  --card:#fff;
  --border:#e3e8ef;
  --text:#101828;
  --muted:#667085;
  --primary:#ee4d2d;
  --primary-dark:#d74427;
  --green:#12b76a;
  --red:#d92d20;
  --blue:#2e90fa;
  --purple:#7f56d9;
  --amber:#f79009;
  --shadow:0 1px 2px rgba(16,24,40,.04);
}

*{box-sizing:border-box}
html,body{
  margin:0;
  min-height:100%;
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  color:var(--text);
  background:var(--bg);
}
body{overflow-x:hidden}
button,input,select{font:inherit}
button{-webkit-tap-highlight-color:transparent}

.sidebar{
  position:fixed;
  inset:0 auto 0 0;
  width:280px;
  display:flex;
  flex-direction:column;
  padding:28px 24px 22px;
  background:var(--sidebar);
  z-index:50;
}
.brand{
  padding:8px 18px 30px;
  border-bottom:1px solid rgba(255,255,255,.09);
}
.brand-title{
  color:#fff;
  font-size:30px;
  font-weight:800;
  letter-spacing:-.5px;
}
.brand-subtitle{
  margin-top:8px;
  color:#aab7ca;
  font-size:15px;
  line-height:1.45;
}
.nav{padding-top:28px}
.nav-item{
  width:100%;
  margin-bottom:8px;
  padding:17px 20px;
  border:0;
  border-radius:12px;
  color:var(--sidebar-text);
  background:transparent;
  text-align:left;
  font-size:17px;
  cursor:pointer;
  transition:.15s ease;
}
.nav-item:hover{color:#fff;background:rgba(255,255,255,.06)}
.nav-item.active{color:#fff;background:var(--sidebar-active)}
.sidebar-footer{
  margin-top:auto;
  padding:18px;
  border-top:1px solid rgba(255,255,255,.09);
  color:#cbd5e1;
  font-size:13px;
}
.live-dot{
  display:inline-block;
  width:9px;
  height:9px;
  border-radius:999px;
  background:var(--green);
  margin-right:7px;
}
.sidebar-backdrop{display:none}

.main{
  width:calc(100% - 280px);
  min-height:100vh;
  margin-left:280px;
}
.header{
  position:sticky;
  top:0;
  z-index:30;
  min-height:104px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:24px;
  padding:20px 30px;
  border-bottom:1px solid var(--border);
  background:rgba(255,255,255,.97);
  backdrop-filter:blur(8px);
}
.title-wrap{display:flex;align-items:center;gap:14px}
.menu-button{
  display:none;
  width:42px;
  height:42px;
  border:1px solid var(--border);
  border-radius:10px;
  background:#fff;
  cursor:pointer;
}
.page-title{
  font-size:30px;
  font-weight:800;
  line-height:1.1;
  letter-spacing:-.6px;
}
.page-context{
  margin-top:5px;
  color:var(--muted);
  font-size:12px;
}
.header-controls{
  display:flex;
  align-items:end;
  justify-content:flex-end;
  gap:12px;
  flex-wrap:wrap;
}
.control-group{
  display:flex;
  flex-direction:column;
  gap:7px;
}
.control-group>span{
  color:var(--muted);
  font-size:11px;
  font-weight:800;
  letter-spacing:.06em;
}
.control{
  height:46px;
  padding:0 12px;
  border:1px solid var(--border);
  border-radius:10px;
  outline:none;
  color:var(--text);
  background:#fff;
}
.control:focus,.search-input:focus{
  border-color:#b6c0cf;
  box-shadow:0 0 0 3px rgba(46,144,250,.08);
}
.shop-select{min-width:190px}
.date-range{
  display:flex;
  align-items:center;
  gap:10px;
}
.date-input{width:156px}
.primary-button{
  height:46px;
  padding:0 24px;
  border:0;
  border-radius:10px;
  color:#fff;
  background:var(--primary);
  font-weight:800;
  cursor:pointer;
  transition:.15s ease;
}
.primary-button:hover{background:var(--primary-dark)}

.content{padding:28px 30px 48px}
.top-status-row{
  min-height:36px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  margin-bottom:18px;
}
.status-copy{
  display:flex;
  align-items:center;
  gap:8px;
  color:var(--muted);
  font-size:13px;
  flex-wrap:wrap;
}
.updating-indicator{
  color:var(--muted);
  font-size:12px;
  opacity:0;
  transition:opacity .15s ease;
}
.updating-indicator.show{opacity:1}

.page{display:none}
.page.active{display:block}
.page-toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  margin-bottom:18px;
  flex-wrap:wrap;
}
.toolbar-copy{color:var(--muted);font-size:13px}
.toolbar-actions{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.search-input{
  width:340px;
  max-width:100%;
  height:44px;
  padding:0 14px;
  border:1px solid var(--border);
  border-radius:10px;
  outline:none;
  color:var(--text);
  background:#fff;
}
.compact{height:44px}

.notice{
  display:none;
  padding:14px 16px;
  margin-bottom:14px;
  border-radius:10px;
  font-size:13px;
  line-height:1.45;
}
.notice.show{display:block}
.notice-warning{
  color:#7a4d00;
  border:1px solid #f2d28b;
  background:#fff7e5;
}
.notice-info{
  color:#1f4e8c;
  border:1px solid #bfd8fd;
  background:#eef6ff;
}

.panel{
  padding:22px;
  border:1px solid var(--border);
  border-radius:15px;
  background:var(--card);
  box-shadow:var(--shadow);
}
.panel-title{
  margin-bottom:18px;
  font-size:18px;
  font-weight:750;
}
.table-panel{overflow:hidden}

.kpi-grid{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:15px;
  margin-bottom:22px;
}
.kpi-card{
  min-width:0;
  min-height:126px;
  padding:20px 22px;
  border:1px solid var(--border);
  border-radius:14px;
  background:#fff;
  box-shadow:var(--shadow);
}
.kpi-label{
  margin-bottom:11px;
  color:var(--muted);
  font-size:13px;
}
.kpi-value{
  margin-bottom:9px;
  overflow:hidden;
  font-size:clamp(22px,2vw,31px);
  font-weight:800;
  line-height:1.08;
  letter-spacing:-.5px;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.kpi-value.money{font-size:clamp(20px,1.75vw,28px)}
.kpi-note{
  color:var(--muted);
  font-size:12px;
  line-height:1.4;
}

.overview-grid{
  display:grid;
  grid-template-columns:minmax(0,2fr) minmax(300px,.8fr);
  gap:20px;
}
.comparison-section{display:none;margin-bottom:22px}
.comparison-section.show{display:block}
.section-heading{margin-bottom:14px}
.section-heading h2{margin:0;font-size:20px}
.section-heading p{margin:5px 0 0;color:var(--muted);font-size:13px}
.comparison-grid{
  display:grid;
  grid-template-columns:minmax(420px,.9fr) minmax(620px,1.3fr);
  gap:20px;
}
.fee-summary-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:15px;
  margin-bottom:22px;
}
.fee-grid{
  display:grid;
  grid-template-columns:minmax(360px,.8fr) minmax(560px,1.2fr);
  gap:20px;
}

.chart-wrap{position:relative;width:100%}
.chart-wrap.large{height:340px}
.chart-wrap.medium{height:300px}
.chart-wrap.pie{height:360px}

.status-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:13px 0;
  border-bottom:1px solid #edf0f4;
}
.status-row:last-child{border-bottom:0}
.status-total{font-weight:800}

.table-scroll{width:100%;overflow-x:auto}
table{
  width:100%;
  min-width:900px;
  border-collapse:collapse;
  background:#fff;
}
th{
  padding:14px 17px;
  border-bottom:1px solid var(--border);
  color:var(--muted);
  background:#fbfcfd;
  font-size:12px;
  font-weight:750;
  text-align:left;
  white-space:nowrap;
}
td{
  padding:14px 17px;
  border-bottom:1px solid #edf0f4;
  font-size:13px;
  vertical-align:middle;
}
tbody tr:last-child td{border-bottom:0}
.right{text-align:right}
.center{text-align:center}
.muted{color:var(--muted)}
.mono{font-family:"SFMono-Regular",Consolas,"Liberation Mono",monospace}
.shop-name{font-weight:700;white-space:nowrap}

.badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:5px 9px;
  border-radius:999px;
  font-size:11px;
  font-weight:800;
  white-space:nowrap;
}
.badge-green{color:#08783c;background:#dff7ea}
.badge-red{color:#b42318;background:#fee4e2}
.badge-blue{color:#175cd3;background:#eaf3ff}
.badge-purple{color:#6927da;background:#f0e8ff}
.badge-amber{color:#9a6700;background:#fff4d9}
.badge-gray{color:#475467;background:#f2f4f7}

.fee-bar{
  display:inline-block;
  width:76px;
  height:7px;
  margin-right:7px;
  overflow:hidden;
  vertical-align:middle;
  border-radius:999px;
  background:#edf0f5;
}
.fee-bar-fill{
  display:block;
  height:100%;
  border-radius:999px;
  background:var(--primary);
}
.empty{padding:26px;color:var(--muted);text-align:center}

.loading-overlay{
  display:none;
  position:fixed;
  inset:0;
  z-index:100;
  align-items:center;
  justify-content:center;
  padding:22px;
  background:rgba(255,255,255,.64);
  backdrop-filter:blur(2px);
}
.loading-overlay.show{display:flex}
.loading-card{
  display:flex;
  align-items:center;
  gap:16px;
  min-width:300px;
  max-width:92vw;
  padding:20px 22px;
  border:1px solid var(--border);
  border-radius:14px;
  background:#fff;
  box-shadow:0 18px 50px rgba(16,24,40,.12);
}
.spinner{
  width:24px;
  height:24px;
  flex:0 0 auto;
  border:3px solid #e9edf3;
  border-top-color:var(--primary);
  border-radius:50%;
  animation:spin .8s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}
.loading-title{font-size:14px;font-weight:800}
.loading-subtitle{margin-top:4px;color:var(--muted);font-size:12px}

.toast{
  position:fixed;
  right:22px;
  bottom:22px;
  z-index:120;
  max-width:420px;
  padding:14px 16px;
  border-radius:10px;
  color:#fff;
  background:#101828;
  box-shadow:0 16px 40px rgba(16,24,40,.18);
  font-size:13px;
  line-height:1.45;
  opacity:0;
  transform:translateY(12px);
  pointer-events:none;
  transition:.2s ease;
}
.toast.show{opacity:1;transform:translateY(0)}
.toast.error{background:#b42318}

@media(max-width:1280px){
  .header{align-items:flex-start;flex-direction:column}
  .header-controls{width:100%;justify-content:flex-start}
  .comparison-grid,.overview-grid,.fee-grid{grid-template-columns:1fr}
  .kpi-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:900px){
  .sidebar{
    width:270px;
    transform:translateX(-100%);
    transition:transform .2s ease;
    box-shadow:14px 0 40px rgba(16,24,40,.14);
  }
  .sidebar.open{transform:translateX(0)}
  .sidebar-backdrop{
    display:block;
    position:fixed;
    inset:0;
    z-index:45;
    background:rgba(16,24,40,.35);
    opacity:0;
    pointer-events:none;
    transition:opacity .2s ease;
  }
  .sidebar-backdrop.show{opacity:1;pointer-events:auto}
  .main{width:100%;margin-left:0}
  .menu-button{display:inline-flex;align-items:center;justify-content:center}
  .header{position:relative;min-height:auto;padding:18px}
  .page-title{font-size:25px}
  .content{padding:20px 16px 38px}
  .header-controls{display:grid;grid-template-columns:1fr 1fr}
  .control-group,.date-range{width:100%}
  .shop-select{width:100%;min-width:0}
  .date-range{grid-column:1/-1;display:grid;grid-template-columns:1fr auto 1fr}
  .date-input{width:100%}
  .primary-button{grid-column:1/-1;width:100%}
  .kpi-grid,.fee-summary-grid{grid-template-columns:1fr}
  .search-input{width:100%}
  .page-toolbar{align-items:stretch;flex-direction:column}
  .toolbar-actions{align-items:stretch;flex-direction:column}
  .compact{width:100%}
  .top-status-row{align-items:flex-start;flex-direction:column}
  .comparison-grid{display:block}
  .comparison-grid>.panel+.panel{margin-top:16px}
  .toast{right:16px;bottom:16px;left:16px;max-width:none}
}
@media(max-width:560px){
  .header-controls{grid-template-columns:1fr}
  .date-range{grid-column:auto}
  .primary-button{grid-column:auto}
  .status-copy{display:block;line-height:1.8}
}
