:root {
  color-scheme: dark;
  --bg: #05070a;
  --panel: #111821;
  --panel-soft: #151f2a;
  --line: #263447;
  --text: #f8fbff;
  --muted: #91a2b8;
  --orange: #ff9618;
  --orange-deep: #ff5b10;
  --red: #ff4d4d;
  --green: #20d469;
  --blue: #1387f5;
  --blue-deep: #0b3fd7;
  --black: #020305;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 74% 0%, rgba(19, 135, 245, 0.16), transparent 28%),
    linear-gradient(135deg, #05070a 0%, #080d13 48%, #0e1014 100%);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.topbar {
  height: 64px;
  border-bottom: 1px solid #1f3147;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  background: linear-gradient(90deg, #05070a 0%, #0b1119 52%, #11100c 100%);
}

.brand, .top-actions, .summary, .controls, .segmented, .import-panel, .view-tabs, .info-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-logo {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid #263447;
  background: #fff;
  box-shadow: 0 0 0 2px rgba(19, 135, 245, 0.12), 0 0 22px rgba(255, 150, 24, 0.14);
}

.top-actions { gap: 12px; }

button, select, input, textarea {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.refresh-button {
  min-height: 38px;
  border-radius: 7px;
  padding: 0 14px 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(19, 135, 245, 0.26), rgba(255, 150, 24, 0.18));
  border-color: #315071;
  color: var(--text);
  font-weight: 900;
}

.refresh-button span {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
}

.shell {
  position: relative;
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto 48px;
}

.summary {
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, #121a24, #0e151d);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.summary-compact .metric {
  width: 126px;
}

.metric {
  width: 94px;
  min-height: 78px;
  padding: 16px 20px 14px;
  border-right: 1px solid #223247;
  border-top: 3px solid transparent;
}

.metric:last-child { border-right: 0; }
.metric strong { display: block; font-size: 28px; line-height: 1; }
.metric span { display: block; margin-top: 12px; font-size: 10px; font-weight: 900; text-transform: uppercase; }
.metric-total strong { color: var(--text); }
.metric-green { border-top-color: var(--green); }
.metric-green strong { color: var(--green); }
.metric-orange { border-top-color: var(--orange); }
.metric-orange strong { color: var(--orange); }
.metric-red { border-top-color: var(--red); }
.metric-red strong { color: var(--red); }
.metric-team { border-top-color: var(--orange); }
.metric-team strong { color: var(--orange); }
.metric-solo { border-top-color: var(--blue); }
.metric-solo strong { color: var(--blue); }

.add-state {
  position: absolute;
  top: 0;
  right: 0;
  width: 82px;
  height: 78px;
  border: 1px dashed #2a3442;
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  place-items: center;
  gap: 2px;
  font-size: 11px;
}

.add-state span {
  display: block;
  font-size: 22px;
  color: var(--text);
}

.controls {
  gap: 8px;
  margin-top: 16px;
}

.search {
  flex: 1;
  height: 39px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0f1620;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
}

.search input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--text);
  background: transparent;
}

.search span {
  color: #7f8da3;
  font-size: 11px;
  text-transform: uppercase;
}

select {
  height: 39px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0f1620;
  color: var(--text);
  padding: 0 14px;
}

