:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafd;
  --border: #dbe4ef;
  --border-strong: #c8d6e6;
  --text: #0f1f33;
  --muted: #61748a;
  --primary: #0b7ca5;
  --primary-soft: #e9f5fb;
  --ok: #15803d;
  --warn: #a16207;
  --bad: #dc2626;
  --radius-lg: 14px;
  --radius-md: 10px;
  --radius-sm: 8px;
  --shadow-1: 0 4px 14px rgba(15, 23, 42, 0.06);
  --shadow-2: 0 10px 24px rgba(15, 23, 42, 0.1);
  --ring: 0 0 0 3px rgba(11, 124, 165, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
}

.shell {
  width: min(1400px, 96vw);
  margin: 1rem auto;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.auth-shell {
  grid-template-columns: 1fr;
  max-width: 460px;
  margin-top: 8vh;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.44);
  opacity: 0;
  visibility: hidden;
  transition: 180ms ease;
  z-index: 60;
}

.mobile-topbar {
  display: none;
}

.mobile-nav-toggle {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  cursor: pointer;
}

.mobile-brand {
  font-weight: 800;
  letter-spacing: -0.01em;
}

.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  position: sticky;
  top: 12px;
  box-shadow: var(--shadow-1);
}

.sidebar h1 {
  margin: 0;
  letter-spacing: -0.02em;
  font-size: 1.7rem;
}

.sidebar p {
  margin: 0.2rem 0 0.9rem;
  color: var(--muted);
}

.sidebar nav {
  display: grid;
  gap: 0.45rem;
}

.nav-link {
  text-decoration: none;
  color: #17314f;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.58rem 0.68rem;
  background: var(--surface);
  font-weight: 700;
  transition: 120ms ease;
}

.nav-link:hover {
  background: var(--surface-soft);
  border-color: var(--border-strong);
}

.nav-link.active {
  color: var(--primary);
  border-color: #9fcee2;
  background: var(--primary-soft);
}

.user-panel {
  margin-top: 1rem;
  display: grid;
  gap: 0.5rem;
}

.user-email {
  font-size: 0.8rem;
  color: var(--muted);
  word-break: break-all;
}

.content {
  min-width: 0;
  display: grid;
  gap: 1rem;
}

.page-head h2 {
  margin: 0;
  letter-spacing: -0.02em;
  font-size: 1.95rem;
}

.page-head p {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.card,
.panel,
.topbar,
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-1);
}

.card h3,
.panel-head h2 {
  margin: 0 0 0.72rem;
  letter-spacing: -0.01em;
}

.panel-head p,
.topbar p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.selected-banner {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--primary-soft);
  border-color: #b8dced;
}

.stats-row,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.68rem;
}

.metric {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: 0.74rem 0.84rem;
}

.metric h4,
.stat-card h3 {
  margin: 0;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
}

.metric p,
.stat-card p {
  margin: 0.35rem 0 0;
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  word-break: break-word;
}

.form-grid {
  display: grid;
  gap: 0.72rem;
}

