/* CMCT web — Honeywell dark theme (palette ported from the desktop theme.py) */

:root {
  --red: #CF2030;
  --red-hover: #E02840;
  --red-press: #B01828;
  --bg-deep: #1a1714;
  --bg: #231f1c;
  --surface: #332e2a;
  --surface-alt: #2a2522;
  --border: #4a4540;
  --wood: #C8956A;
  --green: #5A8C3A;
  --amber: #E8A840;
  --text: #F0EDE8;
  --muted: #A09890;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
}

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  background: var(--bg-deep);
  border-bottom: 1px solid var(--border);
  padding: 10px 20px;
  position: sticky; top: 0; z-index: 50;
}
.topbar .brand { font-size: 17px; font-weight: 700; color: var(--red); white-space: nowrap; display: inline-flex; align-items: center; gap: 10px; }
.topbar .brand small { color: var(--muted); font-weight: 400; margin-left: 8px; }
.topbar .brand img { height: 28px; width: 28px; border-radius: 4px; display: block; }
.topbar .spacer { flex: 1; }
.topbar .user { color: var(--muted); }

/* ---- layout ---- */
.page { max-width: 1400px; margin: 0 auto; padding: 20px; }
.card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 14px; color: var(--wood); text-transform: uppercase; letter-spacing: .5px; }
.grid { display: grid; gap: 10px 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ---- controls ---- */
input, select, textarea, button {
  font-family: inherit; font-size: 14px; color: var(--text);
}
input[type=text], input[type=password], input[type=number], select, textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 7px 10px;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--red); }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--red); }
input[type=color] { padding: 0; height: 30px; width: 44px; border: 1px solid var(--border); background: var(--surface); border-radius: 5px; }
label { color: var(--muted); font-size: 12.5px; display: block; margin-bottom: 3px; }

button {
  background: var(--red); color: #fff; border: none; border-radius: 6px;
  padding: 8px 16px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
button:hover { background: var(--red-hover); }
button:active { background: var(--red-press); }
button.secondary { background: var(--border); color: var(--text); }
button.secondary:hover { background: #5a5450; }
button.small { padding: 4px 10px; font-size: 12.5px; }
button:disabled { background: var(--border); color: var(--muted); cursor: default; }

/* ---- tables ---- */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--wood); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; position: sticky; top: 0; background: var(--surface-alt); }
tr:hover td { background: rgba(255,255,255,.025); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.product-header td {
  background: var(--surface); color: var(--red); font-weight: 700;
}
tr.dim td { color: var(--muted); }

/* ---- tabs ---- */
.tabs { display: flex; gap: 2px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs button {
  background: var(--surface); color: var(--text); border-radius: 6px 6px 0 0;
  border: 1px solid var(--border); border-bottom: none; font-weight: 500;
}
.tabs button.active { background: var(--red); color: #fff; font-weight: 700; }

/* ---- totals cards ---- */
.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.total-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 16px; text-align: center;
}
.total-card .value { font-size: 26px; font-weight: 700; margin-top: 2px; }
.total-card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.total-card.t-total .value { color: var(--green); }
.total-card.t-prev .value { color: var(--wood); }
.total-card.t-pu .value { color: var(--red); }
.total-card.t-corr .value { color: var(--amber); }

/* task-type colors */
.tt-preventive { color: #e07a86; }
.tt-preventive-update { color: #8fbf6f; }
.tt-corrective { color: var(--amber); }

/* ---- asset grid ---- */
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px 16px; }
.asset-item { display: flex; align-items: center; gap: 8px; }
.asset-item label { flex: 1; margin: 0; font-size: 13px; color: var(--text); }
.asset-item input[type=number] { width: 74px; }
.asset-item select { width: 62px; padding: 6px 4px; }

/* ---- modal ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 20px; width: min(640px, 92vw); max-height: 88vh; overflow: auto;
}
.modal h3 { margin: 0 0 14px; color: var(--red); }
.hidden { display: none !important; }

/* ---- misc ---- */
.error { color: var(--amber); font-weight: 600; }
.badge { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 2px 10px; font-size: 12px; color: var(--muted); }
.badge--ok { color: var(--green); border-color: var(--green); }
.badge--warn { color: var(--amber); border-color: var(--amber); }
.save-indicator { color: var(--muted); font-size: 12.5px; }
.save-indicator.dirty { color: var(--amber); }
.banner {
  background: #4a3520; border: 1px solid var(--amber); color: var(--text);
  border-radius: 6px; padding: 10px 14px; margin-bottom: 14px;
}
.banner--danger { background: #4a2023; border-color: var(--red); }
#toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 200; max-width: 420px;
}
#toast .toast-item {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--red);
  border-radius: 6px; padding: 10px 14px; margin-top: 8px; box-shadow: 0 4px 14px rgba(0,0,0,.4);
  white-space: pre-line;
}
.swatch { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 8px; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 12px;
  padding: 34px; width: 100%; position: relative; overflow: hidden;
}
.login-lockup {
  display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 28px;
}
.login-lockup img { height: 40px; width: 40px; border-radius: 6px; }
.login-lockup span {
  color: #E10001; font-weight: 900; font-size: 16px; line-height: 1.08;
  font-family: "Arial Black", "Segoe UI Black", Arial, sans-serif; letter-spacing: -.02em;
}
.login-accent-track {
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--border); overflow: hidden;
}
.login-accent-bar {
  position: absolute; top: 0; left: 0; width: 40%; height: 100%;
  background: linear-gradient(90deg, transparent, var(--red), transparent);
  animation: hw-accent-sweep 3.2s ease-in-out infinite;
}
@keyframes hw-accent-sweep {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(320%); }
}
@media (prefers-reduced-motion: reduce) {
  .login-accent-bar, .hero-accent-bar { animation: none !important; }
}
.login-card h1 { color: var(--red); font-size: 20px; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); margin-bottom: 22px; font-size: 13px; }
.field { margin-bottom: 14px; }

