:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --line: #e2e5ea;
  --text: #1c2430;
  --muted: #6b7684;
  --accent: #1f5fd6;
  --attention: #c8391f;
  --wait: #b3781a;
  --ok: #1f7a4d;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- layout --- */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { font-weight: 700; letter-spacing: .04em; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 14px; flex: 1; }
.topbar nav a { color: var(--text); }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.page { max-width: 1180px; margin: 0 auto; padding: 24px 20px 64px; }
.page-narrow { max-width: 560px; margin: 0 auto; padding: 48px 20px; }
.split { display: grid; grid-template-columns: 320px 1fr; gap: 20px; align-items: start; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row-between { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.stack { display: grid; gap: 12px; }

/* --- cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 16px; }
.card-list { display: grid; gap: 10px; }
.card-item { border-top: 1px solid var(--line); padding-top: 10px; }
.card-item:first-child { border-top: 0; padding-top: 0; }

h1 { font-size: 24px; margin: 0 0 18px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.pre-wrap { white-space: pre-wrap; word-break: break-word; }

/* --- badges --- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #eef1f5;
  color: var(--muted);
}
.badge.attention { background: #fdeceb; color: var(--attention); }
.badge.wait { background: #fdf3e0; color: var(--wait); }
.badge.ok { background: #e8f5ee; color: var(--ok); }
.badge.muted { background: #eef1f5; color: var(--muted); }

/* --- forms --- */
form .field { display: grid; gap: 4px; margin-bottom: 12px; }
form label { font-size: 13px; color: var(--muted); }
.input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  color: inherit;
}
.input:focus { outline: 2px solid rgba(31, 95, 214, .25); border-color: var(--accent); }
.textarea { min-height: 72px; resize: vertical; }
.checkbox { width: auto; }
.help { font-size: 12px; color: var(--muted); }
.errorlist { margin: 4px 0 0; padding-left: 18px; color: var(--attention); font-size: 13px; }

button, .button {
  display: inline-block;
  padding: 8px 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
}
button:hover, .button:hover { text-decoration: none; opacity: .92; }
.button-secondary, button.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}
.button-danger, button.danger { background: #fff; color: var(--attention); border-color: #f0c5bf; }
.link-button { background: none; border: 0; color: var(--accent); padding: 0; cursor: pointer; }

/* --- tables --- */
table { width: 100%; border-collapse: collapse; background: var(--surface); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }

/* --- tabs --- */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tabs a {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}
.tabs a.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* --- timeline --- */
.timeline { display: grid; gap: 14px; }
.timeline-item { border-left: 2px solid var(--line); padding: 0 0 0 14px; position: relative; }
.timeline-item::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--line);
}
.timeline-item.follow_up::before { background: var(--accent); }
.timeline-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; font-size: 13px; color: var(--muted); }

.messages { display: grid; gap: 8px; margin-bottom: 18px; }
.message { padding: 10px 14px; border-radius: 8px; background: #e8f0fd; border: 1px solid #cddffa; }
.message.error { background: #fdeceb; border-color: #f4c7c1; }
.message.success { background: #e8f5ee; border-color: #c4e3d2; }

.credentials { background: #fff8e2; border: 1px solid #f0dca6; border-radius: var(--radius); padding: 14px; }

@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .topbar { gap: 10px; }
}

/* --- services portal --- */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 20px;
}
.tile {
  display: grid;
  gap: 6px;
  align-content: start;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
}
.tile:hover { text-decoration: none; border-color: var(--accent); }
.tile-muted { opacity: .75; }
.tile-icon { font-size: 30px; line-height: 1; }
.tile-name { font-size: 18px; font-weight: 600; }
.tile-description { font-size: 13px; color: var(--muted); }
.tile .badge { justify-self: start; margin-top: 6px; }
