/* StayLine brand (from stayline.org): warm cream, coral, sunny yellow, teal,
   growth purple and celebration green. Fraunces + Plus Jakarta Sans. */
:root {
  --bg: #FFF8F0;
  --ink: #2B2D42;
  --muted: #6B7180;
  --line: #F1DFD0;
  --card: #FFFFFF;
  --coral: #FF6F59;
  --coral-ink: #B93826;
  --coral-label: #C34330;
  --coral-tint: #FFF0EC;
  --yellow: #FFC145;
  --yellow-tint: #FFF6DF;
  --teal: #14B8A6;
  --teal-ink: #0F766B;
  --teal-tint: #E3F8F5;
  --purple: #8B5CF6;
  --purple-tint: #EDE9FE;
  --purple-ink: #6D28D9;
  --green: #86EFAC;
  --green-tint: #DCFCE7;
  --green-ink: #166534;
  --red: #D61F4B;
  --radius: 14px;
  --shadow: 0 1px 3px rgb(166 73 42 / .05), 0 8px 24px -12px rgb(166 73 42 / .19);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; color: var(--coral-ink); letter-spacing: -0.01em; margin: 0 0 .6rem; font-weight: 600; }
h2 { font-size: 1.25rem; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.msg { min-height: 1.2em; color: var(--coral-ink); font-weight: 600; margin: .4rem 0 0; }
.msg.ok { color: var(--teal-ink); }

.brand { display: flex; align-items: center; gap: .55rem; font-family: 'Fraunces', Georgia, serif; font-weight: 600; font-size: 1.35rem; color: var(--ink); }
.brand img { border-radius: 9px; }
.brand em { font-style: normal; font-family: 'Plus Jakarta Sans', sans-serif; font-size: .78rem; font-weight: 700; color: var(--purple-ink); background: var(--purple-tint); padding: .15rem .5rem; border-radius: 999px; }
.brand.big { font-size: 1.8rem; justify-content: center; }

.btn { font: inherit; font-weight: 600; border-radius: 10px; padding: .55rem 1rem; cursor: pointer; border: 1px solid transparent; }
.btn.primary { color: #fff; background: linear-gradient(135deg, #CD4935, #C34330); box-shadow: inset 0 2px 0 #FF6F59, 0 6px 20px -10px rgb(255 111 89 / .6); }
.btn.primary:hover { background: linear-gradient(135deg, #C34330, #B93826); }
.btn.primary:disabled { opacity: .6; cursor: wait; }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--coral); }
.btn:focus-visible, input:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background:
  radial-gradient(circle at 15% 20%, var(--yellow-tint), transparent 40%),
  radial-gradient(circle at 85% 80%, var(--purple-tint), transparent 40%), var(--bg); }
.auth-card { width: min(420px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 2rem; box-shadow: var(--shadow); text-align: center; }
.auth-card form { text-align: left; display: grid; gap: .8rem; margin-top: 1rem; }
label { display: grid; gap: .3rem; font-weight: 600; font-size: .9rem; }
label.inline { display: flex; align-items: center; gap: .4rem; font-weight: 500; }
input, select { font: inherit; padding: .55rem .7rem; border: 1px solid #E5CDB9; border-radius: 10px; background: #fff; color: var(--ink); min-width: 0; }

/* app */
#app { max-width: 1280px; margin: 0 auto; padding: 1rem 1.25rem 3rem; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .5rem 0 1rem; border-bottom: 3px solid var(--purple); margin-bottom: 1.2rem; }
.top-right { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.import-status { font-size: .82rem; color: var(--muted); }
.import-status.bad { color: var(--coral-ink); font-weight: 600; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.2rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); display: grid; gap: .1rem; }
.stat span { color: var(--muted); font-weight: 600; font-size: .85rem; }
.stat b { font-family: 'Fraunces', Georgia, serif; font-size: 2.1rem; color: var(--ink); font-weight: 600; }
.stat small { color: var(--muted); }
.stat.coral { background: var(--coral-tint); border-color: #FFD3C9; }
.stat.coral b { color: var(--coral-ink); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); margin-bottom: 1.2rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.tabs { display: flex; gap: .3rem; background: var(--bg); padding: .25rem; border-radius: 12px; border: 1px solid var(--line); }
.tab { font: inherit; font-weight: 600; border: 0; background: transparent; padding: .4rem .8rem; border-radius: 9px; cursor: pointer; color: var(--muted); }
.tab.active { background: #fff; color: var(--coral-ink); box-shadow: 0 1px 3px rgb(0 0 0 / .08); }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0 .4rem; align-items: center; }
.filters #fQ { flex: 2 1 240px; }
.filters #fName, .filters #fLocation { flex: 1 1 140px; }

.follow-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.follow-list li { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: .6rem .8rem; border-radius: 10px; background: var(--yellow-tint); border: 1px solid #FBE3A7; cursor: pointer; }
.follow-list li:hover { border-color: var(--yellow); }
.follow-list .why { color: var(--coral-ink); font-weight: 600; font-size: .88rem; }
.follow-list .empty { background: var(--green-tint); border-color: var(--green); color: var(--green-ink); cursor: default; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .55rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: .6rem; border-bottom: 1px solid #F7EBE0; vertical-align: top; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--coral-tint); }
td.when { white-space: nowrap; }
td.sum { color: var(--muted); max-width: 360px; }
.pill { display: inline-block; font-size: .76rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; white-space: nowrap; }
.pill.ellie { background: var(--teal-tint); color: var(--teal-ink); }
.pill.nova { background: var(--purple-tint); color: var(--purple-ink); }
.pill.success { background: var(--green-tint); color: var(--green-ink); }
.pill.failure { background: #FDE2E8; color: var(--red); }
.pill.unknown { background: #EEF0F3; color: #4B5563; }
.pill.fu { background: var(--yellow-tint); color: #8A5A00; border: 1px solid #FBE3A7; }
.pill.done { background: var(--green-tint); color: var(--green-ink); }

/* drawer */
.drawer { position: fixed; inset: 0; background: rgb(43 45 66 / .4); backdrop-filter: blur(3px); display: flex; justify-content: flex-end; z-index: 20; }
.drawer-inner { width: min(680px, 100%); height: 100%; overflow-y: auto; background: var(--bg); padding: 1.3rem 1.4rem 3rem; box-shadow: -10px 0 40px rgb(0 0 0 / .15); position: relative; }
.close { position: sticky; top: 0; float: right; z-index: 2; }
.meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem 1rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: .8rem 0; }
.meta div span { display: block; font-size: .76rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; margin: .8rem 0; }
.box.fu { background: var(--yellow-tint); border-color: #FBE3A7; }
audio { width: 100%; margin-top: .3rem; }
.transcript { display: grid; gap: .6rem; }
.turn { padding: .6rem .8rem; border-radius: 12px; max-width: 92%; }
.turn.agent { background: var(--teal-tint); }
.turn.user { background: var(--coral-tint); justify-self: end; }
.turn b { display: block; font-size: .75rem; color: var(--muted); margin-bottom: .15rem; }
.row { display: flex; gap: .5rem; justify-content: flex-end; }
dialog { border: 1px solid var(--line); border-radius: 16px; padding: 1.4rem; width: min(400px, 92vw); }
dialog form { display: grid; gap: .7rem; }
dialog::backdrop { background: rgb(43 45 66 / .4); }
footer { text-align: center; margin-top: 1rem; }

@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .meta { grid-template-columns: 1fr; }
  td.sum { display: none; }
  th:last-child { display: none; }
}
