/* ============================================
   INMAN Digital Retail Dashboard
   Apple-inspired minimal design
   Full responsive: Mobile / Tablet / Desktop
   ============================================ */

:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --sidebar-bg: #fafafa;
  --text: #1d1d1f;
  --text2: #6e6e73;
  --text3: #aeaeb2;
  --border: #e5e5ea;
  --accent: #e60044;
  --accent-dim: rgba(230,0,68,0.08);
  --green: #34c759;
  --green-dim: rgba(52,199,89,0.1);
  --orange: #ff9500;
  --orange-dim: rgba(255,149,0,0.1);
  --red: #ff3b30;
  --red-dim: rgba(255,59,48,0.1);
  --shadow: 0 1px 3px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --font: -apple-system,BlinkMacSystemFont,"SF Pro Display","PingFang SC","Microsoft YaHei",sans-serif;
  --mono: "SF Mono","Menlo",monospace;
  --t: 0.25s cubic-bezier(0.25, 0.1, 0.25, 1);
  --sidebar-w: 220px;
  --sidebar-collapsed: 60px;
  --fs-xs: clamp(11px,1.8vw,12px);
  --fs-sm: clamp(12px,2vw,14px);
  --fs-base: clamp(13px,2.2vw,15px);
  --fs-h3: clamp(14px,2.4vw,16px);
  --fs-h2: clamp(16px,3vw,20px);
  --fs-h1: clamp(22px,5vw,34px);
}

*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
html{-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}
body{
  font-family:var(--font);background:var(--bg);color:var(--text);
  line-height:1.5;-webkit-font-smoothing:antialiased;
  display:flex;min-height:100dvh;overflow-x:hidden;
}

/* === SIDEBAR === */
.sidebar{
  width:var(--sidebar-w);background:var(--sidebar-bg);
  border-right:1px solid var(--border);
  display:flex;flex-direction:column;flex-shrink:0;
  position:sticky;top:0;height:100dvh;z-index:50;
  transition:width var(--t);
  overflow:hidden;
}
.sidebar.collapsed{width:var(--sidebar-collapsed);}
.sidebar.collapsed .nav-text,
.sidebar.collapsed .sidebar-label{opacity:0;pointer-events:none;}
.sidebar.collapsed .brand-logo text{font-size:16px;}
.sidebar-brand{
  display:flex;align-items:center;justify-content:space-between;
  padding:16px;height:56px;border-bottom:1px solid var(--border);
}
.brand-logo{width:100px;height:24px;color:var(--text);flex-shrink:0;}
.sidebar-toggle{
  background:none;border:none;cursor:pointer;color:var(--text3);
  padding:4px;border-radius:6px;display:flex;align-items:center;
  transition:all var(--t);min-width:32px;min-height:32px;
}
.sidebar-toggle:hover{color:var(--text);background:var(--border);}
.sidebar-label{
  font-size:10px;font-weight:700;text-transform:uppercase;
  color:var(--text3);letter-spacing:1.2px;
  padding:20px 16px 8px;transition:opacity var(--t);white-space:nowrap;
}
.nav-item{
  display:flex;align-items:center;gap:10px;
  padding:10px 14px;margin:2px 8px;
  border-radius:8px;font-size:var(--fs-sm);font-weight:500;
  color:var(--text2);cursor:pointer;
  border:none;background:transparent;text-align:left;
  transition:all var(--t);white-space:nowrap;min-height:40px;
}
.nav-item:hover{background:rgba(0,0,0,0.04);color:var(--text);}
.nav-item.active{background:var(--accent-dim);color:var(--accent);font-weight:600;}
.nav-icon{width:18px;height:18px;flex-shrink:0;}
.nav-text{transition:opacity var(--t);}