/* ---- calculator: hero totals + sticky live bar (Claude Design port) ---- */
.hero {
  position: relative; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 28px 24px 24px;
  margin-bottom: 14px;
}
.hero-accent-track { position: absolute; top: 0; left: 0; right: 0; height: 3px; overflow: hidden; }
.hero-accent-bar {
  position: absolute; top: 0; left: 0; width: 30%; height: 100%;
  background: linear-gradient(90deg, transparent, var(--red), transparent);
  animation: hw-accent-sweep 4s ease-in-out infinite;
}
.hero__eyebrow {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--wood); margin-bottom: 6px;
}
.hero__title { font-size: 24px; font-weight: 700; color: var(--text); margin-bottom: 20px; }
.hero .total-card { background: var(--surface-alt); }
.total-card .value .unit { font-size: 14px; color: var(--muted); font-weight: 400; margin-left: 3px; }

.live-bar {
  position: sticky; top: 0; z-index: 40;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  display: flex; align-items: center; gap: 24px;
  padding: 9px 16px; margin-bottom: 20px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.live-bar__label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); white-space: nowrap;
}
.live-bar__items { display: flex; gap: 22px; white-space: nowrap; }
.live-bar__items span { font-size: 13px; color: var(--muted); }
.live-bar__items b { font-size: 15px; font-weight: 700; margin-left: 4px; }
.live-bar .lb-total { color: var(--green); }
.live-bar .lb-prev { color: var(--wood); }
.live-bar .lb-pu { color: var(--red); }
.live-bar .lb-corr { color: var(--amber); }

.summary-sections { display: flex; flex-direction: column; gap: 28px; }
.summary-sections .card { margin-bottom: 0; }

/* ---- mobile product cards + bottom action bar (Claude Design port) ---- */
.products-cards { display: none; }
.product-card {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; background: var(--surface);
  margin-bottom: 10px;
}
.product-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.product-card__total { font-size: 15px; font-weight: 700; color: var(--green); white-space: nowrap; padding-top: 2px; }
.product-card label { display: inline-flex; align-items: center; gap: 8px; margin: 0; color: var(--text); font-size: 13.5px; }
.product-card__cc { margin-top: 6px; padding-left: 2px; }
.product-card__cc label { color: var(--muted); font-size: 12.5px; }

.bottom-bar { display: none; }