.segmented {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.segmented button {
  height: 39px;
  min-width: 52px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
}

.segmented button:last-child { border-right: 0; }
.segmented .active { background: var(--orange); color: #111; font-weight: 900; }

.refresh-inline {
  height: 39px;
}

.view-tabs {
  gap: 8px;
  margin-top: 12px;
}

.view-tabs button {
  min-height: 38px;
  border-radius: 7px;
  padding: 0 13px;
  background: #0f1620;
  color: var(--muted);
  font-weight: 900;
}

.view-tabs button.active {
  border-color: #315071;
  color: var(--text);
  background: linear-gradient(135deg, rgba(19, 135, 245, 0.22), rgba(255, 150, 24, 0.14));
}

.view-tabs span {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 20px;
  margin-left: 8px;
  border-radius: 10px;
  background: rgba(19, 135, 245, 0.24);
  color: #fff;
  font-size: 11px;
}

.info-actions {
  gap: 8px;
  margin-top: 12px;
}

.info-actions button {
  min-height: 38px;
  border-radius: 7px;
  padding: 0 13px;
  background: #0f1620;
  color: var(--text);
  font-weight: 900;
}

.info-actions button:first-child {
  border-color: #315071;
}

.info-actions button:last-child {
  border-color: rgba(255, 150, 24, 0.55);
  background: linear-gradient(135deg, rgba(255, 150, 24, 0.18), rgba(19, 135, 245, 0.12));
}

.portal-status {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 12px;
  padding: 10px 13px;
  color: #b8c3d4;
  border: 1px solid #263b58;
  border-radius: 7px;
  background: linear-gradient(90deg, rgba(19, 135, 245, 0.14), rgba(255, 150, 24, 0.09));
  font-size: 12px;
}

.portal-status strong {
  color: #fff;
}

.portal-status span {
  color: #d7e4f5;
}

.table-wrap {
  min-height: 580px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  background: #101720;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1120px;
}

th {
  height: 36px;
  color: #9db8d6;
  font-size: 10px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #172333, #181c22);
}

th, td { padding: 0 14px; }
td {
  height: 62px;
  border-top: 1px solid #202e40;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.load-id { color: #ffffff; }
.dim { color: var(--muted); }
.state, .load-type, .status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 35px;
  height: 23px;
  border-radius: 4px;
  padding: 0 9px;
  color: #061018;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.state { background: #7f8898; color: #fff; }
.state.hot { background: var(--orange); color: #061018; }
.load-type.solo { background: var(--blue); }
.load-type.team { background: var(--orange); }
.status.expiring { background: var(--red); color: #061018; }
.status.expired { background: #6d7481; color: #061018; }
.status.history { background: #8d98a9; color: #061018; }
.status.soon { background: var(--orange); color: #111; }
.status.upcoming { background: var(--blue); color: #061018; }
.ends.expired { color: #8d98a9; }
.ends.history { color: #9db8d6; }
.ends.expiring { color: var(--red); }
.ends.soon { color: var(--orange); }
.ends.upcoming { color: var(--green); }
.posted { color: #f5f7fb; }
th:last-child { color: var(--orange); }

.import-panel {
  gap: 10px;
  margin-top: 14px;
}

.import-panel button, .file-import {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  padding: 10px 14px;
}

.file-import input { display: none; }

dialog {
  width: min(620px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

dialog::backdrop { background: rgb(0 0 0 / 65%); }
dialog header, dialog footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.plain { border: 0; background: transparent; font-size: 24px; }

.info-dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: min(82vh, 820px);
  overflow: auto;
}

.info-dialog h3 {
  margin: 0 0 10px;
  color: #fff;
  font-size: 15px;
}

.info-dialog p {
  margin: 7px 0;
  color: #d7e4f5;
  font-size: 13px;
  line-height: 1.45;
}

.requirements-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.requirements-grid article,
.setup-content {
  border: 1px solid #263b58;
  border-radius: 7px;
  padding: 14px;
  background: #0f1620;
}

.setup-dialog {
  width: min(560px, calc(100vw - 32px));
}

.setup-line {
  color: var(--orange);
  font-weight: 900;
}

.telegram-cta {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  margin-top: 10px;
  padding: 0 14px;
  border-radius: 7px;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
  text-decoration: none;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

label {
  color: var(--muted);
  font-size: 12px;
}

label input, label select {
  width: 100%;
  margin-top: 6px;
}

input, textarea {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #0f151d;
  color: var(--text);
  padding: 0 10px;
}

textarea {
  width: 100%;
  min-height: 260px;
  padding: 12px;
  margin: 14px 0;
  resize: vertical;
  line-height: 1.5;
}

.helper {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.primary { background: var(--orange); color: #111; font-weight: 900; }

@media (max-width: 820px) {
  .topbar { padding: 0 16px; }
  .shell { width: calc(100vw - 20px); margin-top: 14px; }
  .summary { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
  .metric { width: auto; }
  .add-state { position: static; width: 100%; margin-top: 12px; display: flex; justify-content: center; }
  .controls { align-items: stretch; flex-wrap: wrap; }
  .view-tabs { align-items: stretch; flex-wrap: wrap; }
  .info-actions { align-items: stretch; flex-wrap: wrap; }
  .requirements-grid { grid-template-columns: 1fr; }
  .search { flex-basis: 100%; }
  .refresh-button { justify-content: center; }
  .form-grid { grid-template-columns: 1fr; }
}
