/* Shared styles for supply-chain-reports. Matches the Crow Works dashboard look. */
:root {
  --bg: #f0f4f8;
  --text: #1e293b;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --header: #0f172a;
  --card: #ffffff;
  --accent: #3b82f6;
  --good: #16a34a;
  --watch: #d97706;
  --bad: #dc2626;
  --grey: #64748b;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); overflow-x: hidden; }
a { color: inherit; }

/* Header */
.app-header { position: sticky; top: 0; z-index: 20; height: 60px; background: var(--header); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 24px; }
.app-header .left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.app-header h1 { margin: 0; color: #fff; font-size: 20px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-header .right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.app-header .updated { color: var(--faint); font-size: 12px; white-space: nowrap; }
.btn { background: transparent; color: #fff; border: 1px solid #475569; border-radius: 6px; padding: 6px 12px; font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap; font-family: inherit; }
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-light { color: var(--text); border-color: #cbd5e1; background: #fff; }
.btn-light:hover { border-color: var(--muted); }
.menu { background: transparent; color: #fff; border: 1px solid #475569; border-radius: 6px; padding: 6px 8px; font-size: 13px; font-family: inherit; max-width: 200px; }
.menu option { color: var(--text); }

/* Loading bar */
.loading-bar { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--accent); z-index: 30; transition: width .3s ease, opacity .3s ease; opacity: 0; }
.loading-bar.on { opacity: 1; width: 70%; transition: width 8s cubic-bezier(.1,.7,.3,1); }
.loading-bar.done { opacity: 0; width: 100%; }

/* Banners and panels */
main { max-width: 1500px; margin: 0 auto; padding: 24px; }
.banner { border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 14px; }
.banner.error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.banner.stale { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.ns-panel { background: #fff; border: 1px solid #fecaca; border-left: 4px solid var(--bad); border-radius: 12px; padding: 20px; margin-bottom: 16px; }
.ns-panel h2 { margin: 0 0 6px; font-size: 18px; color: #991b1b; }
.ns-panel p { margin: 0 0 12px; color: var(--muted); }

/* Cards */
.card { background: var(--card); border-radius: 12px; box-shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 2px rgba(15,23,42,.06); padding: 20px; min-width: 0; }
.section { margin-bottom: 20px; }
.section h2 { margin: 0 0 4px; font-size: 17px; }
.section .note { margin: 0 0 14px; color: var(--muted); font-size: 13px; }

/* Landing grid */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
a.report-card { display: flex; flex-direction: column; text-decoration: none; transition: box-shadow .15s, transform .15s; }
a.report-card:hover { box-shadow: 0 6px 18px rgba(15,23,42,.12); transform: translateY(-1px); }
.report-card .title { font-size: 15px; font-weight: 600; color: #334155; }
.report-card .value { font-size: 36px; font-weight: 700; margin: 10px 0 2px; color: #0f172a; font-variant-numeric: tabular-nums; }
.report-card .label { font-size: 13px; color: var(--muted); }
.report-card .detail { font-size: 13px; color: #475569; margin-top: 4px; min-height: 18px; }
.report-card .comparison { font-size: 12px; color: var(--muted); margin-top: 2px; }
.report-card .chart { position: relative; height: 110px; margin-top: 14px; }
.report-card .foot { margin-top: 12px; font-size: 12px; color: var(--faint); }
.report-card .foot .stale { color: var(--watch); font-weight: 600; }
.report-card .foot .unavailable { color: var(--grey); font-weight: 600; }
.report-card.is-unavailable .value { color: var(--faint); }
.s-good { color: var(--good) !important; }
.s-watch { color: var(--watch) !important; }
.s-bad { color: var(--bad) !important; }

/* KPI tiles on report pages */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi .k-label { font-size: 13px; color: var(--muted); }
.kpi .k-value { font-size: 28px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12px; color: var(--faint); margin-top: 2px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.chart-box { position: relative; height: 280px; }

/* Tables: wide tables scroll inside their own box */
.table-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.table-tools input { border: 1px solid #cbd5e1; border-radius: 6px; padding: 6px 10px; font-size: 13px; font-family: inherit; min-width: 0; flex: 1; max-width: 320px; }
.table-wrap { overflow: auto; max-height: 640px; border: 1px solid var(--line); border-radius: 8px; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th { position: sticky; top: 0; background: #f8fafc; text-align: left; font-weight: 600; color: #475569; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none; }
table.data th.num, table.data td.num { text-align: right; }
table.data td { padding: 7px 10px; border-bottom: 1px solid #f1f5f9; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: #f8fafc; }
a.ns-link { color: #2563eb; text-decoration: none; }
a.ns-link:hover { text-decoration: underline; }
table.data td.wrap { white-space: normal; min-width: 260px; max-width: 420px; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.toggle { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.count { color: var(--muted); font-size: 13px; }

@media (max-width: 1100px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
  main { padding: 16px; }
  .app-header { padding: 0 16px; }
  .app-header .updated, .app-header .hide-sm { display: none; }
  .app-header h1 { font-size: 17px; }
  .menu { max-width: 120px; }
}
