/* Home page – list of call reports */
:root {
  --bg: #f1f4fa; --card: #ffffff; --ink: #0f1b2d; --muted: #6b7a90; --line: #e3e8f1;
  --brand: #2457d6; --brand-2: #1739a8; --brand-soft: #eaf0fe;
  --ok: #0b9b64; --ok-soft: #dcf6ea; --warn: #b86e00; --warn-soft: #fff0d3; --danger: #d23a4a; --danger-soft: #fde7ea;
  --btn: #2457d6; --btn-dark: #1b44ad; --card-dark: #e8edf6; --line-dark: #d3dbe9;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d121c; --card: #161d2b; --ink: #e8edf6; --muted: #8b9ab2; --line: #263044;
    --brand: #6b95ff; --brand-2: #4a76f0; --brand-soft: #1c2a4d;
    --ok-soft: #12382b; --warn-soft: #3a2b0c; --danger-soft: #3d1a20;
    --card-dark: #101622; --line-dark: #1d2639;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--ink);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  padding-bottom: 120px;
}
button, input { font: inherit; color: inherit; }

/* ---------- header ---------- */
.top {
  position: sticky; top: 0; z-index: 30; background: var(--card);
  border-bottom: 1px solid var(--line);
}
.top-inner, .tools { width: min(980px, 100% - 24px); margin: 0 auto; }
.top-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 14px 0 10px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  display: block; width: 40px; height: 40px; border-radius: 12px; object-fit: contain;
}
.brand h1 { margin: 0; font-size: 19px; letter-spacing: -.2px; }
.brand p { margin: 0; font-size: 12px; color: var(--muted); }

