:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --bg-elevated: #111821;
  --panel: #151d27;
  --panel-2: #101720;
  --line: #263241;
  --line-soft: #1e2835;
  --text: #ecf2f8;
  --muted: #9aa8b7;
  --subtle: #6f8091;
  --accent: #2ed3b7;
  --accent-2: #69a7ff;
  --warn: #f6bd60;
  --danger: #ff6b6b;
  --ok: #44d07b;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.32);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(46, 211, 183, 0.06), transparent 240px),
    var(--bg);
  letter-spacing: 0;
  overflow-x: hidden;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  background: #0e141c;
  border-right: 1px solid var(--line-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #061014;
  font-size: 13px;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 15px;
  line-height: 18px;
}

.brand small,
.panel p,
.topbar p,
.hint {
  color: var(--muted);
}

.brand small {
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 6px;
  margin-top: 28px;
}

.nav-link {
  display: flex;
  align-items: center;
  min-height: 38px;
  padding: 0 12px;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 650;
  transition:
    color 0.14s ease,
    background 0.14s ease,
    border-color 0.14s ease,
    box-shadow 0.14s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: #151e29;
  border-color: var(--line);
}

.nav-link:hover {
  box-shadow: inset 0 0 0 1px rgba(105, 167, 255, 0.22);
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--subtle);
}

.status-dot.ok {
  background: var(--ok);
}

.status-dot.warn {
  background: var(--warn);
}

.status-dot.bad {
  background: var(--danger);
}

