:root {
  --ink: #e9f2fa;
  --muted: #8da0b4;
  --surface: #07131f;
  --surface-2: #0a1b29;
  --line: rgba(118, 164, 201, 0.24);
  --green: #43e66e;
  --red: #ff555a;
  --yellow: #f4d64b;
  --blue: #75c8ff;
}

@font-face {
  font-family: "Dashboard Persian";
  src: local("B Yekan+"), local("B Yekan");
  font-display: swap;
}

* { box-sizing: border-box; }

html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }

body {
  min-width: 1180px;
  background: #030b12;
  color: var(--ink);
  font-family: "Dashboard Persian", "B Yekan+", "B Yekan", Tahoma, Arial, sans-serif;
}

.tv-dashboard {
  width: 100vw;
  height: 100vh;
  min-height: 680px;
  overflow: hidden;
  display: grid;
  grid-template-rows: minmax(0, 1.24fr) minmax(0, 7.73fr) minmax(0, 1.03fr);
  gap: 1.35vh;
  padding: 0.9vh 1vw;
  background:
    linear-gradient(135deg, rgba(2, 10, 17, 0.94) 0%, rgba(7, 21, 33, 0.88) 50%, rgba(3, 11, 18, 0.94) 100%),
    url("assets-factory-overview.jpg") center / cover no-repeat;
}

.hero-panel, .market-card, .analysis-panel, .status-item {
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(178, 224, 255, 0.04), 0 0 28px rgba(0, 0, 0, 0.22);
}

.hero-panel {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: 19% 1fr 22%;
  align-items: center;
  padding: 0.8vh 2vw;
  border-radius: 0 0 18px 18px;
  background:
    linear-gradient(90deg, rgba(3, 14, 24, 0.95) 0%, rgba(3, 15, 25, 0.72) 47%, rgba(3, 14, 24, 0.95) 100%),
    url("assets-factory-overview.jpg") center 54% / cover no-repeat;
}

.hero-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(2, 10, 17, 0.5), transparent 45%, rgba(2, 10, 17, 0.5));
}

.hero-grid {
  position: absolute;
  inset: -35% 18% -15% 28%;
  opacity: 0.38;
  background:
    repeating-linear-gradient(90deg, transparent 0 66px, rgba(117, 200, 255, 0.12) 67px 69px, transparent 70px 132px),
    repeating-linear-gradient(0deg, transparent 0 35px, rgba(117, 200, 255, 0.08) 36px 37px, transparent 38px 70px);
  transform: perspective(500px) rotateX(57deg) rotateZ(-5deg);
}

.logo-slot, .brand-title, .clock-panel { position: relative; z-index: 1; }

.logo-slot { display: flex; align-items: center; direction: rtl; }
.brand-logo {
  display: block;
  width: clamp(128px, 11.6vw, 222px);
  max-height: 8.8vh;
  object-fit: contain;
  object-position: right center;
  padding: 0;
  background: transparent;
  filter: invert(1) drop-shadow(0 3px 0 rgba(159, 211, 241, 0.56)) drop-shadow(0 12px 13px rgba(0, 0, 0, 0.78));
  transform: perspective(360px) rotateY(-6deg) translateZ(0);
}