a.new {
  display: inline-flex; align-items: center; gap: 8px; padding: 11px 24px; border-radius: 999px;
  color: #fff; text-decoration: none; font-weight: 700; font-size: 16px; letter-spacing: .1px;
  background: var(--btn); transition: background-color .12s;
}
a.new:hover { background: var(--btn-dark); }
a.new:active { background: #14378f; }

.header-actions { display: flex; align-items: center; justify-self: end; gap: 9px; }
.voice-command {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 16px; border: 1px solid var(--line-dark);
  border-radius: 999px; background: var(--card); color: var(--brand);
  font-weight: 700; font-size: 14px; cursor: pointer;
  transition: background-color .12s, color .12s, border-color .12s;
}
.voice-command:hover { background: var(--brand-soft); border-color: var(--brand); }
.voice-command[data-state="recording"] { background: var(--danger); border-color: var(--danger); color: #fff; }
.voice-command:disabled { cursor: progress; opacity: .7; }
.refresh {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 50%;
  cursor: pointer; color: var(--brand); background: var(--card); border: 1px solid var(--line);
  transition: background-color .12s, color .12s;
}
.refresh:hover { background: var(--card-dark); color: var(--brand-2); }
.refresh:disabled { cursor: progress; opacity: .7; }
.refresh[aria-busy="true"] svg { animation: refresh-spin .8s linear infinite; }
@keyframes refresh-spin { to { transform: rotate(360deg); } }

.tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 0 0 12px; }
.search {
  flex: 1 1 280px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 12px;
  background: var(--bg); border: 1px solid var(--line); color: var(--muted);
}
.search:focus-within { border-color: var(--brand); outline: 2px solid var(--brand); outline-offset: -1px; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; padding: 10px 0; color: var(--ink); }
.chips { display: flex; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); font-weight: 600; font-size: 13px; color: var(--muted);
}
.chip { transition: background-color .12s; }
.chip:hover { background: var(--card-dark); }
.chip i { font-style: normal; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--bg); }
.chip.on { background: var(--btn); border-color: var(--btn); color: #fff; }
.chip.on:hover { background: var(--btn-dark); border-color: var(--btn-dark); }
.chip.on i { background: rgba(255, 255, 255, .22); }

/* ---------- list ---------- */
main { width: min(980px, 100% - 24px); margin: 18px auto 0; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }

.card {
  position: relative; display: grid; align-items: center; cursor: pointer; outline: 0;
  grid-template-columns: 110px 112px minmax(0, 1fr) 52px 84px 52px; gap: 0 18px;
  padding: 14px 14px 14px 22px; border-radius: 18px; background: var(--card);
  border: 1.5px solid var(--line);
  transition: background-color .12s, border-color .12s;
  animation: rise .35s both;
}
.card::before {                                   /* status accent strip */
  content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 5px; border-radius: 0 5px 5px 0;
  background: var(--warn); opacity: .85;
}
.card.posted::before { background: var(--ok); }
.card:hover { background: var(--card-dark); }
.card:focus-visible { border-color: var(--brand); }
.card.selected { border-color: var(--brand); background: var(--brand-soft); }
.card.selected:hover { background: var(--brand-soft); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }

.inc small, .when small { display: block; font-size: 11px; font-style: italic; color: var(--muted); }
.inc b { display: block; font-size: 24px; font-weight: 700; color: var(--brand); letter-spacing: -.3px; font-variant-numeric: tabular-nums; }

.state { display: grid; justify-items: center; gap: 2px; text-align: center; font-size: 10.5px; font-style: italic; color: var(--muted); line-height: 1.15; }
.state svg { width: 46px; height: 34px; }
.state.unposted svg { color: #aab4c5; }
.state.posted svg { color: var(--ok); }
.state.posted { color: var(--ok); }

.addr { padding-left: 18px; border-left: 1px solid var(--line); min-width: 0; }
.addr .l1 { font-weight: 600; }
.addr .l2 { color: var(--muted); font-size: 13px; }
.addr .meta { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 12px; color: var(--muted); }
.tag { padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.tag.alert { background: var(--warn-soft); color: var(--warn); }
.tag.proto { background: var(--brand-soft); color: var(--brand); }

.badge {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; color: #fff; font-weight: 700;
  background: var(--warn); font-variant-numeric: tabular-nums;
}
.badge.clear { background: var(--ok); }

.when { text-align: left; padding-left: 16px; border-left: 1px solid var(--line); }
.when .mon { font-size: 13px; font-weight: 600; color: var(--muted); }
.when .day { font-size: 28px; font-weight: 300; letter-spacing: -.5px; line-height: 1; margin-left: 6px; }
.when .time { color: var(--muted); font-size: 13px; }

a.go {
  display: grid; place-items: center; width: 46px; height: 62px; border-radius: 12px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); transition: background-color .12s;
}
a.go:hover { background: var(--line-dark); }

.empty { display: grid; justify-items: center; gap: 4px; padding: 64px 12px; color: var(--muted); text-align: center; }
.empty h2 { margin: 8px 0 0; color: var(--ink); font-size: 18px; }
.empty p { margin: 0; }

/* ---------- action bar ---------- */
.actionbar {
  position: fixed; left: 50%; bottom: 18px; z-index: 40; transform: translateX(-50%);
  width: min(900px, 100% - 24px); display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 14px 12px 20px; border-radius: 20px; color: #fff;
  background: #101a30;
  animation: slide .22s ease-out;
}
@keyframes slide { from { opacity: 0; transform: translate(-50%, 16px); } }
.actionbar[hidden] { display: none; }
.sel { display: grid; min-width: 0; }
.sel-label { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: #8fa4cf; }
.sel b { font-size: 17px; }
#sel-sub { font-size: 12px; color: #aebbd6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.act {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 16px; border-radius: 12px; cursor: pointer;
  border: 0; background: #24335a; color: #fff; font-weight: 600;
  text-decoration: none; font-size: 14px; transition: background-color .12s;
}
.act:hover { background: #1a2644; }
.act.record { background: #0b8058; }
.act.record:hover { background: #096847; }
.act.record[data-state="recording"] { background: #c52c3b; }
.act:disabled { opacity: .5; cursor: not-allowed; }
.act.del { color: #ff9aa6; }
.act.open { background: #2f6bff; }
.act.open:hover { background: #1f52d1; }
.x { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 50%; cursor: pointer; background: transparent; color: #8fa4cf; transition: background-color .12s; }
.x:hover { background: #0a1224; color: #fff; }

/* ---------- dialog / toast ---------- */
dialog { border: 0; border-radius: 18px; padding: 22px; width: min(420px, 92vw); background: var(--card); color: var(--ink); border: 1px solid var(--line); }
dialog::backdrop { background: rgba(8, 14, 28, .55); }
dialog h3 { margin: 0 0 6px; }
dialog p { margin: 0 0 18px; color: var(--muted); }
dialog .row { display: flex; justify-content: flex-end; gap: 8px; }
.btn { padding: 9px 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600; transition: background-color .12s; }
.btn:hover { background: var(--card-dark); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #b02d3b; border-color: #b02d3b; }
.toast {
  position: fixed; left: 50%; top: 18px; z-index: 60; transform: translateX(-50%); padding: 10px 18px; border-radius: 999px;
  background: #0f1b2d; color: #fff; font-weight: 600; animation: slide .2s ease-out;
}
.toast[hidden] { display: none; }
.toast.err { background: var(--danger); }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .top-inner { grid-template-columns: minmax(0, 1fr) auto; }
  .header-actions { gap: 6px; }
  .voice-command { min-height: 40px; padding: 0 10px; font-size: 12px; }
  a.new { padding: 10px 14px; font-size: 14px; }
  .refresh { width: 40px; height: 40px; }
  .card { grid-template-columns: 1fr auto auto; grid-template-areas: "inc state go" "addr addr go" "badge when go"; gap: 10px 12px; }
  .inc { grid-area: inc; } .state { grid-area: state; } a.go { grid-area: go; height: 100%; min-height: 56px; width: 42px; }
  .addr { grid-area: addr; border-left: 0; padding-left: 0; }
  .badge { grid-area: badge; } .when { grid-area: when; border-left: 0; padding-left: 0; display: flex; align-items: baseline; gap: 8px; }
  .when small { display: none; }
  .actionbar { flex-direction: column; align-items: stretch; bottom: 10px; }
  .acts { justify-content: stretch; } .act { flex: 1; justify-content: center; } .x { position: absolute; top: 6px; right: 6px; }
}
@media (max-width: 400px) {
  .brand { gap: 8px; }
  .brand h1 { font-size: 14px; }
  .brand p { display: none; }
  .header-actions { gap: 4px; }
  .voice-command { min-height: 36px; gap: 3px; padding: 0 7px; font-size: 10px; }
  .voice-command svg { width: 15px; height: 15px; }
  a.new { gap: 4px; padding: 8px 9px; font-size: 12px; }
  a.new svg { width: 18px; height: 18px; }
  .refresh { width: 36px; height: 36px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
