:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1d2433;
  --muted: #667085;
  --line: #e3e6ec;
  --brand: #1f4fd8;
  --brand-ink: #ffffff;
  --ok: #12805c;
  --warn: #b25e09;
  --bad: #c0362c;
  --info: #5b4bd6;
  --ready: #12805c;
  --paused: #b25e09;
  --incall: #1f4fd8;
  --wrapup: #7a5af8;
  --dialing: #0e7490;
  --preview: #9a3fb5;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .6rem; font-weight: 600; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.right { margin-left: auto; }
.gap { height: .75rem; }

/* top bar */
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem;
  background: #111827; color: #fff; position: sticky; top: 0; z-index: 10;
}
.topbar .logo { font-weight: 700; letter-spacing: .02em; }
.topbar .logo span { color: #7ea2ff; }
.topbar nav a { color: #cbd5e1; margin-right: .8rem; }
.topbar nav a.active, .topbar nav a:hover { color: #fff; }
.topbar .user { margin-left: auto; display: flex; gap: .75rem; align-items: center; color: #cbd5e1; }

/* layout */
.page { padding: 1rem; max-width: 1600px; margin: 0 auto; }
.grid { display: grid; gap: 1rem; }
.agent-grid { grid-template-columns: 340px minmax(380px, 1fr) 360px; }
@media (max-width: 1200px) { .agent-grid { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; }
.card + .card { margin-top: 1rem; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .75rem; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem 1rem; }
.tile .v { font-size: 1.7rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }

/* controls */
button, .btn {
  font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: .45rem .8rem; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
button:hover { border-color: #c5cad3; background: #fafbfc; }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
button.primary:hover { background: #1a43b8; }
button.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
button.bad { background: var(--bad); border-color: var(--bad); color: #fff; }
button.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
button.small { padding: .2rem .5rem; font-size: .8rem; }
button.big { padding: .7rem 1.1rem; font-size: 1rem; }
input, select, textarea {
  font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: .45rem .55rem; background: #fff; color: var(--ink);
  width: 100%;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d6ff; border-color: var(--brand); }
label { display: block; font-size: .8rem; color: var(--muted); margin: .5rem 0 .2rem; }
label.inline { display: inline-flex; gap: .35rem; align-items: center; margin: 0 .8rem 0 0; color: var(--ink); font-size: .9rem; }
label.inline input { width: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .75rem; }
.form-grid .full { grid-column: 1 / -1; }

/* badge stato */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #eef0f4; color: var(--ink); }
.badge.READY { background: #dcfae6; color: var(--ready); }
.badge.PAUSED { background: #fef0c7; color: var(--paused); }
.badge.INCALL { background: #dbe5ff; color: var(--incall); }
.badge.WRAPUP { background: #ece7ff; color: var(--wrapup); }
.badge.DIALING { background: #d7f2f7; color: var(--dialing); }
.badge.PREVIEW { background: #f6e2fb; color: var(--preview); }
.badge.ok { background: #dcfae6; color: var(--ok); }
.badge.bad { background: #fee4e2; color: var(--bad); }
.badge.warn { background: #fef0c7; color: var(--warn); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa3b2; display: inline-block; }
.dot.on { background: #22c55e; } .dot.off { background: #ef4444; } .dot.wait { background: #f59e0b; }

.state-big { font-size: 1.4rem; font-weight: 700; }
.timer { font-size: 1.1rem; font-variant-numeric: tabular-nums; color: var(--muted); }

/* tabelle */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: #fafbfc; }
tr:hover td { background: #fafbff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow: auto; max-height: 70vh; }

/* call panel */
.call-box { border-radius: var(--radius); padding: 1rem; background: #f8fafc; border: 1px dashed var(--line); text-align: center; }
.call-box.active { background: #eef3ff; border: 1px solid #c7d6ff; }
.call-box .num { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: .35rem; }
.keypad button { padding: .5rem; font-size: 1rem; }
.script { background: #fffdf5; border: 1px solid #f3e8c8; border-radius: 6px; padding: .75rem 1rem; line-height: 1.5; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .45rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.list li:last-child { border-bottom: none; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: .75rem; }
.tabs button { border: none; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }

/* modale */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start; justify-content: center; padding-top: 6vh; z-index: 50; }
.modal { background: #fff; border-radius: 10px; width: min(760px, 94vw); max-height: 88vh; overflow: auto; padding: 1.25rem; box-shadow: 0 20px 40px rgba(0,0,0,.25); }
.dispo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .5rem; }
.dispo-grid button.sel { outline: 3px solid var(--brand); }

/* toast */
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast { background: #111827; color: #fff; padding: .6rem .9rem; border-radius: 6px; box-shadow: var(--shadow); max-width: 380px; }
.toast.err { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 360px; }
.login-card .logo { font-size: 1.6rem; font-weight: 800; margin-bottom: 1rem; }
.login-card .logo span { color: var(--brand); }

/* admin */
.admin-grid { grid-template-columns: 220px 1fr; }
.side a { display: block; padding: .45rem .6rem; border-radius: 6px; color: var(--ink); }
.side a.active, .side a:hover { background: #eef3ff; color: var(--brand); }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: .2rem .6rem; font-size: .85rem; background: #fff; cursor: pointer; user-select: none; }
.chip.on { background: #eef3ff; border-color: var(--brand); color: var(--brand); }
.help { font-size: .75rem; color: var(--muted); margin-top: .15rem; }
.bar { height: 6px; background: #eef0f4; border-radius: 3px; overflow: hidden; }
.bar > div { height: 100%; background: var(--brand); }