.brand-title { text-align: right; padding-right: 2vw; }
.brand-title h1 { margin: 0; font-size: clamp(24px, 2.7vw, 51px); line-height: 1.05; letter-spacing: -1px; }
.brand-title p { margin: 0; }
.eyebrow { color: #a7c7dd; letter-spacing: 0.15em; font-size: clamp(8px, 0.72vw, 13px); direction: ltr; text-align: right; }

.clock-panel { text-align: left; direction: rtl; }
.clock-panel p, .clock-panel span { margin: 0; color: #a7b6c5; font-size: clamp(10px, 0.87vw, 16px); }
.clock-panel time { display: block; direction: ltr; unicode-bidi: isolate; color: #fff; font-family: "Dashboard Persian", "B Yekan+", "B Yekan", Tahoma, sans-serif; font-size: clamp(28px, 3.1vw, 58px); line-height: 0.94; font-weight: 700; letter-spacing: 0.06em; margin: 0.2vh 0; }

.dashboard-grid { min-height: 0; display: grid; direction: ltr; grid-template-columns: 29.7% 1fr; gap: 1vw; }
.market-column { min-height: 0; display: grid; grid-template-rows: 1fr 1fr; gap: 1.25vh; direction: rtl; }

.market-card, .analysis-panel { min-height: 0; border-radius: 16px; background: linear-gradient(145deg, rgba(9, 27, 41, 0.97), rgba(3, 14, 23, 0.98)); }
.market-card { padding: clamp(16px, 2vh, 32px) clamp(18px, 2vw, 38px); display: grid; grid-template-rows: auto 1fr auto; }
.market-heading { display: flex; direction: rtl; justify-content: space-between; align-items: center; gap: 0.8vw; }
.market-heading h2 { margin: 0; font-size: clamp(19px, 1.8vw, 35px); }
.percent-label { unicode-bidi: isolate; font-weight: inherit; }
.market-heading p { margin: 0.6vh 0 0; color: var(--muted); direction: ltr; text-align: right; font-size: clamp(9px, 0.92vw, 17px); letter-spacing: 0.06em; }
.commodity-icon { width: clamp(48px, 5.2vw, 96px); height: clamp(38px, 4.1vw, 76px); fill: #82b9de; stroke: rgba(196, 230, 251, 0.86); stroke-width: 1.3; filter: drop-shadow(0 0 10px rgba(132, 201, 250, 0.24)); flex: 0 0 auto; }
.coal-icon { fill: #253543; stroke: #9ac0d9; }
.billet-icon { fill: #94b8d1; }
.icon-shine { fill: none; stroke: rgba(244, 252, 255, 0.74); stroke-width: 3; stroke-linecap: round; }
.commodity-photo { width: clamp(48px, 5.2vw, 96px); height: clamp(38px, 4.1vw, 76px); object-fit: contain; filter: drop-shadow(0 0 10px rgba(132, 201, 250, 0.2)); flex: 0 0 auto; }

.price-wrap { align-self: center; padding: 1vh 1vw 0.7vh; direction: rtl; }
.price-wrap strong { display: block; color: var(--green); direction: ltr; unicode-bidi: isolate; text-align: right; font-family: "Dashboard Persian", "B Yekan+", "B Yekan", Tahoma, sans-serif; font-size: clamp(34px, 3.95vw, 76px); font-weight: 800; letter-spacing: 0.035em; font-variant-numeric: lining-nums tabular-nums; text-shadow: 0 0 18px rgba(52, 225, 105, 0.14); }
.price-wrap span { display: block; margin-top: 0.2vh; color: #c3d2de; font-size: clamp(14px, 1.3vw, 25px); }
.negative-price strong { color: var(--red); text-shadow: 0 0 18px rgba(255, 85, 90, 0.13); }

.change-panel { display: grid; direction: rtl; grid-template-columns: auto 1fr auto; align-items: center; column-gap: 1.2vw; min-height: 7.2vh; padding: 1.2vh 1.2vw; border: 1px solid rgba(93, 198, 135, 0.2); border-radius: 12px; background: rgba(47, 145, 95, 0.12); color: var(--green); }
.change-panel.negative { color: var(--red); border-color: rgba(255, 92, 96, 0.16); background: rgba(164, 44, 49, 0.12); }
.change-panel .arrow { grid-row: span 2; font-size: clamp(29px, 2.7vw, 52px); }
.change-panel b { direction: ltr; unicode-bidi: isolate; text-align: right; font-family: "Dashboard Persian", "B Yekan+", "B Yekan", Tahoma, sans-serif; font-variant-numeric: lining-nums tabular-nums; font-size: clamp(17px, 1.75vw, 33px); }
.change-panel small { grid-column: 2 / 4; color: #b7c3cd; font-size: clamp(10px, 1vw, 18px); }

.analysis-panel { padding: clamp(13px, 1.8vh, 28px); direction: rtl; display: grid; grid-template-rows: auto 1fr; gap: 1.25vh; }
.analysis-heading { display: flex; align-items: center; justify-content: space-between; padding: 0 0.35vw; }
.lab-title { display: flex; align-items: center; gap: 1.3vw; }
.lab-title h2 { margin: 0; font-size: clamp(21px, 2vw, 39px); }
.lab-title p { margin: 0.35vh 0 0; direction: ltr; text-align: right; color: var(--muted); letter-spacing: 0.1em; font-size: clamp(9px, 0.85vw, 16px); }
.lab-icon { color: var(--blue); font-size: clamp(32px, 3.2vw, 64px); line-height: 1; }
.record-count { color: #b7c8d5; font-size: clamp(12px, 1.05vw, 19px); }
.record-count b { display: inline-block; margin-right: 0.55vw; padding: 0.8vh 1vw; border: 1px solid rgba(134, 181, 216, 0.35); border-radius: 9px; color: #eaf4fa; font-weight: 400; }

.table-shell { min-height: 0; overflow: hidden; border: 1px solid rgba(117, 172, 212, 0.2); border-radius: 13px; background: rgba(2, 12, 20, 0.6); }
table { width: 100%; height: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { border-left: 1px solid rgba(117, 172, 212, 0.14); border-bottom: 1px solid rgba(117, 172, 212, 0.14); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
thead tr { height: 13%; background: rgba(23, 48, 69, 0.72); }
tbody tr { height: 8.7%; }
tbody tr:nth-child(even) { background: rgba(21, 46, 63, 0.3); }
th { font-size: clamp(11px, 1.1vw, 21px); font-weight: 700; }
th small { display: block; color: #91a8b9; direction: ltr; margin-top: 0.55vh; font-size: clamp(8px, 0.72vw, 13px); font-weight: 400; }
td { padding: 0 0.3vw; color: #dbe7ef; font-size: clamp(11px, 1.05vw, 20px); }
th:nth-child(1) { width: 4%; } th:nth-child(2) { width: 12%; } th:nth-child(3) { width: 14%; } th:nth-child(4) { width: 20%; } th:nth-child(5), th:nth-child(6), th:nth-child(7), th:nth-child(8) { width: 8.5%; } th:nth-child(9) { width: 16%; }
.metric-good { color: var(--green); font-weight: 700; } .metric-alert { color: var(--red); font-weight: 700; } .metric-warn { color: var(--yellow); font-weight: 700; }
.latin-number { direction: ltr; unicode-bidi: isolate; font-family: "Dashboard Persian", "B Yekan+", "B Yekan", Tahoma, sans-serif; }

.status-bar { direction: rtl; min-height: 0; display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 1vw; }
.status-item { min-width: 0; padding: 1.2vh 1.6vw; border-radius: 15px; background: linear-gradient(135deg, rgba(8, 27, 41, 0.94), rgba(4, 17, 27, 0.96)); display: flex; direction: rtl; align-items: center; justify-content: center; gap: clamp(8px, 0.85vw, 16px); color: #bac8d3; font-size: clamp(11px, 1.04vw, 19px); white-space: nowrap; }
.status-item strong { color: #eef7fc; font-size: clamp(13px, 1.2vw, 23px); }
.status-glyph { color: var(--blue); font-size: clamp(22px, 2.2vw, 40px); }
.online-dot { flex: 0 0 auto; width: clamp(10px, 0.8vw, 16px); aspect-ratio: 1; border-radius: 50%; background: #15d147; box-shadow: 0 0 14px rgba(21, 209, 71, 0.65); }
.system-status { border-right-color: rgba(27, 215, 74, 0.36); }

@media (max-height: 780px) { .market-card { padding-top: 1.3vh; padding-bottom: 1.3vh; } }

/* Android TV browsers sometimes expose a smaller CSS viewport than the TV's
   physical resolution. Keep the approved Full HD layout unchanged while
   allowing the same grid to fit within that reported viewport. */
@media (max-width: 1180px), (max-height: 680px) {
  body { min-width: 0; }
  .tv-dashboard { min-height: 0; }
}
