:root {
  --bg: #f4f7fb;
  --panel: #fff;
  --text: #172033;
  --muted: #6e788c;
  --line: #e4e9f2;
  --primary: #3157d5;
  --primary-dark: #2444ad;
  --green: #14845f;
  --green-soft: #e8f7f1;
  --amber: #a86908;
  --amber-soft: #fff4dc;
  --red: #bf3d48;
  --red-soft: #ffedef;
  --blue-soft: #eaf0ff;
  --shadow: 0 8px 30px rgba(26, 41, 75, .07);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }

.topbar {
  min-height: 72px; padding: 0 34px; display: flex; align-items: center; justify-content: space-between;
  gap: 30px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; gap: 11px; align-items: center; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark, .login-logo {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px;
  color: #fff; font-weight: 800; font-size: 22px; background: linear-gradient(140deg, #3157d5, #6b85e7);
  box-shadow: 0 6px 15px rgba(49,87,213,.25);
}
.brand span:last-child { display: grid; line-height: 1.05; }
.brand small { color: var(--muted); margin-top: 4px; font-size: 11px; }
.topbar nav { display: flex; align-items: center; gap: 24px; }
.topbar nav a, .link-button { color: #4c566b; font-weight: 600; font-size: 14px; }
.inline-form { display: inline; margin: 0; }
.link-button { border: 0; background: none; padding: 0; cursor: pointer; }

.container { width: min(1440px, calc(100% - 48px)); margin: 34px auto 60px; }
.login-container { min-height: 100vh; width: 100%; margin: 0; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top left, #eef2ff, #f7f9fc 50%); }
footer { color: #8a94a6; text-align: center; padding: 25px; font-size: 12px; }

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin: 0 0 24px; }
.page-heading h1 { font-size: clamp(27px, 3vw, 38px); margin: 4px 0 5px; letter-spacing: -.04em; }
.eyebrow { font-size: 11px; letter-spacing: .16em; color: var(--primary); font-weight: 800; }
.muted { color: var(--muted); margin: 0; }
h2 { font-size: 19px; margin: 0 0 5px; letter-spacing: -.02em; }

.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 17px;
  color: #354058; background: #fff; border: 1px solid #dce2ed; border-radius: 10px; cursor: pointer;
  font-weight: 700; font-size: 14px; white-space: nowrap;
}
.button:hover { text-decoration: none; border-color: #aeb8ca; }
.button.primary { color: #fff; background: var(--primary); border-color: var(--primary); box-shadow: 0 5px 14px rgba(49,87,213,.19); }
.button.primary:hover { background: var(--primary-dark); }
.button.small { min-height: 34px; padding: 0 11px; font-size: 12px; border-radius: 8px; }
.button.wide { width: 100%; }
.button.danger-outline { color: var(--red); border-color: #f0c5ca; }
.button:disabled { opacity: .5; cursor: not-allowed; }

.messages { display: grid; gap: 8px; margin: 0 0 18px; }
.message { padding: 13px 16px; border-radius: 10px; border: 1px solid var(--line); background: #fff; }
.message.error { color: #9a2732; background: var(--red-soft); border-color: #f4ccd0; }
.message.success { color: #0c684a; background: var(--green-soft); border-color: #c5eadc; }
.alert-card { padding: 18px 22px; margin-bottom: 22px; border-radius: 13px; border: 1px solid; }
.alert-card ul { margin: 9px 0; }
.alert-card.danger { color: #8d2832; background: var(--red-soft); border-color: #f0c5ca; }
.alert-card.success { color: #0b6749; background: var(--green-soft); border-color: #c4e8da; }
.alert-card p { margin: 7px 0 0; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow); padding: 22px; margin-bottom: 22px; }
.panel-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 18px; }
.panel-title p { color: var(--muted); margin: 0; font-size: 13px; }
.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: #fff; border: 1px solid var(--line); box-shadow: var(--shadow); padding: 18px; border-radius: 14px; border-top: 3px solid #8894a8; }
.stat-card span { display: block; color: var(--muted); font-size: 12px; min-height: 32px; }
.stat-card strong { font-size: 31px; letter-spacing: -.04em; }
.stat-card.green { border-top-color: var(--green); }
.stat-card.amber { border-top-color: #db9b2e; }
.stat-card.blue { border-top-color: var(--primary); }
.stat-card.red { border-top-color: var(--red); }
.two-columns { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr); gap: 22px; }

.bar-chart { height: 205px; display: flex; align-items: flex-end; gap: clamp(8px, 3vw, 28px); padding-top: 25px; }
.bar-item { flex: 1; min-width: 20px; height: 100%; display: grid; grid-template-rows: 20px 1fr 22px; text-align: center; color: var(--muted); font-size: 11px; }
.bar-track { width: min(38px, 80%); height: 100%; justify-self: center; background: #edf1f8; border-radius: 8px 8px 3px 3px; position: relative; overflow: hidden; }
.bar-fill { position: absolute; bottom: 0; width: 100%; min-height: 3px; background: linear-gradient(180deg, #6b85e7, #3157d5); border-radius: 8px 8px 3px 3px; }
.h-0 { height: 0; }.h-10 { height: 10%; }.h-20 { height: 20%; }.h-30 { height: 30%; }.h-40 { height: 40%; }.h-50 { height: 50%; }
.h-60 { height: 60%; }.h-70 { height: 70%; }.h-80 { height: 80%; }.h-90 { height: 90%; }.h-100 { height: 100%; }
.ranking { list-style: none; padding: 0; margin: 0; display: grid; gap: 3px; }
.ranking li { display: flex; align-items: center; justify-content: space-between; padding: 11px 4px; border-bottom: 1px solid #edf0f5; }
.ranking li:last-child { border-bottom: 0; }
.ranking li span { display: grid; }
.ranking small, td small { display: block; color: var(--muted); margin-top: 4px; font-size: 11px; }
.ranking b { min-width: 34px; padding: 6px; text-align: center; border-radius: 8px; background: var(--blue-soft); color: var(--primary); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: #7b8598; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 14px 12px; border-bottom: 1px solid #edf0f5; vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfe; }
.nowrap { white-space: nowrap; }
.disabled-row { opacity: .64; }
.actions { text-align: right; white-space: nowrap; }
.actions form { margin-left: 4px; }
.pill { display: inline-block; border-radius: 999px; padding: 5px 9px; color: #4f5b70; background: #eef1f6; font-weight: 700; font-size: 10px; white-space: nowrap; }
.pill.enabled, .decision-allowed, .decision-admin_test, .outbound-accepted { color: var(--green); background: var(--green-soft); }
.pill.disabled, .decision-disabled, .decision-unknown_number, .decision-invalid_phone, .decision-wrong_destination, .decision-worker_unavailable, .outbound-failed, .outbound-unknown, .outbound-expired { color: var(--red); background: var(--red-soft); }
.decision-schedule_denied, .decision-rate_limited, .decision-global_rate_limited, .outbound-queued, .outbound-sending { color: var(--amber); background: var(--amber-soft); }
.danger-text { color: var(--red); }
.empty { min-height: 130px; display: grid; place-items: center; align-content: center; gap: 8px; text-align: center; color: var(--muted); }
.empty p { margin: 0 0 8px; }

.form-panel { max-width: 940px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 19px; }
label, fieldset { color: #4c566b; font-size: 13px; font-weight: 700; }
input, select, textarea {
  display: block; width: 100%; margin-top: 7px; padding: 11px 12px; color: var(--text); background: #fff;
  border: 1px solid #d8deea; border-radius: 9px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #6983df; box-shadow: 0 0 0 3px rgba(49,87,213,.10); }
textarea { resize: vertical; }
label small { display: block; color: var(--muted); font-weight: 400; margin-top: 5px; }
.required { color: var(--red); }
.span-2 { grid-column: span 2; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { margin-bottom: 8px; }
.weekday-row { display: flex; flex-wrap: wrap; gap: 7px; }
.check-chip input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-chip span { display: grid; place-items: center; width: 42px; height: 38px; border-radius: 9px; border: 1px solid #d8deea; background: #fff; cursor: pointer; }
.check-chip input:checked + span { color: #fff; background: var(--primary); border-color: var(--primary); }
.toggle-label { display: flex; flex-direction: column; justify-content: flex-start; }
.toggle-line { display: flex; align-items: center; min-height: 43px; margin-top: 7px; padding: 0 12px; border: 1px solid #d8deea; border-radius: 9px; }
.toggle-line input { width: auto; margin: 0 9px 0 0; }
.section-divider { display: flex; align-items: center; gap: 13px; margin: 27px 0 18px; color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.section-divider:after { content: ""; flex: 1; height: 1px; background: var(--line); }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; padding-top: 24px; margin-top: 24px; border-top: 1px solid var(--line); }
.filter-panel { padding: 15px 18px; }
.filter-form { display: flex; align-items: flex-end; gap: 10px; }
.filter-form label:first-child { flex: 1; }
.filter-form label:nth-child(2) { min-width: 210px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }

.settings-grid { grid-template-columns: 1fr 1fr; }
.settings-list { margin: 18px 0 0; }
.settings-list div { display: contents; }
.settings-list dt, .settings-list dd { padding: 10px 0; border-bottom: 1px solid #edf0f5; }
.settings-list dt { float: left; clear: left; color: var(--muted); }
.settings-list dd { text-align: right; margin: 0; font-weight: 700; }

.login-card { width: min(420px, 100%); padding: 36px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 20px 60px rgba(37,53,91,.12); text-align: center; }
.login-logo { margin: 0 auto 18px; width: 54px; height: 54px; border-radius: 16px; font-size: 28px; }
.login-card h1 { margin: 0 0 7px; letter-spacing: -.03em; }
.form-stack { display: grid; gap: 16px; margin-top: 26px; text-align: left; }
.error-code { color: var(--primary); font-size: 52px; font-weight: 800; }

@media (max-width: 1050px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .two-columns { grid-template-columns: 1fr; }
  .topbar { padding: 0 20px; }
  .topbar nav { gap: 13px; }
}
@media (max-width: 760px) {
  .container { width: min(100% - 24px, 700px); margin-top: 20px; }
  .topbar { position: static; padding: 13px; align-items: flex-start; flex-direction: column; }
  .topbar nav { width: 100%; overflow-x: auto; padding-bottom: 3px; }
  .brand small { display: none; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .filter-form { align-items: stretch; flex-direction: column; }
  .filter-form label:nth-child(2) { min-width: 0; }
  .filter-form .button { width: 100%; }
  .actions { white-space: normal; }
  .actions form { display: block; margin: 5px 0 0; }
}
@media (max-width: 470px) {
  .stat-grid { grid-template-columns: 1fr; }
  .login-card { padding: 27px 20px; }
  .panel { padding: 16px; }
}
