:root {
  color-scheme: light;
  --ink: #102b36;
  --muted: #617780;
  --line: #d9e6e3;
  --page: #f2f7f6;
  --surface: #ffffff;
  --teal: #0b6670;
  --teal-dark: #073f49;
  --green: #67c744;
  --good: #23845d;
  --warning: #ba7119;
  --danger: #ad3540;
  --info: #27768b;
  --shadow: 0 16px 42px rgba(16, 43, 54, .09);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--page); scroll-behavior: smooth; }
body { min-height: 100vh; margin: 0; color: var(--ink); background: var(--page); font: 15px/1.5 Inter, "Segoe UI", system-ui, sans-serif; }
button, input, select { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(103, 199, 68, .48); outline-offset: 3px; }
[hidden] { display: none !important; }
.skip-link { position: fixed; top: -100px; left: 18px; z-index: 100; padding: 10px 14px; color: #fff; background: var(--teal-dark); border-radius: 9px; }
.skip-link:focus { top: 12px; }

.demo-topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  min-height: 78px;
  padding: 11px clamp(18px, 4vw, 56px);
  background: rgba(255,255,255,.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.demo-brand { display: inline-flex; align-items: center; gap: 11px; width: fit-content; color: var(--ink); text-decoration: none; }
.brand-mark { display: block; width: 42px; height: 42px; object-fit: cover; border: 1px solid rgba(103,199,68,.45); border-radius: 12px; box-shadow: 0 10px 22px rgba(103,199,68,.24); }
.demo-brand strong, .demo-brand small, .admin-brand strong, .admin-brand small { display: block; }
.demo-brand strong { font-size: 17px; }
.demo-brand small { color: var(--muted); font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.view-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: #e8f0ee; border: 1px solid #d4e1de; border-radius: 14px; }
.view-switch-button { min-height: 43px; padding: 8px 15px; color: #4a646c; background: transparent; border: 0; border-radius: 10px; cursor: pointer; font-size: 13px; font-weight: 800; }
.view-switch-button span { margin-right: 5px; }
.view-switch-button.is-active { color: #fff; background: var(--teal); box-shadow: 0 8px 18px rgba(11,102,112,.22); }
.reset-button { justify-self: end; display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 7px 12px; color: var(--teal); background: #fff; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 12px; font-weight: 780; }
.reset-button:hover { border-color: #8ec8ba; background: #f7fbfa; }

.session-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 18px;
  color: #36575e;
  background: #e7f3ee;
  border-bottom: 1px solid #cde2da;
  font-size: 12px;
}
.session-dot { width: 8px; height: 8px; background: var(--good); border-radius: 50%; box-shadow: 0 0 0 4px rgba(35,132,93,.12); }

.demo-view { min-height: calc(100vh - 112px); }
.user-view { max-width: 1480px; margin: 0 auto; padding: clamp(24px, 4vw, 54px); }
.view-hero { display: flex; align-items: center; justify-content: space-between; gap: 36px; margin-bottom: 28px; }
.view-hero h1, .admin-hero h1 { margin: 4px 0 8px; font-size: clamp(31px, 4vw, 48px); line-height: 1.05; letter-spacing: -.045em; }
.view-hero p, .admin-hero p { max-width: 760px; margin: 0; color: var(--muted); }
.eyebrow { margin: 0; color: var(--teal); font-size: 10px; font-weight: 900; letter-spacing: .13em; text-transform: uppercase; }
.stick-visual {
  position: relative;
  flex: 0 0 190px;
  display: grid;
  align-content: center;
  min-height: 96px;
  padding: 18px 28px;
  color: #fff;
  background: linear-gradient(145deg, #0b6771, #082f3a);
  border-radius: 22px 8px 8px 22px;
  box-shadow: 0 22px 44px rgba(8,63,73,.24);
}
.stick-brand-image { display: block; width: 38px; height: 38px; margin-bottom: 3px; border-radius: 9px; box-shadow: 0 7px 18px rgba(0,0,0,.2); }
.stick-visual small { color: #b8d5d5; font-size: 10px; }
.stick-visual i { position: absolute; right: -31px; width: 39px; height: 42px; background: linear-gradient(#b4c2c4 0 32%, #ecf2f2 32% 66%, #aab9bb 66%); border-radius: 0 5px 5px 0; }
.stick-led { position: absolute; top: 13px; right: 14px; width: 8px; height: 8px; background: #7bec5e; border-radius: 50%; box-shadow: 0 0 12px #7bec5e; }

.device-overview { display: grid; grid-template-columns: minmax(480px, 1.25fr) minmax(350px, .75fr); gap: 16px; }
.health-card, .mini-metrics, .panel, .issue-card, .admin-metrics article, .admin-actions button { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.health-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 22px; padding: 22px; }
.health-card h2 { margin: 4px 0; font-size: clamp(20px, 2vw, 27px); }
.health-card p { margin: 0; color: var(--muted); }
.health-score { --score: 64; display: grid; place-items: center; width: 112px; height: 112px; background: conic-gradient(var(--warning) calc(var(--score) * 1%), #e5eeec 0); border-radius: 50%; transition: background .4s ease; }
.health-score::before { grid-area: 1/1; width: 86px; height: 86px; content: ""; background: #fff; border-radius: 50%; }
.health-score span { z-index: 1; grid-area: 1/1; text-align: center; }
.health-score strong { display: block; font-size: 28px; line-height: 1; }
.health-score small { color: var(--muted); }
.primary-button, .card-action, .text-button { border: 0; cursor: pointer; font-weight: 800; }
.primary-button { min-height: 45px; padding: 10px 17px; color: #fff; background: var(--teal); border-radius: 11px; box-shadow: 0 9px 20px rgba(11,102,112,.2); }
.primary-button:hover { background: var(--teal-dark); transform: translateY(-1px); }
.mini-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; overflow: hidden; background: var(--line); }
.mini-metrics article { display: flex; align-items: center; gap: 12px; min-height: 91px; padding: 16px; background: #fff; }
.mini-metrics small, .mini-metrics strong { display: block; }
.mini-metrics small { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.mini-metrics strong { margin-top: 2px; font-size: 13px; }
.metric-icon { display: grid; place-items: center; width: 34px; height: 34px; color: var(--info); background: #e4f1f4; border-radius: 10px; font-weight: 900; }
.metric-icon.good { color: var(--good); background: #e0f3e9; }
.metric-icon.warning { color: var(--warning); background: #fff0ce; }
.metric-icon.danger { color: var(--danger); background: #fbe4e6; }

.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin: 34px 0 14px; }
.section-heading h2, .panel-heading h2 { margin: 3px 0 0; font-size: 23px; }
.issue-count, .live-badge, .simulation-badge { display: inline-flex; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 10px; font-weight: 850; text-transform: uppercase; }
.issue-count { color: #8a2c35; background: #fbe5e7; }
.issue-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; }
.issue-card { position: relative; display: flex; flex-direction: column; min-height: 315px; padding: 20px; overflow: hidden; }
.issue-card::before { position: absolute; inset: 0 auto 0 0; width: 4px; content: ""; background: var(--warning); }
.issue-card.danger::before { background: var(--danger); }
.issue-card.resolved::before { background: var(--good); }
.issue-card header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.issue-symbol { display: grid; place-items: center; width: 39px; height: 39px; color: #fff; background: var(--teal); border-radius: 12px; font-weight: 950; }
.issue-card h3 { margin: 18px 0 6px; font-size: 20px; }
.issue-card > p { margin: 0; color: var(--muted); }
.issue-card dl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 17px 0; }
.issue-card dl div { padding: 10px; background: #f6f9f8; border-radius: 9px; }
.issue-card dt { color: var(--muted); font-size: 9px; font-weight: 800; text-transform: uppercase; }
.issue-card dd { margin: 2px 0 0; font-weight: 780; }
.state-chip { display: inline-flex; padding: 5px 8px; color: #36575e; background: #e7eeee; border-radius: 999px; font-size: 9px; font-weight: 900; text-transform: uppercase; }
.state-chip.warning { color: #84550d; background: #fff0c8; }
.state-chip.danger { color: #922e38; background: #fbe4e6; }
.state-chip.good { color: #176744; background: #dff3e8; }
.card-action { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 43px; margin-top: auto; padding: 9px 13px; color: var(--teal); background: #edf6f3; border-radius: 10px; }
.card-action:hover { background: #dfeee9; }
.card-action:disabled { cursor: default; opacity: .6; }

.user-lower-grid { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; margin-top: 18px; }
.panel { padding: 20px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 13px; margin-bottom: 14px; }
.quick-action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.quick-action-grid button { display: grid; grid-template-columns: auto 1fr; column-gap: 11px; padding: 13px; text-align: left; background: #f7faf9; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; }
.quick-action-grid button:hover { background: #edf6f3; border-color: #9fcfc1; transform: translateY(-1px); }
.quick-action-grid button > span { grid-row: span 2; display: grid; place-items: center; width: 36px; height: 36px; color: #fff; background: var(--teal); border-radius: 10px; font-size: 18px; }
.quick-action-grid strong, .quick-action-grid small { display: block; }
.quick-action-grid small { color: var(--muted); }
.live-badge { gap: 5px; color: var(--good); background: #e0f3e9; }
.live-badge::before { width: 6px; height: 6px; content: ""; background: currentColor; border-radius: 50%; animation: pulse 1.6s infinite; }
.event-list { max-height: 270px; margin: 0; padding: 0; overflow: auto; list-style: none; }
.event-list li { display: flex; align-items: flex-start; gap: 11px; padding: 10px 2px; border-bottom: 1px solid #e7eeee; }
.event-list li:last-child { border: 0; }
.event-list strong, .event-list small { display: block; }
.event-list strong { font-size: 13px; }
.event-list small { margin-top: 2px; color: var(--muted); font-size: 11px; }
.event-dot { flex: 0 0 auto; width: 9px; height: 9px; margin-top: 5px; background: var(--info); border-radius: 50%; box-shadow: 0 0 0 4px rgba(39,118,139,.1); }
.event-dot.good { background: var(--good); box-shadow: 0 0 0 4px rgba(35,132,93,.1); }
.event-dot.warning { background: var(--warning); box-shadow: 0 0 0 4px rgba(186,113,25,.1); }

.admin-shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: calc(100vh - 112px); }
.admin-sidebar { position: sticky; top: 112px; display: flex; flex-direction: column; height: calc(100vh - 112px); padding: 24px 15px; color: #e7f3f1; background: linear-gradient(180deg, #0b5661, #082e38); }
.admin-brand { display: flex; align-items: center; gap: 11px; padding: 0 5px; }
.admin-brand small { color: #aac8c8; font-size: 10px; }
.simulation-badge { width: fit-content; margin: 18px 5px; color: #dcffd4; background: rgba(103,199,68,.13); border: 1px solid rgba(103,199,68,.25); }
.admin-sidebar nav { display: grid; gap: 4px; }
.admin-sidebar nav button { display: flex; justify-content: space-between; min-height: 41px; padding: 9px 11px; color: #d5e6e6; text-align: left; background: transparent; border: 0; border-radius: 10px; cursor: pointer; font-weight: 700; }
.admin-sidebar nav button:hover, .admin-sidebar nav button.is-active { color: #fff; background: rgba(255,255,255,.1); }
.admin-sidebar nav button.is-active { box-shadow: inset 3px 0 var(--green); }
.admin-sidebar nav span { min-width: 22px; padding: 1px 6px; color: #092f37; background: var(--green); border-radius: 999px; text-align: center; font-size: 10px; }
.admin-sidebar-note { margin-top: auto; padding: 14px 5px 0; color: #9db8bc; border-top: 1px solid rgba(255,255,255,.12); }
.admin-workspace { min-width: 0; padding: clamp(24px, 3vw, 42px); }
.admin-hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; }
.admin-hero h1 { font-size: clamp(29px, 3.5vw, 43px); }
.admin-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin: 25px 0 16px; }
.admin-metrics article { min-height: 127px; padding: 18px; border-top: 4px solid var(--good); }
.admin-metrics article.warning { border-top-color: var(--warning); }
.admin-metrics article.danger { border-top-color: var(--danger); }
.admin-metrics span, .admin-metrics small { color: var(--muted); }
.admin-metrics span { font-size: 10px; font-weight: 850; text-transform: uppercase; }
.admin-metrics strong { display: block; margin: 8px 0 2px; font-size: 33px; }
.admin-actions { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 9px; margin-bottom: 16px; }
.admin-actions button { min-height: 132px; padding: 14px; text-align: left; cursor: pointer; }
.admin-actions button:hover { border-color: #94c8ba; transform: translateY(-2px); box-shadow: 0 18px 40px rgba(16,43,54,.12); }
.admin-actions strong, .admin-actions small { display: block; }
.admin-actions strong { margin: 11px 0 3px; font-size: 13px; }
.admin-actions small { color: var(--muted); font-size: 10px; }
.action-icon { display: grid; place-items: center; width: 34px; height: 34px; color: #fff; background: var(--teal); border-radius: 10px; font-size: 17px; font-weight: 900; }
.admin-grid { display: grid; grid-template-columns: minmax(560px, 1.35fr) minmax(280px, .65fr); gap: 16px; }
.text-button { color: var(--teal); background: transparent; }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); background: #f7faf9; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
td { font-size: 12px; }
td strong, td small { display: block; }
td small { color: var(--muted); }
.row-action { padding: 5px 8px; color: var(--teal); background: #edf6f3; border: 0; border-radius: 8px; cursor: pointer; font-size: 10px; font-weight: 800; }

.operation-dock { position: fixed; right: 24px; bottom: 24px; z-index: 80; display: grid; grid-template-columns: auto minmax(240px, 1fr) auto; align-items: center; gap: 14px; width: min(520px, calc(100vw - 32px)); padding: 15px; color: #fff; background: #092f39; border: 1px solid rgba(255,255,255,.15); border-radius: 16px; box-shadow: 0 24px 60px rgba(5,35,42,.35); }
.operation-icon { display: grid; place-items: center; width: 40px; height: 40px; background: rgba(103,199,68,.14); border-radius: 12px; }
.operation-icon span { width: 19px; height: 19px; border: 3px solid rgba(255,255,255,.3); border-top-color: var(--green); border-radius: 50%; animation: spin .85s linear infinite; }
.operation-copy strong, .operation-copy small { display: block; }
.operation-copy small { margin-top: 2px; color: #bcd2d2; font-size: 11px; }
.progress-track { height: 6px; margin-top: 9px; overflow: hidden; background: rgba(255,255,255,.14); border-radius: 999px; }
.progress-track span { display: block; width: 0; height: 100%; background: linear-gradient(90deg, var(--teal), var(--green)); border-radius: inherit; transition: width .35s ease; }
.operation-percent { font-size: 12px; }

.demo-dialog { width: min(620px, calc(100vw - 28px)); padding: 0; color: var(--ink); background: #fff; border: 0; border-radius: 20px; box-shadow: 0 30px 90px rgba(5,35,42,.35); }
.demo-dialog::backdrop { background: rgba(5,33,40,.62); backdrop-filter: blur(4px); }
.dialog-shell { margin: 0; }
.dialog-shell > header, .dialog-shell > footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 19px 22px; }
.dialog-shell > header { border-bottom: 1px solid var(--line); }
.dialog-shell > footer { justify-content: flex-end; background: #f7faf9; border-top: 1px solid var(--line); }
.dialog-shell h2 { margin: 2px 0 0; font-size: 24px; }
.dialog-close { width: 36px; height: 36px; color: var(--muted); background: #edf2f1; border: 0; border-radius: 10px; cursor: pointer; font-size: 23px; }
.dialog-content { padding: 22px; }
.dialog-content > p:first-child { margin-top: 0; }
.dialog-note { padding: 11px 13px; color: #425f66; background: #edf5f3; border-radius: 10px; font-size: 12px; }
.dialog-warning { padding: 12px 13px; color: #7d4d09; background: #fff1cf; border: 1px solid #f0d48f; border-radius: 10px; font-size: 12px; }
.dialog-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.dialog-form-grid label { display: grid; gap: 5px; color: #36535b; font-size: 11px; font-weight: 750; }
.dialog-form-grid label.full { grid-column: 1/-1; }
.dialog-form-grid input, .dialog-form-grid select { width: 100%; min-height: 43px; padding: 9px 11px; color: var(--ink); background: #fff; border: 1px solid #c9d9d6; border-radius: 9px; }
.dialog-summary { display: grid; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.dialog-summary li { display: flex; justify-content: space-between; gap: 15px; padding: 9px 11px; background: #f6f9f8; border-radius: 9px; }
.secondary-button { min-height: 40px; padding: 8px 13px; color: var(--teal); background: #fff; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; font-weight: 800; }
.danger-button { min-height: 40px; padding: 8px 13px; color: #fff; background: var(--danger); border: 0; border-radius: 9px; cursor: pointer; font-weight: 800; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 90; min-width: min(420px, calc(100vw - 30px)); padding: 12px 17px; color: #fff; background: #143e47; border-radius: 12px; box-shadow: 0 18px 44px rgba(5,35,42,.25); text-align: center; transform: translateX(-50%); font-weight: 750; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }

@media (max-width: 1200px) {
  .device-overview, .admin-grid { grid-template-columns: 1fr; }
  .admin-actions { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .demo-topbar { grid-template-columns: 1fr auto; }
  .view-switch { grid-column: 1/-1; grid-row: 2; }
  .session-notice { align-items: flex-start; flex-wrap: wrap; }
  .issue-grid { grid-template-columns: 1fr; }
  .user-lower-grid { grid-template-columns: 1fr; }
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { position: static; height: auto; }
  .admin-sidebar nav { grid-template-columns: repeat(5, minmax(120px, 1fr)); overflow: auto; }
  .admin-sidebar-note { margin-top: 16px; }
  .admin-metrics { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 650px) {
  .demo-topbar { padding: 10px 14px; }
  .reset-button span:last-child { display: none; }
  .view-switch-button { padding: 8px 9px; font-size: 11px; }
  .session-notice span:last-child { flex-basis: 100%; padding-left: 16px; }
  .user-view, .admin-workspace { padding: 22px 14px; }
  .view-hero, .admin-hero { align-items: flex-start; flex-direction: column; }
  .stick-visual { align-self: center; width: calc(100% - 38px); }
  .health-card { grid-template-columns: auto 1fr; }
  .health-card .primary-button { grid-column: 1/-1; width: 100%; }
  .health-score { width: 88px; height: 88px; }
  .health-score::before { width: 68px; height: 68px; }
  .health-score strong { font-size: 23px; }
  .mini-metrics, .quick-action-grid, .admin-metrics, .admin-actions { grid-template-columns: 1fr; }
  .admin-sidebar nav { grid-template-columns: 1fr 1fr; }
  .operation-dock { right: 16px; bottom: 16px; grid-template-columns: auto 1fr; }
  .operation-percent { display: none; }
  .dialog-form-grid { grid-template-columns: 1fr; }
  .dialog-form-grid label.full { grid-column: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
