/* Pranav Agro — shared page styles (008). Authoritative source:
   extracted from frontend/index.html's style block; loaded by BOTH
   /dashboard and /admin. Page-specific rules stay in each page. */
:root {
      --tone-red-bg: rgba(255,69,58,0.15);
      --tone-green-bg: rgba(48,209,88,0.15);
      --tone-amber-bg: rgba(255,159,10,0.15);
      --tone-purple-bg: rgba(191,90,242,0.15);
      --tone-blue-bg: rgba(10,132,255,0.15);
      --tone-yellow-bg: rgba(255,214,10,0.15);
      --tone-shipping-bg: rgba(172,142,104,0.15);

      --sku-388e3c: #388E3C;
      --sku-66bb6a: #66BB6A;
      --sku-7cb342: #7CB342;
      --sku-a4d65e: #A4D65E;
      --sku-e64a19: #E64A19;
      --sku-f9a825: #F9A825;
      --sku-fb8c00: #FB8C00;
      --sku-fbc02d: #FBC02D;
      --sku-ff5722: #FF5722;
      --sku-ff7043: #FF7043;
      --sku-ffa726: #FFA726;
      --sku-ffb300: #FFB300;
      --sku-ffee58: #FFEE58;

      --chart-0: #FF9F0A;
      --chart-1: #FFD60A;
      --chart-2: #30D158;
      --chart-3: #FF453A;
      --chart-4: #BF5AF2;
      --chart-5: #FF375F;
      --chart-6: #64D2FF;
      --chart-7: #FFB340;
      --chart-8: #30B0C7;
      --chart-9: #AC8E68;
      --chart-10: #FF6482;
      --chart-11: #5E5CE6;

      color-scheme: dark;
      --bg-primary: #0a0e17;
      --bg-card: #111827;
      --bg-card-hover: #181d2a;
      --border: #1f2937;
      --text-primary: #e5e7eb;
      --text-secondary: #9ca3af;
      --text-muted: #8b95a5;
      --accent: #FF9F0A;
      --accent-hover: #FFB340;
      --accent-yellow: #FFD60A;
      --green-bullish: #30D158;
      --red-bearish: #FF453A;
      --amber-signal: #FF9F0A;
      --bg-main: #111827;
      --bg-surface-alt: #181d2a;
      --pill-reference: rgba(251, 191, 36, 0.08);
      --brand-accent: #E8751A;
      --blue: #0A84FF;
      --purple: #BF5AF2;
      --shipping: #AC8E68;
      --chart-grid: rgba(255,255,255,0.04);
      --chart-border: rgba(255,255,255,0.08);
      --chart-crosshair: #4b5563;
      --selection-bg: rgba(255,159,10,0.15);
      --selection-soft: rgba(255,159,10,0.07);
      --brand-wordmark: var(--accent);
      --font-body: 'Sora', system-ui, sans-serif;
    }
    
    :root[data-theme="light"] {
      --tone-red-bg: rgba(180,61,58,0.07);
      --tone-green-bg: rgba(34,107,75,0.07);
      --tone-amber-bg: rgba(128,96,31,0.07);
      --tone-purple-bg: rgba(116,80,160,0.07);
      --tone-blue-bg: rgba(36,93,181,0.07);
      --tone-yellow-bg: rgba(128,96,31,0.07);
      --tone-shipping-bg: rgba(112,88,68,0.07);

      --sku-388e3c: #307a33;
      --sku-66bb6a: #407642;
      --sku-7cb342: #52772c;
      --sku-a4d65e: #597433;
      --sku-e64a19: #c53f16;
      --sku-f9a825: #956517;
      --sku-fb8c00: #a65d00;
      --sku-fbc02d: #876819;
      --sku-ff5722: #c5431a;
      --sku-ff7043: #b24e2f;
      --sku-ffa726: #996417;
      --sku-ffb300: #916600;
      --sku-ffee58: #766e2a;

      --chart-0: #a85532;
      --chart-1: #80601f;
      --chart-2: #226b4b;
      --chart-3: #b03835;
      --chart-4: #7450a0;
      --chart-5: #ac3e63;
      --chart-6: #176a82;
      --chart-7: #985b2a;
      --chart-8: #216f6b;
      --chart-9: #705844;
      --chart-10: #a24463;
      --chart-11: #545ba1;

      color-scheme: light;
      --accent: #245db5;
      --accent-hover: #1d4c94;
      --accent-yellow: #80601f;
      --green-bullish: #226b4b;
      --red-bearish: #b03835;
      --amber-signal: #80601f;
      --brand-accent: #a14726;
      --blue: #245db5;
      --purple: #7450a0;
      --shipping: #705844;
      --chart-grid: rgba(65,58,45,0.07);
      --chart-border: rgba(65,58,45,0.18);
      --chart-crosshair: #545550;
      --bg-primary: #f4f1ea;
      --bg-card: #fcfaf5;
      --bg-card-hover: #efebe3;
      --border: #d8d3c9;
      --text-primary: #272725;
      --text-secondary: #545550;
      --text-muted: #62645e;
      --bg-main: #f4f1ea;
      --bg-surface-alt: #efebe3;
      --pill-reference: rgba(128,96,31,0.08);
      --selection-bg: rgba(36,93,181,0.10);
      --selection-soft: rgba(36,93,181,0.06);
      --brand-wordmark: var(--brand-accent);
    }
    
    /* Smooth transitions for theme switching */
    body, .widget, .exchange-card, .kpi-card, .header-controls button {
      transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
    }

    @font-face {
      font-family: 'Futura Medium BT';
      src: url('/public/futura-medium-bt.ttf') format('truetype');
      font-weight: 500;
      font-style: normal;
      font-display: swap;
    }
    .brand-wordmark {
      font-family: 'Futura Medium BT', 'Sora', system-ui, sans-serif;
      letter-spacing: 0.08em;
    }
    body {
      background: var(--bg-primary);
      color: var(--text-primary);
      font-family: var(--font-body);
      margin: 0;
      padding: 0;
    }
    :root[data-theme="light"] body {
      background-image: url('/public/paper-grain.svg');
      background-size: 180px 180px;
      background-repeat: repeat;
    }
    .font-mono { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; font-variant-numeric: tabular-nums; }
    .tabular-nums { font-variant-numeric: tabular-nums; }
    .bg-card { background: var(--bg-card); }
    .border-custom { border-color: var(--border); }
    .text-secondary { color: var(--text-secondary); }
    .text-muted { color: var(--text-muted); }
    .text-green { color: var(--green-bullish); }
    .text-red { color: var(--red-bearish); }
    .text-amber { color: var(--amber-signal); }
    .bg-primary { background: var(--bg-primary); }

    .stale { opacity: 0.45; }

    .parity-input::placeholder { color: var(--text-muted); opacity: 0.6; }

    .price-up { color: var(--green-bullish); }
    .price-down { color: var(--red-bearish); }

    table { border-collapse: collapse; width: 100%; }
    th, td { padding: 10px 14px; text-align: right; border-bottom: 1px solid var(--border); }
    th:first-child, td:first-child { text-align: left; }
    th { color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }

    .upload-zone {
      border: 2px dashed var(--border);
      border-radius: 8px;
      padding: 20px;
      text-align: center;
      transition: border-color 0.2s, background 0.2s;
      cursor: pointer;
    }
    .upload-zone.dragover {
      border-color: var(--accent);
      background: rgba(255, 159, 10, 0.1);
    }

    .sentiment-dot {
      width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 8px; flex-shrink: 0;
    }
    .sentiment-BULLISH { background: var(--green-bullish); }
    .sentiment-BEARISH { background: var(--red-bearish); }
    .sentiment-NEUTRAL { background: var(--text-muted); }

    .kpi-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 12px 16px;
      min-width: 120px;
    }

    .info-tip {
      position: absolute;
      right: 2px;
      bottom: 1px;
      font-size: 0.65rem;
      color: var(--text-muted);
      cursor: help;
      line-height: 1;
      padding: 4px;
    }
    .info-tip .info-tip-text {
      display: none;
      position: absolute;
      bottom: 100%;
      right: 0;
      background: var(--bg-card);
      border: 1px solid var(--border);
      color: var(--text-primary);
      font-size: 0.58rem;
      font-weight: 400;
      padding: 4px 8px;
      border-radius: 4px;
      white-space: nowrap;
      pointer-events: none;
      z-index: 10;
      margin-bottom: 4px;
    }
    .info-tip:hover .info-tip-text {
      display: block;
    }

    .exchange-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 16px;
    }

    .widget {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 8px;
      padding: 16px;
      min-width: 0; /* allow widget to shrink inside grid/flex parents */
    }

    /* Horizontal scroll container for wide tables (e.g. Supplier Matrix).
       Without this, a table wider than the widget blows out the whole
       dashboard and you get page-level horizontal scroll. */
    .matrix-wrap {
      overflow-x: auto;
      max-width: 100%;
      /* thin scrollbar so it doesn't dominate the dark UI */
      scrollbar-width: thin;
      scrollbar-color: var(--border) transparent;
    }
    .matrix-wrap::-webkit-scrollbar { height: 8px; }
    .matrix-wrap::-webkit-scrollbar-track { background: transparent; }
    .matrix-wrap::-webkit-scrollbar-thumb {
      background: var(--border);
      border-radius: 4px;
    }
    .matrix-wrap::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }
    /* Let the table size naturally beyond the container width so the scroll
       actually has something to reveal. */
    .matrix-wrap > table { width: auto; min-width: 100%; }
    /* Supplier Offer Matrix: fixed layout so the text columns stay pinned and
       the price columns split the remaining width evenly (instead of auto-layout
       dumping all the slack into NOTES and leaving a gap). Column widths come
       from the <colgroup>; an inline min-width drives horizontal scroll. */
    .matrix-wrap > table.matrix-table { table-layout: fixed; width: auto; min-width: 0; }
    .matrix-table td { overflow-wrap: anywhere; }
    .matrix-table th { word-break: normal; overflow-wrap: normal; }

    .widget-title {
      font-size: 0.75rem;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--text-muted);
      margin-bottom: 12px;
      font-weight: 600;
    }

    .btn {
      padding: 6px 16px;
      border-radius: 6px;
      font-size: 0.8rem;
      cursor: pointer;
      border: 1px solid var(--border);
      background: var(--bg-card);
      color: var(--text-primary);
      transition: background 0.15s;
    }
    .btn:hover { background: var(--bg-card-hover); }
    .btn.active { background: var(--accent); border-color: var(--accent); color: var(--bg-primary); font-weight: 600; }

    .loading {
      display: flex; align-items: center; justify-content: center;
      padding: 40px; color: var(--text-muted);
    }

    .empty-state {
      text-align: center; padding: 40px; color: var(--text-muted); font-size: 0.9rem;
    }

    .lang-toggle {
      display: flex;
      border-radius: 6px;
      border: 1px solid var(--border);
      overflow: hidden;
    }
    .lang-toggle button {
      padding: 4px 14px;
      font-size: 0.8rem;
      cursor: pointer;
      border: none;
      transition: background 0.15s, color 0.15s;
    }
    .lang-toggle button.active {
      background: var(--accent);
      color: var(--bg-primary);
      font-weight: 600;
    }
    .lang-toggle button:not(.active) {
      background: transparent;
      color: var(--text-muted);
    }
    .lang-toggle button:not(.active):hover {
      color: var(--text-secondary);
    }

    /* Onboarding */
    .onboard-overlay {
      position: fixed; inset: 0; z-index: 1000;
      background: rgba(0,0,0,0.88);
      display: flex; align-items: center; justify-content: center;
      backdrop-filter: blur(12px);
      -webkit-backdrop-filter: blur(12px);
    }
    .onboard-card {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 20px;
      max-width: 580px; width: 92%;
      padding: 40px 36px;
      animation: onboardIn 0.35s ease;
    }
    @keyframes onboardIn {
      from { transform: translateY(24px) scale(0.97); opacity: 0; }
      to { transform: translateY(0) scale(1); opacity: 1; }
    }
    .onboard-dots {
      display: flex; gap: 8px; justify-content: center; margin-bottom: 28px;
    }
    .onboard-dot {
      width: 8px; height: 8px; border-radius: 50%;
      background: var(--border);
      transition: all 0.25s;
    }
    .onboard-dot.active { background: var(--accent); transform: scale(1.4); }
    .onboard-dot.done { background: var(--green-bullish); }
    .onboard-title {
      font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: 6px;
    }
    .onboard-sub {
      font-size: 0.9rem; color: var(--text-secondary); text-align: center; margin-bottom: 28px;
    }
    .toggle-grid {
      display: grid; gap: 12px;
    }
    .toggle-grid.cols-2 { grid-template-columns: 1fr 1fr; }
    .toggle-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
    .toggle-card {
      background: var(--bg-primary);
      border: 2px solid var(--border);
      border-radius: 14px;
      padding: 18px 16px;
      cursor: pointer;
      transition: border-color 0.2s, background 0.2s, transform 0.15s;
      text-align: center;
      user-select: none;
    }
    .toggle-card:hover { border-color: var(--text-muted); transform: translateY(-1px); }
    .toggle-card.selected {
      border-color: var(--accent);
      background: rgba(255, 159, 10, 0.07);
    }
    .toggle-card .tc-icon { font-size: 1.6rem; margin-bottom: 6px; }
    .toggle-card .tc-label { font-size: 0.88rem; font-weight: 600; }
    .toggle-card .tc-desc { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; line-height: 1.35; }
    .toggle-card .tc-check {
      width: 20px; height: 20px; border-radius: 50%; margin: 8px auto 0;
      border: 2px solid var(--border); display: flex; align-items: center; justify-content: center;
      transition: all 0.2s; font-size: 0.7rem;
    }
    .toggle-card.selected .tc-check {
      border-color: var(--accent); background: var(--accent); color: var(--bg-primary);
    }
    .onboard-btn-primary {
      background: var(--accent); color: var(--bg-primary); border: none; border-radius: 12px;
      padding: 14px 32px; font-size: 1rem; font-weight: 600; cursor: pointer;
      transition: background 0.15s, transform 0.1s; width: 100%; margin-top: 24px;
    }
    .onboard-btn-primary:hover { background: var(--accent-hover); }
    .onboard-btn-primary:active { transform: scale(0.98); }
    .onboard-btn-back {
      background: none; border: none; color: var(--text-muted); font-size: 0.85rem;
      cursor: pointer; padding: 8px 0; transition: color 0.15s;
    }
    .onboard-btn-back:hover { color: var(--text-primary); }
    .onboard-footer {
      display: flex; justify-content: space-between; align-items: center; margin-top: 20px;
    }
    .customize-btn {
      background: var(--accent); border: 1px solid var(--accent);
      color: var(--bg-primary); border-radius: 8px; padding: 9px 20px; font-size: 0.9rem;
      font-weight: 600; cursor: pointer; transition: background 0.15s, transform 0.1s;
      box-shadow: 0 0 0 1px rgba(255,159,10,0.25), 0 2px 8px rgba(255,159,10,0.18);
    }
    .customize-btn:hover { background: var(--accent-hover); }
    .customize-btn:active { transform: scale(0.97); }

    /* Full-height app shell: header spans full width, panes below */
    .app-shell {
      display: flex;
      flex-direction: column;
      height: 100vh;
      overflow: hidden;
    }
    .app-topbar {
      flex-shrink: 0;
      padding: 16px 20px 0;
    }
    /* Two-pane layout: dashboard left, broker feed right */
    .two-pane {
      display: flex;
      flex: 1 1 0%;
      min-height: 0; /* allow children to scroll */
    }
    .pane-left {
      flex: 1 1 0%;
      min-width: 0;
      padding: 0 20px 16px;
      overflow-y: auto;
      scrollbar-width: none;          /* Firefox */
    }
    .pane-left::-webkit-scrollbar { display: none; }  /* Chrome/Safari */
    .pane-right {
      flex: 0 0 30%;
      max-width: 480px;
      min-width: 320px;
      overflow: hidden;
      display: flex;
      flex-direction: column;
    }

    @media (max-width: 768px) {
      .app-shell { height: auto; overflow: visible; }
      .app-topbar { padding: 12px 10px 0; }
      .two-pane { flex-direction: column; }
      .pane-left { padding: 0 10px 12px; overflow-y: visible; }
      /* pane-right hidden on mobile via React conditional — no CSS needed */
      .grid-responsive { grid-template-columns: 1fr !important; }
      .toggle-grid.cols-3 { grid-template-columns: 1fr 1fr; }
      .onboard-card { padding: 28px 20px; }

      /* Header: stack title + controls */
      .dash-header { flex-direction: column !important; align-items: flex-start !important; gap: 8px !important; }
      .subtitle-text { display: none !important; }
      .header-controls { flex-wrap: wrap; gap: 6px !important; justify-content: flex-start; }

      /* Filter bar: stack controls vertically, wrap chips */
      .filter-bar { flex-direction: column !important; gap: 8px !important; }
      .filter-bar > div { flex-wrap: wrap; }
      .filter-chips { flex-wrap: wrap !important; }

      /* KPI cards: 2-column on tablet, 1-column on phone */
      .kpi-row { flex-wrap: wrap !important; }
      .kpi-card { min-width: 140px !important; flex: 1 1 45% !important; }

      /* Widget titles: tighter on mobile */
      .widget-title { font-size: 0.85rem !important; }
      .widget { padding: 14px 10px !important; }

      /* Parity calculator: single column inputs */
      .parity-grid { grid-template-columns: 1fr !important; }
    }

    @media (max-width: 480px) {
      .kpi-card { flex: 1 1 100% !important; }
    }

    /* News Ticker — C6.3 */
    .news-ticker {
      background: var(--bg-card);
      border: 1px solid var(--border);
      border-radius: 8px;
      margin-bottom: 12px;
      overflow: hidden;
      display: flex;
      align-items: center;
      height: 34px;
      font-size: 0.72rem;
    }
    .news-ticker-label {
      flex-shrink: 0;
      padding: 0 10px;
      font-size: 0.62rem;
      font-weight: 700;
      text-transform: uppercase;
      letter-spacing: 0.1em;
      color: var(--accent);
      border-right: 1px solid var(--border);
      height: 100%;
      display: flex;
      align-items: center;
    }
    .news-ticker-scroll {
      flex: 1;
      overflow: hidden;
      height: 100%;
      cursor: pointer;
      display: flex;
      align-items: center;
    }
    .news-ticker-track {
      display: flex;
      align-items: center;
      white-space: nowrap;
      animation: ticker-scroll 180s linear infinite;
    }
    .news-ticker-track.paused,
    .news-ticker-track:hover { animation-play-state: paused; }
    @keyframes ticker-scroll {
      0%   { transform: translateX(0); }
      100% { transform: translateX(-50%); }
    }
    .news-ticker-item {
      display: inline-flex;
      align-items: center;
      padding: 0 32px;
      color: var(--text-primary);
      font-size: 0.74rem;
    }
    .news-ticker-sep {
      color: var(--text-muted);
      font-size: 0.65rem;
      padding: 0 4px;
      flex-shrink: 0;
      opacity: 0.4;
    }
    /* WhatsApp FAB — mobile only (rendered conditionally via React) */
    .broker-fab {
      position: fixed;
      bottom: 20px;
      right: 20px;
      z-index: 900;
      width: 56px;
      height: 56px;
      border-radius: 50%;
      background: #25D366;
      border: none;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      box-shadow: 0 4px 12px rgba(0,0,0,0.4);
      transition: transform 0.15s, box-shadow 0.15s;
    }
    .broker-fab:active { transform: scale(0.92); }
    .broker-fab svg { width: 28px; height: 28px; fill: #fff; }

    /* Backdrop behind feed overlay */
    .broker-feed-backdrop {
      position: fixed;
      inset: 0;
      z-index: 899;
      background: rgba(0,0,0,0.5);
      animation: fadeIn 0.2s ease;
    }

    /* Slide-up feed overlay */
    .broker-feed-overlay {
      position: fixed;
      bottom: 0; left: 0; right: 0;
      z-index: 901;
      height: 85vh;
      border-radius: 16px 16px 0 0;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      animation: feedSlideUp 0.3s ease;
    }
    .broker-feed-overlay.closing {
      animation: feedSlideDown 0.3s ease forwards;
    }

    /* Drag handle at top of overlay */
    .broker-feed-handle {
      background: var(--bg-card);
      padding: 10px 0 6px;
      display: flex;
      justify-content: center;
      cursor: pointer;
      flex-shrink: 0;
    }
    .handle-bar {
      width: 36px;
      height: 4px;
      border-radius: 2px;
      background: rgba(255,255,255,0.25);
    }

    @keyframes feedSlideUp {
      from { transform: translateY(100%); }
      to { transform: translateY(0); }
    }
    @keyframes feedSlideDown {
      from { transform: translateY(0); }
      to { transform: translateY(100%); }
    }
    @keyframes fadeIn {
      from { opacity: 0; }
      to { opacity: 1; }
    }
    @media (max-width: 768px) {
      .grid-2col { grid-template-columns: 1fr !important; }
    }
    .skeleton {
      background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
      background-size: 200% 100%;
      animation: shimmer 1.5s infinite;
      border-radius: 4px;
    }
    @keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
    .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

    button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
      outline: 2px solid var(--accent); outline-offset: 3px;
    }
    @media (prefers-reduced-motion: reduce) {
      body, .widget, .exchange-card, .kpi-card, .header-controls button { transition: none; }
    }