/* === MAIN === */
.main-wrap{flex:1;display:flex;flex-direction:column;min-width:0;}
.topbar{
  display:flex;align-items:center;justify-content:space-between;
  padding:0 20px;height:52px;background:var(--card);
  border-bottom:1px solid var(--border);position:sticky;top:0;z-index:40;
  gap:12px;
}
.topbar-left{display:flex;align-items:center;gap:10px;min-width:0;}
.menu-btn{
  display:none;background:none;border:none;cursor:pointer;
  color:var(--text2);padding:4px;border-radius:6px;min-width:36px;min-height:36px;
  align-items:center;justify-content:center;
}
.menu-btn:hover{color:var(--text);background:var(--border);}
.topbar-title{font-size:var(--fs-sm);font-weight:600;white-space:nowrap;}
.topbar-dot{width:6px;height:6px;border-radius:50%;background:var(--green);flex-shrink:0;}
.topbar-update{font-size:var(--fs-xs);color:var(--text3);white-space:nowrap;}
.topbar-right{display:flex;gap:8px;align-items:center;flex-shrink:0;}
.topbar-link{
  font-size:var(--fs-xs);color:var(--accent);text-decoration:none;
  padding:5px 12px;border:1px solid var(--accent);
  border-radius:20px;font-weight:500;white-space:nowrap;
  transition:all var(--t);
}
.topbar-link:hover{background:var(--accent);color:#fff;}

/* === CONTENT === */
.content{padding:clamp(12px,2vw,24px);flex:1;overflow-y:auto;overflow-x:hidden;}

/* === FILTERS === */
.filter-bar{margin-bottom:16px;}
.filter-row{
  display:flex;align-items:flex-end;gap:10px;flex-wrap:wrap;
}
.filter-select-wrap{display:flex;flex-direction:column;gap:3px;}
.filter-select-label{font-size:10px;font-weight:600;text-transform:uppercase;color:var(--text3);letter-spacing:0.5px;}
.filter-select{
  padding:7px 28px 7px 12px;border:1px solid var(--border);border-radius:8px;
  font-size:var(--fs-sm);font-family:var(--font);color:var(--text);
  background:var(--card);cursor:pointer;appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' stroke='%236e6e73' stroke-width='1.5'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right 10px center;
  min-height:36px;transition:border var(--t);
}
.filter-select:focus{outline:none;border-color:var(--accent);}
.filter-date{
  padding:7px 10px;border:1px solid var(--border);border-radius:8px;
  font-size:var(--fs-xs);font-family:var(--font);color:var(--text);
  background:var(--card);min-height:36px;
}
.filter-custom-btn{
  display:flex;align-items:center;gap:5px;padding:7px 14px;
  border:1px dashed var(--border);border-radius:8px;
  font-size:var(--fs-xs);color:var(--text2);background:transparent;
  cursor:pointer;min-height:36px;transition:all var(--t);
}
.filter-custom-btn:hover{border-color:var(--accent);color:var(--accent);}
/* Quick date presets */
.filter-preset{
  padding:6px 12px;border:1px solid var(--border);border-radius:8px;
  font-size:var(--fs-xs);font-weight:500;color:var(--text2);background:var(--card);
  cursor:pointer;min-height:36px;transition:all var(--t);white-space:nowrap;
}
.filter-preset:hover{background:var(--accent-dim);border-color:var(--accent);color:var(--accent);}
.filter-preset:active{background:var(--accent);color:#fff;}

/* === KPI ROW === */
.kpi-row{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(clamp(130px,30vw,180px),1fr));
  gap:clamp(8px,1.5vw,12px);margin-bottom:16px;
}
.kpi-card{
  background:var(--card);border-radius:var(--radius-sm);
  padding:clamp(10px,2vw,16px);border:1px solid var(--border);
  transition:all var(--t);cursor:default;
}
.kpi-card:active{transform:scale(0.98);}
.kpi-card .kpi-lbl{font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:0.5px;color:var(--text3);margin-bottom:2px;}
.kpi-card .kpi-val{font-size:var(--fs-h1);font-weight:700;letter-spacing:-0.02em;line-height:1.15;}
.kpi-card .kpi-sub{font-size:var(--fs-xs);color:var(--text2);margin-top:4px;display:flex;align-items:center;gap:6px;flex-wrap:wrap;}
.tag{font-size:10px;font-weight:600;padding:2px 7px;border-radius:10px;}
.tag-up{background:var(--green-dim);color:var(--green);}
.tag-down{background:var(--red-dim);color:var(--red);}
.tag-warn{background:var(--orange-dim);color:var(--orange);}

/* === PANELS === */
.chart-row{display:grid;grid-template-columns:1fr;gap:clamp(8px,1.5vw,12px);margin-bottom:12px;}
.panel{
  background:var(--card);border-radius:var(--radius);
  border:1px solid var(--border);overflow:hidden;
  transition:all var(--t);
}
.panel-wide{grid-column:1/-1;}
.panel-hd{
  display:flex;justify-content:space-between;align-items:center;
  padding:14px 16px;border-bottom:1px solid var(--border);gap:8px;flex-wrap:wrap;
}
.panel-title{font-size:var(--fs-h3);font-weight:600;}
.panel-sub{font-size:var(--fs-xs);color:var(--text3);}
.panel-body{padding:12px;}
.panel-table .panel-body{padding:0;}
.chart-box{width:100%;height:clamp(220px,35vh,320px);}
.chart-box.tall{height:clamp(260px,45vh,400px);}

/* === TABLES === */
.panel-table{border-radius:var(--radius);overflow:hidden;}
.tbl-scroll{overflow-x:auto;-webkit-overflow-scrolling:touch;}
table{width:100%;border-collapse:collapse;font-size:var(--fs-sm);min-width:700px;}
thead th{
  background:var(--sidebar-bg);padding:10px 12px;text-align:left;
  font-weight:600;font-size:10px;text-transform:uppercase;letter-spacing:0.5px;
  color:var(--text3);border-bottom:1px solid var(--border);white-space:nowrap;
  position:sticky;top:0;z-index:1;
}
thead th.r,tbody td.r{text-align:right;font-variant-numeric:tabular-nums;}
tbody td{padding:10px 12px;border-bottom:1px solid var(--border);white-space:nowrap;}
tbody tr:hover{background:rgba(0,0,0,0.015);}
.td-name{font-weight:600;}
/* Sticky first column */
.sticky-col{position:sticky;left:0;background:var(--card);z-index:2;box-shadow:2px 0 4px rgba(0,0,0,0.03);}
thead .sticky-col{z-index:3;background:var(--sidebar-bg);}
tbody tr:hover .sticky-col{background:rgba(0,0,0,0.015);}
.td-badge{display:inline-block;padding:2px 8px;border-radius:10px;font-size:10px;font-weight:600;color:#fff;}
.td-bar{display:flex;align-items:center;gap:6px;min-width:90px;}
.td-bar-inner{flex:1;height:5px;background:var(--border);border-radius:3px;overflow:hidden;}
.td-bar-fill{height:100%;border-radius:3px;transition:width 0.4s ease;}
.td-bar-fill.good{background:var(--green);}
.td-bar-fill.warn{background:var(--orange);}
.td-bar-fill.bad{background:var(--red);}
.td-bar-pct{font-size:11px;font-weight:600;color:var(--text2);min-width:38px;text-align:right;}

/* === STORE CARDS === */
.store-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(clamp(260px,40vw,320px),1fr));
  gap:clamp(8px,1.5vw,12px);margin-bottom:12px;
}
.store-card{
  background:var(--card);border-radius:var(--radius);
  padding:clamp(12px,2vw,18px);border:1px solid var(--border);
  transition:all var(--t);cursor:pointer;
}
.store-card:active{transform:scale(0.98);}
.store-card-hd{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;}
.store-card-name{font-size:var(--fs-base);font-weight:600;}
.store-card-ch{font-size:10px;font-weight:600;padding:2px 8px;border-radius:8px;color:#fff;}
.store-card-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px;}
.store-card-metric{display:flex;flex-direction:column;}
.scm-lbl{font-size:10px;font-weight:600;text-transform:uppercase;letter-spacing:0.5px;color:var(--text3);margin-bottom:2px;}
.scm-val{font-size:clamp(15px,2.5vw,18px);font-weight:700;}

