:root {
  --navy: #14304f;
  --navy-dark: #0d2138;
  --orange: #f2803b;
  --orange-dark: #d96a28;
  --bg: #f4f6f9;
  --card: #ffffff;
  --text: #1c2b3a;
  --muted: #6b7a8c;
  --border: #dde4ec;
  --green: #2e9e5b;
  --red: #c94f3d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

header.topbar {
  background: var(--navy);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

header.topbar .logo {
  background: var(--orange);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

header.topbar h1 { font-size: 18px; margin: 0; font-weight: 600; }
header.topbar .sub { font-size: 12px; opacity: 0.75; }

main { max-width: 860px; margin: 0 auto; padding: 24px 16px 64px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 { margin: 0 0 12px; font-size: 16px; }

.banner {
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid;
}
.banner.warn { background: #fdf3e7; border-color: #f0d4b2; color: #8a5a1e; }
.banner.ok { background: #e9f7ee; border-color: #bfe5cc; color: #1f6b3d; display: none; }

form.new-estimate { display: flex; gap: 10px; flex-wrap: wrap; }
form.new-estimate input {
  flex: 1 1 180px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
}
form.new-estimate select {
  flex: 0 1 auto;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
form.new-estimate button {
  padding: 10px 18px;
  background: var(--orange);
  border: none;
  border-radius: 8px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
form.new-estimate button:hover { background: var(--orange-dark); }
form.new-estimate button:disabled { opacity: 0.6; cursor: default; }

.estimate {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  background: #fff;
}
.estimate .row1 { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px; }
.estimate .name { font-weight: 600; font-size: 15px; }
.estimate .when { color: var(--muted); font-size: 12px; }
.estimate .phone { color: var(--muted); font-size: 13px; margin-top: 2px; }

.badges { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
}
.badge.ok { background: #e9f7ee; color: var(--green); }
.badge.err { background: #fbeae7; color: var(--red); }

.actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.actions a, .actions button {
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--navy);
  cursor: pointer;
  text-decoration: none;
  font-weight: 500;
}
.actions .primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.actions a:hover, .actions button:hover { filter: brightness(1.06); }

.empty { color: var(--muted); font-size: 14px; text-align: center; padding: 24px 0; }

/* Call pages */
html:has(body.call-page), body.call-page { height: 100%; }
body.call-page {
  background: var(--navy-dark);
  height: 100vh;
  height: 100dvh; /* mobile browsers: exclude dynamic toolbars */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.call-header { flex: 0 0 auto; color: #fff; padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.call-header .title { font-weight: 600; font-size: 15px; }
.call-header .hint { font-size: 12px; opacity: 0.7; }
#call-frame { flex: 1 1 auto; min-height: 0; position: relative; }
#call-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Customer viewfinder (join page) */
#stage { position: absolute; inset: 0; overflow: hidden; }
#big { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
#topbar {
  position: absolute; top: 0; left: 0; right: 0;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  color: #fff; font-size: 13px; font-weight: 600;
  background: linear-gradient(rgba(13,33,56,0.85), rgba(13,33,56,0));
  pointer-events: none;
}
#small {
  position: absolute;
  right: 12px;
  top: calc(52px + env(safe-area-inset-top));
  width: 104px; height: 148px;
  border-radius: 12px; overflow: hidden;
  border: 2px solid rgba(255,255,255,0.7);
  background: #000;
  box-shadow: 0 4px 14px rgba(0,0,0,0.4);
  cursor: pointer; z-index: 5;
}
#small video { width: 100%; height: 100%; object-fit: cover; }
.tile-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  font-size: 10px; color: #fff; text-align: center;
  padding: 3px 4px; background: rgba(13,33,56,0.65);
}
#controls {
  position: absolute; left: 0; right: 0;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; justify-content: center; gap: 14px; z-index: 5;
}
#controls button {
  width: 54px; height: 54px; border-radius: 50%;
  border: none; font-size: 22px; cursor: pointer;
  background: rgba(20,48,79,0.85); color: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,0.35);
}
#controls button.off { background: rgba(201,79,61,0.9); }
#controls button.danger { background: var(--red); }
#status-overlay {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  z-index: 4; pointer-events: none;
}
.status-card {
  background: rgba(13,33,56,0.85); color: #fff;
  padding: 14px 22px; border-radius: 12px;
  font-size: 15px; max-width: 320px; text-align: center; line-height: 1.4;
}

.mock-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.mock-card {
  background: #fff;
  border-radius: 14px;
  padding: 32px;
  max-width: 440px;
  text-align: center;
}
.mock-card .cam {
  font-size: 44px;
  background: var(--bg);
  width: 88px; height: 88px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
}
.mock-card h2 { margin: 0 0 8px; font-size: 18px; }
.mock-card p { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0; }
.mock-card .tag { display: inline-block; margin-top: 14px; font-size: 11px; background: #fdf3e7; color: #8a5a1e; padding: 4px 10px; border-radius: 999px; }
