:root {
  --blue: #168fc5;
  --blue-dark: #087bb1;
  --ink: #10282f;
  --muted: #667c84;
  --subtle: #87999f;
  --line: #dbe6e8;
  --bg: #f3f7f7;
  --surface: #ffffff;
  --green: #18ae7a;
  --orange: #ed913a;
  --red: #df5b52;
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --shadow: 0 12px 32px rgba(19, 53, 62, .08);
}

* { box-sizing: border-box; }
html { background: #dce8eb; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: #dce8eb; color: var(--ink); font-family: "DM Sans", sans-serif; font-size: 16px; line-height: 1.45; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, [role="link"]:focus-visible { outline: 3px solid rgba(22, 143, 197, .3); outline-offset: 3px; }

.app-shell {
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: auto;
  padding: max(24px, env(safe-area-inset-top)) 22px calc(116px + env(safe-area-inset-bottom));
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

.topbar { display: flex; align-items: center; justify-content: space-between; animation: settle-in .45s var(--ease-out) both; }
.brand { display: flex; align-items: center; gap: 10px; color: #11262f; font: 26px/.78 Outfit, sans-serif; letter-spacing: -1px; }
.brand strong { color: #2798cb; }
.brand em { font-style: normal; font-weight: 800; }
.brand small { display: block; margin: 8px 0 0 4px; color: #2798cb; font-size: 9px; letter-spacing: 5.5px; text-align: center; }
.brand-mark { width: 36px; height: 39px; position: relative; display: block; }
.brand-mark::before { content: ""; position: absolute; width: 21px; height: 27px; left: 8px; top: 1px; border: 3px solid #e2ae22; border-radius: 18px 2px 18px 2px; transform: rotate(42deg); }
.brand-mark::after { content: ""; position: absolute; width: 25px; height: 2px; left: 1px; top: 23px; background: #e2ae22; transform: rotate(-37deg); }
.brand-mark i, .brand-mark b { position: absolute; z-index: 2; width: 3px; height: 3px; border-radius: 50%; background: #e2ae22; }
.brand-mark i { top: 15px; left: 18px; }
.brand-mark b { top: 21px; left: 25px; }

.icon-button, .add-button, .detail-topbar > a, .detail-topbar > button, .more {
  min-width: 48px;
  min-height: 48px;
  border: 0;
  display: grid;
  place-items: center;
}
.icon-button { width: 50px; height: 50px; position: relative; border-radius: 17px; background: var(--surface); box-shadow: 0 7px 24px rgba(25, 57, 66, .09); }
.icon-button .lucide { width: 24px; height: 24px; stroke-width: 2.15; }
.notification .lucide { animation: bell-in .65s .45s var(--ease-out) both; transform-origin: 50% 10%; }
.badge { position: absolute; top: -4px; right: -3px; display: grid; place-items: center; width: 21px; height: 21px; border: 3px solid var(--bg); border-radius: 50%; color: white; background: var(--red); font-size: 11px; line-height: 1; font-weight: 800; }

.welcome { padding: 38px 2px 24px; animation: settle-in .5s .06s var(--ease-out) both; }
.eyebrow { margin: 0 0 9px; color: #6d8c94; font-size: 12px; line-height: 1.3; font-weight: 800; letter-spacing: 1.7px; }
.headline-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.headline-row h1 { margin: 0; font: 750 36px/1.05 Outfit, sans-serif; letter-spacing: -1.1px; }
.headline-row p { margin: 10px 0 0; color: var(--muted); font-size: 16px; }
.add-button { flex: 0 0 auto; width: 54px; height: 54px; border-radius: 18px; color: white; background: linear-gradient(145deg, #27a6d9, var(--blue)); box-shadow: 0 12px 24px rgba(28, 155, 210, .28); transition: transform .18s var(--ease-out), box-shadow .18s var(--ease-out); }
.add-button .lucide { width: 29px; height: 29px; stroke-width: 2.2; }

.overview-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; padding: 14px 16px; border: 1px solid #caeadf; border-radius: 18px; background: #e5f6f0; font-size: 14px; animation: settle-in .5s .12s var(--ease-out) both; }
.overview-card > div { display: flex; align-items: center; }
.overview-card strong { font-size: 15px; }
.status-dot { display: inline-block; width: 10px; height: 10px; margin-right: 10px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px #bce8da; animation: status-pulse 2.6s 1.2s ease-out infinite; }
.updated { color: #64847c; font-size: 13px; white-space: nowrap; }

.devices { margin-top: 36px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 2px 15px; }
.section-heading h2, .chart-card h2, .detail-actions h2, .event-list h2 { margin: 0; font: 750 21px/1.2 Outfit, sans-serif; letter-spacing: -.25px; }
.section-heading button, .alert-card button { min-height: 44px; margin: -8px -8px -8px 0; padding: 8px; border: 0; display: inline-flex; align-items: center; gap: 2px; color: var(--blue-dark); background: transparent; font-size: 14px; font-weight: 750; }
.section-heading button .lucide, .alert-card button .lucide { width: 18px; height: 18px; stroke-width: 2.4; }

.device-card { margin-bottom: 18px; padding: 20px 18px 16px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); transition: transform .2s var(--ease-out), box-shadow .2s var(--ease-out), border-color .2s; }
.device-card:nth-of-type(1) { animation: card-in .55s .17s var(--ease-out) both; }
.device-card:nth-of-type(2) { animation: card-in .55s .25s var(--ease-out) both; }
.device-card.warning { border-top: 4px solid var(--orange); }
.device-card.healthy { border-top: 4px solid var(--green); }
.device-card-top { display: flex; align-items: center; gap: 14px; }
.device-icon { width: 54px; height: 58px; position: relative; flex: 0 0 auto; border-radius: 15px; }
.device-icon.display { background: linear-gradient(140deg, #3b535d, #192f38); }
.device-icon.display::before { content: ""; position: absolute; inset: 8px 7px 15px; border-radius: 5px; background: linear-gradient(145deg, #36b4e6, #269bcf); }
.device-icon.display::after { content: ""; position: absolute; bottom: 7px; left: 18px; width: 18px; height: 3px; border-radius: 4px; background: #a3bec4; }
.device-icon.sensor { border-radius: 10px; background: #31454c; }
.device-icon.sensor::before { content: ""; position: absolute; inset: 7px 9px 9px; border-radius: 4px; background: linear-gradient(145deg, #69cdec, #48b5db); }
.device-icon.sensor::after { content: ""; position: absolute; top: 6px; right: 5px; width: 9px; height: 9px; border: 2px solid white; border-radius: 50%; background: #20cf7a; }
.device-title { min-width: 0; flex: 1; }
.name-line { display: flex; align-items: center; gap: 8px; }
.device-title h3 { margin: 0; overflow: hidden; display: -webkit-box; font: 750 20px/1.2 Outfit, sans-serif; letter-spacing: -.25px; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.device-title p { margin: 6px 0 0; color: var(--subtle); font-size: 13px; }
.device-title p span { padding: 0 4px; color: #c0cbce; }
.alert-icon { width: 21px; height: 21px; flex: 0 0 auto; border-radius: 50%; color: #df7444; background: #fff0e8; font-size: 13px; line-height: 21px; text-align: center; font-weight: 800; }
.online { padding: 5px 8px; border-radius: 8px; color: #128b61; background: #e1f6ed; font-size: 12px; line-height: 1; font-weight: 800; }
.more { width: 48px; height: 48px; margin: -8px -10px -8px 0; border-radius: 15px; color: #8da0a5; background: transparent; }
.more .lucide { width: 23px; height: 23px; }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); margin: 22px 0 18px; }
.metric { min-width: 0; padding-left: 15px; border-left: 1px solid var(--line); }
.metric:first-child { padding-left: 0; border: 0; }
.metric span, .metric small { display: block; color: #768a91; font-size: 13px; }
.metric strong { display: block; font: 750 28px/1.25 Outfit, sans-serif; letter-spacing: -.6px; }
.metric.critical strong, .metric.critical small { color: var(--red); }

.device-card footer { min-height: 50px; padding-top: 14px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.device-card footer > span { font-size: 13px; font-weight: 700; }
.warning-label { color: #c96e2d; }
.success-label { color: #248e6a; }
.device-card footer > span i { width: 17px; height: 17px; margin-right: 5px; display: inline-grid; place-items: center; border-radius: 50%; color: white; background: currentColor; font-size: 10px; font-style: normal; }
.device-link { min-height: 42px; padding: 9px 11px; display: inline-flex; align-items: center; gap: 6px; border-radius: 12px; color: var(--blue-dark); background: #e7f5fb; font-size: 13px; line-height: 1; font-weight: 800; text-decoration: none; transition: background .18s, transform .18s; }
.device-link .lucide { width: 16px; height: 16px; stroke-width: 2.5; }

.discover { width: 100%; min-height: 78px; margin-top: 4px; padding: 16px; border: 1px dashed #8fc4d8; border-radius: 20px; display: flex; align-items: center; gap: 14px; color: #17698d; background: #eaf7fb; text-align: left; animation: card-in .55s .33s var(--ease-out) both; transition: transform .18s var(--ease-out), background .18s; }
.discover .scan-icon { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 14px; color: var(--blue-dark); background: #d7eef7; }
.discover .scan-icon .lucide { width: 23px; height: 23px; }
.discover strong, .discover small { display: block; }
.discover strong { font-size: 15px; }
.discover small { margin-top: 3px; color: #648a9a; font-size: 12px; }
.discover b { width: 38px; height: 38px; margin-left: auto; display: grid; place-items: center; color: var(--blue); font-weight: 400; }
.discover b .lucide { width: 22px; height: 22px; }

.bottom-nav { width: min(100%, 480px); height: calc(88px + env(safe-area-inset-bottom)); position: fixed; z-index: 10; bottom: 0; left: 50%; padding: 10px 28px max(10px, env(safe-area-inset-bottom)); border-top: 1px solid rgba(214, 227, 230, .88); display: flex; justify-content: space-around; background: rgba(255, 255, 255, .94); box-shadow: 0 -10px 32px rgba(22, 54, 62, .07); backdrop-filter: blur(18px); transform: translateX(-50%); }
.bottom-nav.two-items { justify-content: center; gap: min(18vw, 92px); }
.bottom-nav button, .bottom-nav a { min-width: 84px; min-height: 58px; padding: 7px 10px; border: 0; border-radius: 17px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: #84969c; background: transparent; font-size: 12px; line-height: 1; font-weight: 650; text-decoration: none; transition: color .18s, background .18s, transform .18s; }
.bottom-nav .lucide { width: 24px; height: 24px; stroke: currentColor; stroke-width: 2; }
.bottom-nav .active { color: var(--blue-dark); background: #e3f4fa; font-weight: 800; }

.detail-shell { padding-top: max(22px, env(safe-area-inset-top)); }
.detail-topbar { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; animation: settle-in .45s var(--ease-out) both; }
.detail-topbar > a, .detail-topbar > button { width: 48px; height: 48px; border-radius: 16px; color: #18333b; background: var(--surface); box-shadow: 0 6px 22px rgba(24, 57, 66, .08); text-decoration: none; }
.detail-topbar .lucide { width: 23px; height: 23px; }
.device-header-name { min-width: 0; padding: 0 10px; text-align: center; }
.device-header-name p { margin: 0 0 4px; color: #6f8e96; font-size: 11px; font-weight: 800; letter-spacing: 1.5px; }
.device-header-name h1 { margin: 0; overflow: hidden; font: 750 21px/1.2 Outfit, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.connection-row { min-height: 62px; padding: 18px 3px 14px; display: flex; align-items: center; justify-content: space-between; gap: 12px; color: #70838a; font-size: 13px; animation: settle-in .45s .05s var(--ease-out) both; }
.connection-row > span:first-child { color: #23755f; font-size: 14px; font-weight: 800; }
.connection-row i { display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; background: var(--green); }
.connection-row b { margin: 0 5px; color: #c0cbce; }

.alert-card { min-height: 88px; padding: 16px; border: 1px solid #ffd8c0; border-radius: 21px; display: flex; align-items: center; gap: 13px; background: #fff0e7; animation: card-in .5s .1s var(--ease-out) both; }
.alert-symbol { width: 46px; height: 46px; flex: 0 0 auto; border-radius: 15px; display: grid; place-items: center; color: white; background: #ef8f53; }
.alert-symbol .lucide { width: 23px; height: 23px; }
.alert-card div:nth-child(2) { flex: 1; }
.alert-card strong { font-size: 15px; line-height: 1.25; }
.alert-card p { margin: 4px 0 0; color: #9c6448; font-size: 13px; line-height: 1.35; }
.alert-card button { flex: 0 0 auto; color: #c9662f; }

.value-overview { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 20px 0; }
.value-card { min-width: 0; min-height: 120px; padding: 16px 13px; border: 1px solid var(--line); border-radius: 19px; background: var(--surface); box-shadow: 0 7px 24px rgba(23, 56, 65, .05); animation: card-in .5s var(--ease-out) both; }
.value-card:nth-child(1) { animation-delay: .16s; }
.value-card:nth-child(2) { animation-delay: .22s; }
.value-card:nth-child(3) { animation-delay: .28s; }
.value-card span, .value-card small { display: block; color: #6e838a; font-size: 13px; }
.value-card strong { display: block; margin-top: 5px; font: 750 29px/1.2 Outfit, sans-serif; letter-spacing: -.6px; }
.value-card.critical { border-color: #ffd7d3; background: #fffafa; }
.value-card.critical strong { color: var(--red); }

.chart-card { padding: 20px 17px 23px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); box-shadow: var(--shadow); animation: card-in .55s .31s var(--ease-out) both; }
.chart-card header { display: flex; align-items: flex-start; justify-content: space-between; }
.chart-card .eyebrow { margin-bottom: 5px; font-size: 11px; }
.period-button { min-height: 44px; padding: 10px 12px; border: 1px solid #d5e3e6; border-radius: 13px; display: inline-flex; align-items: center; gap: 6px; color: #4b6871; background: white; font-size: 13px; font-weight: 650; }
.period-button .lucide { width: 16px; height: 16px; stroke-width: 2.3; }
.chart-key { margin: 16px 0 12px; color: #6e8289; font-size: 13px; }
.line-key, .limit-key { width: 18px; height: 3px; margin: 0 5px 2px 0; display: inline-block; border-radius: 4px; background: var(--red); }
.limit-key { margin-left: 14px; border-top: 2px dashed #efaa9d; background: transparent; }
.chart { height: 190px; display: flex; }
.axis { width: 34px; padding-bottom: 17px; display: flex; flex-direction: column; justify-content: space-between; color: #899ba1; font-size: 11px; }
.plot { position: relative; flex: 1; border-left: 1px solid #dce7e9; border-bottom: 1px solid #dce7e9; background: repeating-linear-gradient(to bottom, transparent 0, transparent 36px, #edf2f3 37px); }
.target-band { position: absolute; top: 63px; right: 0; left: 0; height: 46px; background: #ebf7f2; }
.plot svg { width: 100%; height: calc(100% - 17px); position: absolute; inset: 0 0 17px; overflow: visible; }
.plot svg path { stroke-dasharray: 500; stroke-dashoffset: 500; animation: draw-line 1.15s .55s var(--ease-out) forwards; }
.plot svg circle { opacity: 0; transform-box: fill-box; transform-origin: center; animation: point-in .35s 1.55s var(--ease-out) forwards; }
.times { position: absolute; right: -3px; bottom: -18px; left: -3px; display: flex; justify-content: space-between; color: #899ba1; font-size: 10px; }

.detail-actions { margin: 32px 0 28px; animation: settle-in .5s .38s var(--ease-out) both; }
.action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 15px; }
.action-grid button { min-height: 122px; padding: 14px 11px; border: 1px solid var(--line); border-radius: 19px; background: var(--surface); text-align: left; transition: transform .18s var(--ease-out), border-color .18s, box-shadow .18s; }
.action-icon { width: 38px; height: 38px; margin-bottom: 11px; border-radius: 12px; display: grid; place-items: center; color: var(--blue); background: #e3f4fa; }
.action-icon .lucide { width: 20px; height: 20px; }
.action-icon.calibration { color: #178e66; background: #e5f5ee; }
.action-grid strong, .action-grid small { display: block; }
.action-grid strong { font-size: 14px; }
.action-grid small { margin-top: 4px; color: #74878e; font-size: 12px; }

.event-list { animation: settle-in .5s .44s var(--ease-out) both; }
.event-list .section-heading { margin-bottom: 12px; }
.event-list article { min-height: 72px; padding: 14px; border: 1px solid var(--line); border-bottom: 0; display: flex; align-items: center; gap: 12px; background: var(--surface); }
.event-list article:first-of-type { border-radius: 19px 19px 0 0; }
.event-list article:last-child { border-bottom: 1px solid var(--line); border-radius: 0 0 19px 19px; }
.event-dot { width: 36px; height: 36px; flex: 0 0 auto; border-radius: 12px; display: grid; place-items: center; }
.event-dot .lucide { width: 18px; height: 18px; stroke-width: 2.5; }
.warning-dot { color: #d56d35; background: #fff0e7; }
.success-dot { color: #198f66; background: #e3f6ed; }
.event-list article div { flex: 1; }
.event-list article strong { font-size: 14px; }
.event-list article p { margin: 4px 0 0; color: #798c92; font-size: 12px; }
.event-list article > b { color: var(--red); font: 750 20px Outfit, sans-serif; }

@media (hover: hover) {
  .device-card:hover { border-color: #cbdadd; box-shadow: 0 16px 38px rgba(19, 53, 62, .12); transform: translateY(-3px); }
  .add-button:hover { box-shadow: 0 15px 28px rgba(28, 155, 210, .34); transform: translateY(-2px); }
  .action-grid button:hover { border-color: #c5d8dc; box-shadow: 0 10px 26px rgba(20, 53, 62, .08); transform: translateY(-2px); }
  .discover:hover { background: #dff3fa; transform: translateY(-2px); }
}

button:active, a:active, [role="link"]:active, .device-link:active { transform: scale(.97); }

@keyframes settle-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes card-in { from { opacity: 0; transform: translateY(18px) scale(.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes bell-in { 0% { opacity: 0; transform: rotate(0) scale(.8); } 45% { opacity: 1; transform: rotate(13deg) scale(1.06); } 70% { transform: rotate(-9deg); } 100% { opacity: 1; transform: rotate(0) scale(1); } }
@keyframes status-pulse { 0%, 42%, 100% { box-shadow: 0 0 0 5px #bce8da; } 18% { box-shadow: 0 0 0 8px rgba(188, 232, 218, .15); } }
@keyframes draw-line { to { stroke-dashoffset: 0; } }
@keyframes point-in { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: scale(1); } }

@media (min-width: 481px) {
  .app-shell { box-shadow: 0 0 70px rgba(34, 70, 78, .2); }
}

@media (max-width: 380px) {
  .app-shell { padding-right: 17px; padding-left: 17px; }
  .headline-row h1 { font-size: 33px; }
  .device-title h3 { font-size: 18px; }
  .metric { padding-left: 11px; }
  .metric strong { font-size: 25px; }
  .alert-card p { font-size: 12px; }
  .value-card { padding: 14px 10px; }
  .value-card strong { font-size: 26px; }
  .action-grid { gap: 7px; }
  .action-grid button { padding: 13px 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-delay: 0ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