.cols-3 {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.cols-6 {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

label {
  display: grid;
  gap: 0.32rem;
  font-size: 0.84rem;
  color: #304a67;
  font-weight: 700;
}

input,
select,
button {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.66rem;
  font: inherit;
}

input,
select {
  background: var(--surface);
  color: var(--text);
}

input:focus,
select:focus {
  outline: none;
  border-color: #79bedb;
  box-shadow: var(--ring);
}

button {
  border: none;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  background: linear-gradient(120deg, #096b8d, var(--primary));
  box-shadow: 0 8px 16px rgba(9, 107, 141, 0.24);
  transition: 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

button:active {
  transform: translateY(0);
}

.btn-ghost {
  background: var(--surface);
  color: #28425f;
  border: 1px solid #98adc5;
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--surface-soft);
  transform: none;
}

.checkbox-row,
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.48rem;
  flex-wrap: wrap;
  font-weight: 700;
}

.checkbox-row input,
.checkbox-label input {
  width: auto;
}

.actions-row {
  display: flex;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 0.8rem;
}

.symbol-picker {
  position: relative;
}

.symbol-toggle {
  text-align: left !important;
  background: var(--surface) !important;
  color: var(--text);
  border: 1px solid var(--border) !important;
  padding: 0.62rem 2rem 0.62rem 0.75rem;
  border-radius: var(--radius-sm);
  font-weight: 700;
  position: relative;
  display: grid;
  gap: 0.1rem;
  min-height: 50px;
  box-shadow: none;
}

.symbol-toggle::after {
  content: "▾";
  position: absolute;
  right: 0.72rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.symbol-picker.is-open .symbol-toggle::after {
  content: "▴";
}

.symbol-toggle-main {
  font-size: 0.92rem;
  line-height: 1.15;
}

.symbol-toggle-meta {
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.15;
}

.symbol-panel {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 6px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  padding: 0.5rem;
  z-index: 80;
  display: none;
}

.symbol-picker.is-open .symbol-panel {
  display: block;
}

.symbol-search-input {
  width: 100%;
  margin-bottom: 0.42rem;
}

.symbol-results {
  max-height: 320px;
  overflow: auto;
  border: 1px solid #e5edf5;
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.symbol-result-item {
  width: 100%;
  text-align: left !important;
  border: none;
  background: var(--surface) !important;
  color: var(--text);
  border-radius: 0;
  padding: 0.66rem 0.75rem;
  font-weight: 600 !important;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border-bottom: 1px solid #eef2f7;
  box-shadow: none;
  transform: none;
}

.symbol-result-item:last-child {
  border-bottom: 0;
}

.symbol-result-item:hover,
.symbol-result-item.active {
  background: #eff8fd !important;
}

.symbol-main {
  min-width: 138px;
  font-weight: 800;
  font-size: 0.88rem;
}

.symbol-sub {
  flex: 1;
  color: var(--muted);
  font-size: 0.77rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.symbol-badge {
  display: inline-block;
  border: 1px solid #ccd8e7;
  border-radius: 999px;
  padding: 0.14rem 0.45rem;
  font-size: 0.71rem;
  color: #2f4966;
  background: var(--surface-soft);
}

.symbol-empty {
  color: var(--muted);
  padding: 0.6rem 0.75rem;
  font-size: 0.82rem;
}

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
}

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

th,
td {
  border-bottom: 1px solid #e8eef5;
  padding: 0.54rem 0.58rem;
  text-align: left;
  font-size: 0.81rem;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f7fafd;
  color: #5d738d;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.69rem;
}

tbody tr:nth-child(even) {
  background: #fcfdff;
}

tbody tr:hover {
  background: #f1f7fd;
}

.selected-row {
  background: #eaf6fc !important;
}

.status {
  display: inline-block;
  border-radius: 999px;
  padding: 0.16rem 0.48rem;
  font-size: 0.7rem;
  font-weight: 800;
}

.status.completed { background: #dcfce7; color: var(--ok); }
.status.failed { background: #fee2e2; color: var(--bad); }
.status.running,
.status.queued { background: #fef9c3; color: var(--warn); }
.status.stopped { background: #e2e8f0; color: #475569; }

.error-cell {
  color: #b91c1c;
  max-width: 320px;
  white-space: pre-wrap;
  word-break: break-word;
}

.params-cell {
  max-width: 520px;
  white-space: normal;
  word-break: break-word;
}

.mini-link {
  display: inline-block;
  text-decoration: none;
  border: 1px solid #b5d7e8;
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.74rem;
  font-weight: 700;
  background: #eff9fd;
  color: #0f6c8b;
}

.mini-link:hover {
  background: #e2f3fb;
}

.sort-btn {
  width: auto;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
  box-shadow: none;
  transform: none;
  filter: none;
}

.sort-btn:hover,
.sort-btn:active {
  box-shadow: none;
  transform: none;
  filter: none;
}

.dashboard-shell {
  width: min(1400px, 96vw);
  margin: 1rem auto;
  display: grid;
  gap: 1rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
}

.topbar h1 {
  margin: 0;
  letter-spacing: -0.02em;
}

.chip {
  border: 1px solid #b6d8e8;
  border-radius: 999px;
  padding: 0.22rem 0.68rem;
  background: #eff8fd;
  color: #0f6c8b;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.panel-wide {
  grid-column: 1 / -1;
}

.bg-glow {
  display: none;
}

@media (max-width: 1200px) {
  .panel-grid {
    grid-template-columns: 1fr;
  }

  .table-wrap table {
    min-width: 760px;
  }
}

@media (max-width: 980px) {
  .shell {
    width: min(100vw - 0.8rem, 100%);
    margin: 0.4rem auto;
    grid-template-columns: 1fr;
    gap: 0.72rem;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    position: sticky;
    top: 0.35rem;
    z-index: 70;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(5px);
    box-shadow: var(--shadow-1);
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(320px, 84vw);
    border-radius: 0 14px 14px 0;
    transform: translateX(-105%);
    transition: transform 180ms ease;
    z-index: 80;
    overflow-y: auto;
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  body.nav-open .sidebar-backdrop {
    opacity: 1;
    visibility: visible;
  }

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

  .nav-link {
    text-align: center;
    white-space: nowrap;
  }

  .user-panel {
    grid-template-columns: 1fr;
  }

  .page-head h2 {
    font-size: 1.55rem;
  }
}

@media (max-width: 760px) {
  .shell,
  .dashboard-shell {
    width: min(100vw - 0.56rem, 100%);
    margin: 0.28rem auto;
    gap: 0.6rem;
  }

  .content {
    gap: 0.6rem;
  }

  .card,
  .panel,
  .topbar,
  .stat-card,
  .metric,
  .sidebar {
    border-radius: 12px;
    padding: 0.76rem;
  }

  .selected-banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .cols-3,
  .cols-6 {
    grid-template-columns: 1fr;
  }

  .stats-row,
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.56rem;
  }

  .metric h4,
  .stat-card h3 {
    font-size: 0.66rem;
  }

  .metric p,
  .stat-card p {
    font-size: 0.96rem;
  }

  .actions-row {
    flex-direction: column;
    align-items: stretch;
  }

  .actions-row form,
  .actions-row .mini-link {
    width: 100%;
  }

  .actions-row .mini-link {
    text-align: center;
    padding: 0.46rem 0.62rem;
  }

  th,
  td {
    font-size: 0.76rem;
    padding: 0.46rem 0.48rem;
  }

  .table-wrap table {
    min-width: 700px;
  }

  .params-cell {
    max-width: 260px;
  }

  .symbol-panel {
    max-width: calc(100vw - 0.9rem);
  }

  .symbol-results {
    max-height: 46vh;
  }

  .symbol-result-item {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.16rem;
    padding: 0.55rem 0.62rem;
  }

  .symbol-main {
    min-width: 0;
  }

  .symbol-sub {
    width: 100%;
    white-space: normal;
  }

  .symbol-badge {
    align-self: flex-start;
  }
}

@media (max-width: 520px) {
  body {
    font-size: 15px;
  }

  .auth-shell {
    width: min(100vw - 0.56rem, 100%);
    margin-top: 1.4rem;
  }

  .sidebar nav {
    grid-template-columns: 1fr;
  }

  .stats-row,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .page-head h2 {
    font-size: 1.32rem;
  }

  input,
  select,
  button {
    padding-top: 0.56rem;
    padding-bottom: 0.56rem;
  }

  .table-wrap table {
    min-width: 640px;
  }
}