/* === CHANNEL SECTIONS === */
.ch-section{margin-bottom:20px;}
.ch-sec-hd{display:flex;align-items:center;gap:8px;margin-bottom:10px;}
.ch-sec-dot{width:8px;height:8px;border-radius:50%;flex-shrink:0;}
.ch-sec-name{font-size:var(--fs-h3);font-weight:700;}
.ch-sec-sub{font-size:var(--fs-xs);color:var(--text3);}

/* === MOBILE BOTTOM NAV === */
.mob-nav{display:none;position:fixed;bottom:0;left:0;right:0;z-index:60;background:var(--card);border-top:1px solid var(--border);padding:4px 12px calc(4px + env(safe-area-inset-bottom));justify-content:space-around;}
.mob-nav-item{flex:1;display:flex;flex-direction:column;align-items:center;gap:2px;padding:8px 4px;border:none;background:none;font-size:10px;font-weight:500;color:var(--text3);cursor:pointer;min-height:50px;border-radius:8px;transition:all var(--t);}
.mob-nav-item.active{color:var(--accent);}
.mob-nav-item svg{width:20px;height:20px;}

/* === RESPONSIVE === */
@media (max-width: 767px) {
  body{flex-direction:column;}
  .sidebar{display:none;}
  .menu-btn{display:flex;}
  .mob-nav{display:flex;}
  .main-wrap{padding-bottom:64px;}
  .content{padding:10px;}
  .topbar{padding:0 12px;height:48px;}
  .topbar-title{font-size:13px;}
  .topbar-link{font-size:10px;padding:4px 8px;}
  .kpi-row{grid-template-columns:repeat(2,1fr);gap:8px;}
  .store-grid{grid-template-columns:1fr;}
  .filter-row{gap:6px;}
  .filter-select{font-size:12px;padding:6px 24px 6px 10px;}
  .chart-box{height:220px;}
  .chart-box.tall{height:260px;}
}

@media (min-width: 768px) and (max-width: 1023px) {
  body{flex-direction:row;}
  .menu-btn{display:none;}
  .mob-nav{display:none;}
  .sidebar{width:160px;}
  .chart-row.cols-2{grid-template-columns:1fr;}
  .store-grid{grid-template-columns:repeat(2,1fr);}
  .kpi-row{grid-template-columns:repeat(3,1fr);}
}

@media (min-width: 1024px) {
  .menu-btn{display:none;}
  .mob-nav{display:none;}
  .chart-row.cols-2{grid-template-columns:repeat(2,1fr);}
  .kpi-row{grid-template-columns:repeat(auto-fit,minmax(170px,1fr));}
}

@media (min-width: 1440px) {
  .content{padding:24px 36px;}
  .kpi-row{grid-template-columns:repeat(5,1fr);}
  .store-grid{grid-template-columns:repeat(auto-fill,minmax(340px,1fr));}
  .chart-box{height:340px;}
  .chart-box.tall{height:420px;}
}

/* === MOBILE SIDEBAR OVERLAY === */
.sidebar-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,0.3);z-index:55;}
.sidebar-overlay.show{display:block;}

@media (max-width: 767px) {
  .sidebar.mobile-open{
    display:flex;position:fixed;left:0;top:0;bottom:0;z-index:70;
    width:260px;box-shadow:var(--shadow-md);
  }
}
