* { box-sizing: border-box; }
:root {
  --bg: #f6f7f9;
  --fg: #1a2030;
  --muted: #67707f;
  --brand: #1f4a8a;
  --brand-dark: #163668;
  --border: #d8dde6;
  --card: #ffffff;
  --ok: #2c8a4d;
  --err: #b6262c;
}
html, body { margin: 0; padding: 0; font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); color: var(--fg); }
[hidden] { display: none !important; }

header#topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 2rem; background: var(--card); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 600; color: var(--brand); font-size: 1.1rem; }
.brand .sep { color: var(--muted); margin: 0 .5rem; }
.meta { display: flex; gap: 1rem; align-items: center; color: var(--muted); }
.badge { background: var(--brand); color: white; padding: 2px 8px; border-radius: 10px; font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; }
.badge.muted { background: var(--muted); }
button.link { background: none; border: none; color: var(--brand); cursor: pointer; text-decoration: underline; padding: 0; }
button.link:hover { color: var(--brand-dark); }

main { max-width: 880px; margin: 2rem auto; padding: 0 1.5rem; }
main.card {
  max-width: 460px; margin-top: 6rem; padding: 2rem; background: var(--card);
  border-radius: 12px; box-shadow: 0 2px 18px rgba(20,30,60,0.08);
}
h1, h2, h3 { color: var(--fg); margin-top: 0; }
p.muted, small.hint, .muted { color: var(--muted); font-size: 0.9rem; }

form#login-form, form#activate-form { display: flex; flex-direction: column; gap: .5rem; margin-top: 1.25rem; }
input, select, button, textarea {
  font: inherit; padding: .55rem .75rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card); color: var(--fg);
}
button { background: var(--brand); color: white; cursor: pointer; border-color: var(--brand); transition: background .15s; }
button:hover { background: var(--brand-dark); }
button[type="submit"] { padding: .7rem 1rem; }
input[readonly] { background: var(--bg); color: var(--muted); }

nav.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
nav.tabs .tab {
  background: transparent; color: var(--muted); border: none; padding: .75rem 1.25rem;
  border-bottom: 2px solid transparent; border-radius: 0; cursor: pointer; font-weight: 500;
}
nav.tabs .tab:hover { color: var(--fg); }
nav.tabs .tab.active { color: var(--brand); border-bottom-color: var(--brand); }

section.tab-pane { display: none; background: var(--card); padding: 1.5rem 2rem; border-radius: 12px; box-shadow: 0 1px 8px rgba(20,30,60,0.05); }
section.tab-pane.active { display: block; }

form.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem 1.5rem; margin-top: 1rem; }
form.grid label { display: flex; flex-direction: column; gap: .35rem; }
form.grid label span { font-weight: 500; }
form.grid .section-title { grid-column: 1 / -1; margin: 1rem 0 0; padding-bottom: .35rem; border-bottom: 1px solid var(--border); font-size: 1.05rem; color: var(--brand); }
form.grid .section-title:first-child { margin-top: 0; }
form.grid fieldset { grid-column: 1 / -1; border: 1px solid var(--border); border-radius: 6px; padding: .75rem 1rem; display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; align-items: center; }
form.grid fieldset legend { color: var(--muted); padding: 0 .35rem; font-size: .9rem; }
form.grid fieldset label.inline { margin-right: 0; }
label.inline { display: inline-flex; align-items: center; gap: .35rem; margin-right: 1rem; font-weight: normal; }
.actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 1rem; }
.status { font-size: .9rem; }
.status.ok { color: var(--ok); }
.status.err { color: var(--err); }

table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { text-align: left; padding: .65rem .5rem; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--muted); font-size: .9rem; }
#calls-table tbody tr { cursor: pointer; }
#calls-table tbody tr:hover { background: var(--bg); }
.audio-yes { color: var(--ok); }
.audio-no  { color: var(--muted); }
.call-live td { font-weight: 600; }
.live-dot {
  display: inline-block; width: .65rem; height: .65rem; border-radius: 50%;
  background: var(--err); margin-right: .35rem; vertical-align: middle;
  animation: live-pulse 1.4s infinite ease-in-out;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .45; transform: scale(.75); }
}

.staff-source { display: flex; flex-direction: column; gap: .5rem; margin: 1rem 0 1.5rem; }
.staff-source label.inline { display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; padding: .75rem 1rem; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.staff-source label.inline:hover { background: var(--bg); }
.staff-source label.inline b { color: var(--fg); }
.staff-source small { margin-left: 1.4rem; }

.hint-box { background: #f3f7ff; border-left: 3px solid var(--brand); padding: .85rem 1rem; border-radius: 4px; margin-bottom: 1rem; font-size: .95rem; }
.hint-box pre { background: var(--card); padding: .5rem .75rem; border-radius: 4px; white-space: pre-wrap; word-break: break-all; font-size: .85rem; max-height: 6rem; overflow: auto; }

label.block { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1.5rem; }
label.block span { font-weight: 500; }

#staff-table input, #users-table input, #users-table select {
  width: 100%; padding: .4rem .5rem; font-size: .9rem;
}
#staff-table .col-del, #users-table .col-del { width: 2rem; text-align: center; }
.del-btn { background: none; color: var(--err); border: 1px solid transparent; padding: .2rem .4rem; cursor: pointer; font-size: 1.1rem; }
.del-btn:hover { border-color: var(--err); border-radius: 4px; }

#staff-add { background: transparent; color: var(--brand); border: 1px dashed var(--brand); margin-top: .25rem; }
#staff-add:hover { background: var(--bg); color: var(--brand-dark); }

#detail-overlay {
  position: fixed; inset: 0; background: rgba(20,30,60,0.45); display: flex; align-items: center; justify-content: center; padding: 1.5rem;
}
.detail-card {
  background: var(--card); border-radius: 12px; max-width: 720px; width: 100%; max-height: 90vh; overflow: auto; padding: 1.75rem; position: relative;
}
.detail-card .close { position: absolute; top: .5rem; right: .75rem; background: none; border: none; color: var(--muted); font-size: 1.5rem; cursor: pointer; padding: 0 .5rem; }
.detail-card .close:hover { color: var(--fg); }
.detail-card audio { width: 100%; margin-bottom: 1rem; }
.detail-card pre { background: var(--bg); padding: 1rem; border-radius: 6px; white-space: pre-wrap; word-break: break-word; max-height: 60vh; overflow: auto; }
code { background: var(--bg); padding: 1px 4px; border-radius: 3px; font-size: 0.9em; }
