:root {
  color-scheme: light;
  --ink: #182034;
  --muted: #69748b;
  --line: #e2e7f0;
  --surface: #ffffff;
  --background: #f3f5fa;
  --primary: #315efb;
  --primary-dark: #2447c8;
  --navy: #111a31;
  --green: #15845f;
  --amber: #a35a08;
  --red: #c9384d;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: var(--background); color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid #9db2ff; outline-offset: 2px; }
h1, h2, p { margin-top: 0; }
h1 { font-size: clamp(28px, 4vw, 40px); letter-spacing: -.04em; margin-bottom: 8px; }
h2 { margin-bottom: 0; letter-spacing: -.025em; }
.muted { color: var(--muted); line-height: 1.55; }
.eyebrow { color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; margin-bottom: 10px; }
.login-layout { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 0%, #243b78 0, transparent 45%), var(--navy); }
.login-card { width: min(430px, 100%); background: var(--surface); border-radius: 24px; padding: 38px; box-shadow: 0 30px 80px #050a1866; }
.login-card h1 { margin-bottom: 12px; }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px; background: var(--primary); color: white; font-weight: 900; font-size: 25px; margin-bottom: 24px; }
.brand-mark.small { width: 34px; height: 34px; border-radius: 10px; font-size: 17px; margin: 0; }
label { display: block; font-size: 13px; font-weight: 700; margin: 18px 0 7px; }
input, select { width: 100%; border: 1px solid #ccd4e3; background: white; color: var(--ink); border-radius: 10px; padding: 11px 12px; }
input[type="range"] { padding: 0; accent-color: var(--primary); }
.button { border: 1px solid transparent; border-radius: 9px; padding: 9px 13px; font-size: 13px; font-weight: 700; transition: background .18s, border-color .18s; }
.button.primary { background: var(--primary); color: white; }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { background: #eef2ff; color: #2949ba; border-color: #dce4ff; }
.button.ghost { background: #ffffff12; color: white; border-color: #ffffff2c; }
.button.danger { background: #fff1f3; color: var(--red); border-color: #ffd5dc; }
.button.wide { width: 100%; padding: 12px; margin-top: 22px; }
.form-error { min-height: 20px; color: var(--red); font-size: 13px; margin: 14px 0 0; }
.topbar { background: var(--navy); color: white; }
.topbar-inner { max-width: 1640px; margin: auto; min-height: 66px; padding: 10px 28px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 800; letter-spacing: -.02em; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.connection { display: inline-flex; align-items: center; gap: 7px; color: #d7def1; font-size: 12px; margin-right: 8px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #f4b952; }
.connection.online .status-dot { background: #54daa7; }
.connection.offline .status-dot { background: #ff7587; }
.page-content { max-width: 1640px; margin: auto; padding: 34px 28px 50px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 25px; }
.page-heading .muted { margin-bottom: 0; }
.summary { display: flex; gap: 10px; }
.summary > div { background: white; border: 1px solid var(--line); min-width: 100px; padding: 13px 17px; border-radius: 12px; display: flex; flex-direction: column; }
.summary strong { font-size: 23px; }
.summary span { font-size: 11px; color: var(--muted); }
.panel-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 6px 24px #27334b08; overflow: hidden; }
.table-scroll { overflow-x: auto; }
.devices-table { border-collapse: collapse; width: 100%; min-width: 1280px; }
.devices-table th { background: #f8f9fc; color: #68748a; font-size: 11px; text-transform: uppercase; letter-spacing: .055em; text-align: left; padding: 13px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.devices-table td { padding: 16px 14px; border-bottom: 1px solid #edf0f5; vertical-align: middle; font-size: 13px; }
.devices-table tr:last-child td { border-bottom: 0; }
.device-name { font-weight: 800; white-space: nowrap; }
.device-id { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; max-width: 170px; overflow-wrap: anywhere; }
.online-state { display: inline-flex; align-items: center; gap: 5px; margin-top: 8px; font-size: 11px; color: var(--muted); }
.online-state::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #a5adbb; }
.online-state.yes::before { background: #23b786; }
.time-value { white-space: nowrap; }
.comment-text { display: block; max-width: 180px; white-space: pre-wrap; overflow-wrap: anywhere; }
.saved-link { color: var(--primary); font-weight: 700; max-width: 170px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; flex-direction: column; gap: 7px; min-width: 145px; }
.mode-badge { display: inline-block; border-radius: 20px; padding: 5px 9px; background: #eef1f5; color: #5f6b7d; font-size: 11px; font-weight: 800; }
.mode-badge.active { color: #126a4e; background: #e3f8ef; }
.pending { display: block; color: var(--amber); font-size: 10px; margin-top: 6px; }
.mini-preview { border: 0; background: transparent; padding: 0; color: var(--primary); }
.mini-preview .phone-scene { margin-bottom: -7px; }
.preview-caption { font-size: 10px; text-decoration: underline; }
.phone-scene { width: 112px; height: 150px; display: grid; place-items: center; perspective: 600px; overflow: visible; }
.phone-scene.no-data { opacity: .42; }
.phone-scale { transform-style: preserve-3d; }
.phone-object { position: relative; width: 66px; height: 126px; transform-style: preserve-3d; transition: transform .45s ease; }
.phone-face { position: absolute; display: block; backface-visibility: visible; border: 1px solid #65718b; }
.phone-front, .phone-back { inset: 0; border-radius: 9px; overflow: hidden; }
.phone-front { background: linear-gradient(145deg, #223252, #0c1324); transform: translateZ(5px); box-shadow: inset 0 0 0 3px #263451; }
.phone-back { background: linear-gradient(145deg, #63708a, #2b354d); transform: rotateY(180deg) translateZ(5px); }
.phone-speaker { position: absolute; width: 18px; height: 3px; border-radius: 3px; background: #6e7d99; top: 7px; left: 24px; }
.phone-screen-glow { position: absolute; inset: 16px 6px 12px; border-radius: 4px; background: linear-gradient(155deg, #315efb77, #6f43d433 55%, #0e192e); }
.phone-home { position: absolute; width: 17px; height: 2px; background: #93a1b9; bottom: 5px; left: 24px; border-radius: 2px; }
.phone-camera { position: absolute; width: 20px; height: 28px; background: #202b41; border-radius: 8px; left: 7px; top: 8px; border: 1px solid #8490a4; }
.phone-camera::before, .phone-camera::after { content: ""; position: absolute; width: 8px; height: 8px; border-radius: 50%; background: #0a1222; border: 2px solid #495a77; left: 4px; }
.phone-camera::before { top: 3px; } .phone-camera::after { bottom: 3px; }
.phone-right, .phone-left { width: 10px; height: 126px; left: 28px; background: #303c55; }
.phone-right { transform: rotateY(90deg) translateZ(33px); }
.phone-left { transform: rotateY(-90deg) translateZ(33px); }
.phone-top, .phone-bottom { width: 66px; height: 10px; top: 58px; background: #3e4b65; }
.phone-top { transform: rotateX(90deg) translateZ(63px); }
.phone-bottom { transform: rotateX(-90deg) translateZ(63px); }
.phone-scene.large { width: 100%; height: 390px; perspective: 900px; background: radial-gradient(ellipse at center, #e8edfb, #f8f9fc 65%); border: 1px solid var(--line); border-radius: 16px; }
.phone-scene.large .phone-scale { transform: scale(1.9); }
.empty-state { padding: 60px 20px; text-align: center; display: flex; flex-direction: column; gap: 8px; color: var(--muted); }
.empty-state strong { color: var(--ink); font-size: 18px; }
.footnote { color: var(--muted); font-size: 11px; margin-top: 14px; }
.history-dialog { width: min(950px, calc(100vw - 32px)); max-height: calc(100vh - 32px); border: 0; border-radius: 20px; padding: 24px; color: var(--ink); box-shadow: 0 30px 100px #0b122966; }
.history-dialog::backdrop { background: #0d1629bb; backdrop-filter: blur(4px); }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.icon-button { width: 38px; height: 38px; border: 0; border-radius: 50%; background: #edf0f6; font-size: 25px; line-height: 1; color: var(--ink); }
.history-layout { display: grid; grid-template-columns: minmax(300px, 1.4fr) minmax(250px, 1fr); gap: 26px; align-items: center; }
.history-time { text-align: center; font-weight: 800; margin: 16px 0 3px; }
.angles { text-align: center; font-size: 12px; }
.history-mode { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px; border-radius: 10px; background: #eef2ff; color: #2949ba; font-size: 12px; font-weight: 800; }
.playback-buttons { display: flex; gap: 7px; margin-top: 16px; }
.playback-buttons .button { flex: 1; padding-left: 6px; padding-right: 6px; }
.toast-region { position: fixed; right: 20px; bottom: 20px; z-index: 20; display: flex; flex-direction: column; gap: 10px; width: min(380px, calc(100vw - 40px)); }
.toast { background: var(--navy); color: white; padding: 15px 17px; border-radius: 12px; box-shadow: 0 12px 40px #0c142944; font-size: 13px; line-height: 1.5; border-left: 4px solid var(--primary); }
.toast.motion { border-left-color: #ff637b; background: #531f35; }
.toast strong { display: block; margin-bottom: 3px; }
@media (max-width: 900px) {
  .topbar-inner { align-items: flex-start; padding: 14px 18px; }
  .header-actions { max-width: 480px; }
  .page-content { padding: 24px 16px; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .summary { width: 100%; }
  .summary > div { flex: 1; min-width: 0; }
  .history-layout { grid-template-columns: 1fr; }
  .phone-scene.large { height: 310px; }
  .phone-scene.large .phone-scale { transform: scale(1.45); }
}
@media (max-width: 600px) {
  .topbar-inner { flex-direction: column; }
  .header-actions { justify-content: flex-start; }
  .connection { width: 100%; }
  .login-card { padding: 28px 24px; }
  .summary strong { font-size: 20px; }
  .history-dialog { padding: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