.workspace {
  min-width: 0;
  width: 100%;
  padding: 24px;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.topbar > div,
.panel-header > div,
.topbar-actions,
.actions-row,
.client-row,
.task-row,
.event-row,
.billing-row {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
  line-height: 34px;
}

.topbar p,
.panel p {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 18px;
  max-width: 720px;
  overflow-wrap: anywhere;
}

.topbar-actions,
.actions-row {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.actions-row.inline {
  justify-content: flex-end;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

select,
input,
textarea {
  color: var(--text);
  background: #0d131b;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

select {
  min-width: 190px;
  height: 38px;
  padding: 0 10px;
}

input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
}

textarea {
  width: 100%;
  min-height: 150px;
  padding: 12px;
  resize: vertical;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 13px;
  line-height: 20px;
}

.button {
  height: 38px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  background: #202b38;
  font-size: 13px;
  font-weight: 750;
  cursor: pointer;
  transition:
    transform 0.14s ease,
    filter 0.14s ease,
    border-color 0.14s ease,
    box-shadow 0.14s ease,
    background 0.14s ease;
}

.button:hover {
  filter: brightness(1.12);
  border-color: rgba(105, 167, 255, 0.8);
  box-shadow:
    0 0 0 2px rgba(105, 167, 255, 0.18),
    0 10px 24px rgba(0, 0, 0, 0.28);
  transform: translateY(-1px);
}

.button:focus-visible,
.nav-link:focus-visible,
.segmented button:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}

.button.primary:hover {
  border-color: rgba(46, 211, 183, 0.95);
  box-shadow:
    0 0 0 2px rgba(46, 211, 183, 0.26),
    0 10px 24px rgba(0, 0, 0, 0.28);
}

.button.danger:hover {
  border-color: rgba(255, 107, 107, 0.95);
  box-shadow:
    0 0 0 2px rgba(255, 107, 107, 0.24),
    0 10px 24px rgba(0, 0, 0, 0.28);
}

.button.primary {
  color: #04110f;
  background: var(--accent);
}

.button.secondary {
  border-color: var(--line);
  background: #131b25;
}

.button.danger {
  color: #fff7f7;
  background: #9d2f3a;
  border-color: #c04752;
}

.button.full {
  width: 100%;
  margin-top: 12px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric {
  padding: 14px;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 28px;
}

.metric small {
  display: block;
  margin-top: 4px;
  color: var(--subtle);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.layout-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  gap: 14px;
}

.layout-2.wide-left {
  grid-template-columns: minmax(0, 1.35fr) 380px;
}

.panel {
  min-width: 0;
  padding: 16px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0;
  font-size: 18px;
  line-height: 24px;
}

.compact-header {
  margin-bottom: 10px;
}

.section-divider {
  height: 1px;
  margin: 16px 0;
  background: var(--line-soft);
}

.client-list,
.task-list,
.event-list,
.billing-panel {
  display: grid;
  gap: 10px;
}

.client-row,
.task-row,
.event-row,
.billing-row {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.row-title {
  font-size: 14px;
  font-weight: 800;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 17px;
}

.meta-grid span,
.row-title,
td,
th {
  min-width: 0;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 7px;
  color: var(--text);
  background: #202b38;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 750;
}

.badge.ok {
  color: #b8ffd3;
  border-color: rgba(68, 208, 123, 0.35);
  background: rgba(68, 208, 123, 0.12);
}

.badge.warn {
  color: #ffe2a8;
  border-color: rgba(246, 189, 96, 0.35);
  background: rgba(246, 189, 96, 0.12);
}

.badge.bad {
  color: #ffc0c0;
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 107, 107, 0.12);
}

.checkbox-list {
  display: grid;
  gap: 8px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 8px 10px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.button.tiny {
  height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: #0d131b;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.segmented button {
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  transition:
    color 0.14s ease,
    background 0.14s ease,
    box-shadow 0.14s ease;
}

.segmented button.active {
  color: #061014;
  background: var(--accent);
}

.segmented button:hover {
  color: var(--text);
  background: #172231;
  box-shadow: inset 0 0 0 1px rgba(105, 167, 255, 0.28);
}

.segmented button.active:hover {
  color: #061014;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(46, 211, 183, 0.24);
}

.hunter-status {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.status-cell {
  min-height: 72px;
  padding: 12px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

.status-cell span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.status-cell strong {
  display: block;
  margin-top: 8px;
  font-size: 17px;
  line-height: 21px;
}

.table-wrap {
  overflow: auto;
  margin-top: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}

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

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
  line-height: 18px;
}

th {
  position: sticky;
  top: 0;
  color: var(--muted);
  background: #101720;
  font-size: 12px;
  font-weight: 800;
}

td {
  color: #dfe8f2;
}

tr:last-child td {
  border-bottom: 0;
}

.mono {
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  word-break: break-all;
}

.hint {
  margin-top: 8px;
  font-size: 12px;
  line-height: 17px;
}

.log-output {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  max-height: 280px;
  overflow: auto;
  padding: 10px;
  background: #0a0f15;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  font-family: "JetBrains Mono", Consolas, monospace;
  font-size: 12px;
  line-height: 18px;
}

.log-output.tall {
  max-height: 680px;
}

.log-line {
  white-space: pre-wrap;
  word-break: break-word;
  color: #d7e2ed;
}

.log-line .time {
  color: var(--subtle);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: 420px;
  padding: 12px 14px;
  color: var(--text);
  background: #172231;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 13px;
  line-height: 18px;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(440px, 100%);
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-brand {
  margin-bottom: 18px;
}

.login-panel h1 {
  margin: 0;
  font-size: 26px;
  line-height: 32px;
}

.login-panel p {
  color: var(--muted);
  font-size: 13px;
  line-height: 19px;
}

.telegram-widget {
  min-height: 48px;
  margin: 18px 0 10px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .layout-2,
  .layout-2.wide-left,
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  html,
  body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }

  .app-shell {
    display: block;
  }

  .app-shell,
  .sidebar,
  .workspace {
    width: 100%;
    max-width: 100%;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .panel-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .topbar p,
  .panel p {
    max-width: calc(100vw - 32px);
    white-space: normal;
  }

  .topbar-actions,
  .actions-row,
  .actions-row.inline {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    width: 100%;
  }

  .field,
  .button,
  input,
  select {
    min-width: 0;
    width: 100%;
    max-width: 100%;
  }

  .metric,
  .panel,
  .topbar-actions {
    max-width: calc(100vw - 32px);
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hunter-status,
  .meta-grid {
    grid-template-columns: 1fr;
  }
}