@media (max-width: 760px) {
  .products-table-wrap { display: none; }
  .products-cards { display: block; }
  .page--calculator { padding-bottom: 84px; }
  .bottom-bar {
    display: flex; align-items: center; gap: 12px;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: var(--bg-deep); border-top: 1px solid var(--border);
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  }
  .bottom-bar__total { flex: 1; display: flex; flex-direction: column; }
  .bottom-bar__total span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
  .bottom-bar__total b { font-size: 18px; color: var(--green); }
  .bottom-bar button { flex: 1.2; min-height: 46px; }
  .hero { padding: 20px 14px 16px; }
  .hero__title { font-size: 19px; margin-bottom: 14px; }
  .summary-sections { gap: 16px; }
}

/* ---- asset tiles (project page) ---- */
.asset-summary { color: var(--muted); font-size: 12.5px; }
.asset-summary b { color: var(--green); font-size: 14px; }
.asset-group-title {
  color: var(--wood); font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em;
  margin: 16px 0 10px;
}
.asset-group-title:first-child { margin-top: 8px; }
.asset-tiles {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
}
.asset-tile {
  background: var(--surface-alt);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 12px 10px;
  transition: border-color .18s, background .18s, transform .12s;
}
.asset-tile:hover { transform: translateY(-1px); }
.asset-tile--active {
  border-color: var(--red);
  background: linear-gradient(180deg, rgba(207, 32, 48, .10), transparent 55%), var(--surface-alt);
}
.asset-tile__top { display: flex; align-items: center; gap: 9px; margin-bottom: 10px; min-height: 34px; }
.asset-tile__icon {
  flex: none; width: 34px; height: 34px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--muted); transition: color .18s, border-color .18s, background .18s;
}
.asset-tile__icon svg { width: 20px; height: 20px; display: block; }
.asset-tile--active .asset-tile__icon {
  color: #fff; background: var(--red); border-color: var(--red);
}
.asset-tile__name { font-size: 12.5px; line-height: 1.25; color: var(--text); }
.asset-tile__stepper { width: 100%; }
.asset-tile__stepper .stepper__value { flex: 1; width: auto; min-width: 0; font-weight: 600; }
.asset-tile--active .stepper__value { color: var(--red); }
.stepper__value.pop { animation: asset-pop .28s ease; }
@keyframes asset-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
.asset-tile__conc { margin-top: 8px; }
.asset-tile__conc label {
  display: flex; align-items: center; gap: 8px; margin: 0;
  color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
}
.asset-tile__conc select { min-width: 0; width: auto; flex: 1; padding: 4px 8px; min-height: 30px; font-size: 12.5px; }
@media (max-width: 760px) {
  .asset-tiles { grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 8px; }
  .asset-tile { padding: 10px; }
}

/* ---- Purdue architecture sketch (project page) ---- */
.arch-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.arch-canvas {
  position: relative; min-width: 720px; height: 860px;
  background: var(--bg-deep);
  border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; user-select: none; touch-action: none;
}
.arch-canvas.arch--connecting { cursor: crosshair; }
#arch-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#arch-svg .arch-cable {
  fill: none; stroke: var(--wood); stroke-width: 2; stroke-linecap: round;
  opacity: .85; transition: stroke .12s;
}
#arch-svg .arch-cable--hover { stroke: var(--red); opacity: 1; }
#arch-svg .arch-cable--ghost { stroke: var(--red); stroke-dasharray: 5 5; opacity: .8; }
#arch-svg .arch-cable-hit {
  fill: none; stroke: transparent; stroke-width: 14; pointer-events: stroke; cursor: pointer;
}
.arch-band {
  position: absolute; left: 0; right: 0;
  border-bottom: 1px dashed var(--border);
  pointer-events: none;
}
.arch-band:nth-child(odd) { background: rgba(255,255,255,.015); }
.arch-band--context {
  background: repeating-linear-gradient(45deg, transparent, transparent 7px, rgba(255,255,255,.025) 7px, rgba(255,255,255,.025) 9px);
}
.arch-band__label {
  position: absolute; top: 6px; left: 10px;
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--wood); opacity: .85;
}
.arch-band--context .arch-band__label { color: var(--muted); }
.arch-band__note {
  position: absolute; top: 6px; right: 10px;
  font-size: 10.5px; color: var(--muted); font-style: italic;
}
.arch-node {
  position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  width: 96px; cursor: grab; z-index: 5;
  transition: transform .12s;
}
.arch-node:hover { transform: translate(-50%, -50%) scale(1.05); z-index: 8; }
.arch-node--drag { cursor: grabbing; z-index: 10; }
.arch-node--drag .arch-node__shape,
.arch-node--source .arch-node__shape { filter: drop-shadow(0 0 7px rgba(207,32,48,.9)); }
.arch-node__shape {
  width: 74px; height: 58px; pointer-events: none;
  filter: drop-shadow(0 4px 7px rgba(0,0,0,.55));
}
.arch-node__shape svg { width: 100%; height: 100%; display: block; }
.arch-node__label {
  font-size: 11px; color: var(--text); white-space: nowrap;
  max-width: 110px; overflow: hidden; text-overflow: ellipsis;
  background: rgba(26, 23, 20, .78); padding: 1px 7px; border-radius: 4px;
  border-bottom: 1px dotted transparent; cursor: text; text-align: center;
}
.arch-node:hover .arch-node__label { border-bottom-color: var(--muted); }
.arch-node__rename {
  width: 110px; min-height: 0; padding: 1px 4px; font-size: 12px;
  background: var(--bg); border: 1px solid var(--red); border-radius: 4px; color: var(--text);
}
.arch-node__plug {
  position: absolute; top: -8px; right: 2px;
  min-width: 0; min-height: 0; width: 23px; height: 23px; padding: 0;
  border-radius: 50%; font-size: 13px; line-height: 1;
  background: var(--surface-alt); color: var(--wood);
  border: 1px solid var(--border);
  opacity: 0; transition: opacity .12s;
}
.arch-node:hover .arch-node__plug, .arch-node--source .arch-node__plug { opacity: 1; }
.arch-node__plug:hover { background: var(--red); color: #fff; border-color: var(--red); }
.arch-node--source .arch-node__plug { background: var(--red); color: #fff; border-color: var(--red); }
@media (max-width: 760px) {
  .arch-canvas { height: 480px; }
}

/* ---- stepper ([-] n [+], onboarding) ---- */
.stepper { display: inline-flex; align-items: stretch; }
.stepper__btn {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); width: 38px; min-height: 38px; min-width: 0;
  font-size: 17px; font-weight: 700; cursor: pointer; padding: 0; border-radius: 0;
}
.stepper__btn:first-child { border-radius: 5px 0 0 5px; }
.stepper__btn:last-child { border-radius: 0 5px 5px 0; }
.stepper__btn:hover { background: var(--red); color: #fff; }
.stepper__value {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-left: none; border-right: none;
  width: 54px; text-align: center; font-size: 14px; padding: 0; border-radius: 0;
}
.stepper__value:focus { outline: none; }

/* ---- empty state (projects dashboard) ---- */
.empty-state {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 48px 24px;
}
.empty-state__title { font-size: 16px; font-weight: 700; color: var(--text); margin-top: 20px; }
.empty-state__text { font-size: 13px; color: var(--muted); max-width: 340px; margin-top: 6px; line-height: 1.5; }

/* ---- responsive / mobile ---- */
@media (max-width: 760px) {
  .page { padding: 12px; }
  .topbar { padding: 8px 12px; gap: 8px; }
  .topbar .brand small { display: none; }
  .topbar .user { display: none; }
  .topbar input[type=text] { min-width: 130px; flex: 1 1 130px; }
  .totals { grid-template-columns: repeat(2, 1fr); }
  .total-card .value { font-size: 20px; }
  .asset-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; }
  .tabs button { white-space: nowrap; }
  /* tables scroll sideways instead of breaking the layout */
  .card table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .card table td:nth-child(2) { white-space: normal; min-width: 180px; }
  button { min-height: 38px; }
  .modal { padding: 14px; }
}
@media (max-width: 420px) {
  .totals { grid-template-columns: 1fr 1fr; gap: 8px; }
  .topbar .brand { font-size: 15px; }
}
