:root {
  --bg: #e9eef5;
  --panel: #ffffff;
  --panel-2: #f4f7fb;
  --text: #020817;
  --muted: #5a6678;
  --border: #d8e0ea;
  --primary: #15547b;
  --primary-2: #0f4161;
  --accent: #0f9f8f;
  --ink: #071526;
  --danger: #e22727;
  --warning: #df7b00;
  --success: #16a34a;
  --shadow: 0 18px 46px rgba(13, 30, 49, 0.12);
  --soft-shadow: 0 10px 24px rgba(13, 30, 49, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(21, 84, 123, 0.12), rgba(233, 238, 245, 0) 280px),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  background: #101828;
  color: #fff;
  padding: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--primary);
  font-weight: 800;
}

.brand small,
.nav-label {
  color: #98a2b3;
}

.nav-item {
  width: 100%;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.06);
  color: #fff;
  border-radius: 12px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
}

.content {
  padding: 28px;
  min-width: 0;
}

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

.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 30px;
}

.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.panel-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.panel-body {
  padding: 18px 20px;
}

.btn {
  border: 0;
  border-radius: 12px;
  padding: 12px 20px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 50px;
}

.btn:hover {
  background: var(--primary-2);
}

.btn.secondary {
  background: #eef4ff;
  color: #1d4ed8;
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn.danger {
  background: #fee2e2;
  color: var(--danger);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
}

.truncate {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid var(--border);
  color: var(--muted);
}

.chip.success {
  color: var(--success);
  border-color: rgba(22,163,74,.24);
  background: rgba(22,163,74,.08);
}

.chip.error {
  color: var(--danger);
  border-color: rgba(220,38,38,.24);
  background: rgba(220,38,38,.08);
}

.form {
  display: grid;
  gap: 14px;
}

.field {
  display: grid;
  gap: 7px;
}

label {
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.check {
  display: flex;
  align-items: center;
  gap: 9px;
}

.check input {
  width: auto;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(7, 21, 38, 0.92), rgba(21, 84, 123, 0.78)),
    var(--bg);
}

.login-card {
  width: min(430px, 100%);
  padding: 28px;
  border-color: rgba(255, 255, 255, 0.3);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 420px;
  border-radius: 14px;
  background: linear-gradient(135deg, #071526, #15547b);
  color: #fff;
  padding: 13px 15px;
  box-shadow: var(--shadow);
}

.admin-page {
  min-height: 100vh;
  padding: 18px;
}

.admin-hero {
  min-height: 164px;
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  align-items: center;
  gap: 24px;
  overflow: hidden;
  position: relative;
  padding: 28px 30px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 22px;
  background:
    linear-gradient(135deg, rgba(7, 21, 38, 0.96), rgba(21, 84, 123, 0.94) 48%, rgba(15, 159, 143, 0.88)),
    #15547b;
  color: #fff;
  box-shadow: var(--shadow);
}

.admin-hero::after {
  content: "";
  position: absolute;
  inset: auto -80px -140px auto;
  width: 360px;
  height: 360px;
  border-radius: 50%;
  border: 58px solid rgba(255, 255, 255, 0.12);
}

.hero-copy,
.hero-actions {
  position: relative;
  z-index: 1;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  margin-bottom: 12px;
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.13);
  color: #d9fbf4;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.hero-copy h1 {
  margin: 0 0 8px;
  font-size: 42px;
  line-height: 1;
}

.hero-copy p {
  max-width: 680px;
  margin: 0;
  color: rgba(255, 255, 255, 0.82);
  font-size: 17px;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hero-actions .btn {
  min-width: 132px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.18);
}

.refresh-btn,
.logout-btn {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.refresh-btn:hover,
.logout-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 16px;
  margin: -28px 22px 18px;
  position: relative;
  z-index: 2;
}

.metric-card {
  min-height: 118px;
  display: grid;
  align-content: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
  padding: 20px;
  border: 1px solid rgba(216, 224, 234, 0.86);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--soft-shadow);
}

.metric-card::before {
  content: "";
  width: 6px;
  position: absolute;
  inset: 18px auto 18px 0;
  border-radius: 0 999px 999px 0;
  background: var(--primary);
}

.metric-card span {
  color: #64748b;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.metric-card strong {
  color: var(--ink);
  font-size: 34px;
  line-height: 1;
}

.metric-card small {
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
}

.metric-card.active::before {
  background: var(--accent);
}

.metric-card.success::before {
  background: var(--success);
}

.metric-card.warning::before {
  background: var(--warning);
}

.client-workspace {
  overflow: hidden;
  border: 1px solid rgba(216, 224, 234, 0.9);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.client-toolbar {
  min-height: 92px;
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  align-items: center;
  gap: 18px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(180deg, #ffffff, #f8fafc);
}

.toolbar-title {
  display: grid;
  gap: 3px;
}

.toolbar-title strong {
  color: var(--ink);
  font-size: 18px;
}

.toolbar-title span {
  color: #64748b;
  font-size: 13px;
  font-weight: 700;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.toolbar-controls strong,
.inline-label {
  color: #344054;
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}

.toolbar-controls select {
  width: 146px;
  height: 46px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 0 42px 0 18px;
  color: #020817;
  background:
    linear-gradient(45deg, transparent 50%, #777 50%) calc(100% - 24px) 22px / 7px 7px no-repeat,
    linear-gradient(135deg, #777 50%, transparent 50%) calc(100% - 17px) 22px / 7px 7px no-repeat,
    #fff;
  appearance: none;
}

.search-field {
  width: min(320px, 30vw);
  min-width: 220px;
  height: 46px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 0 14px;
  background: #fff;
}

.search-field span {
  width: 18px;
  height: 18px;
  border: 3px solid #7a8088;
  border-radius: 50%;
  position: relative;
  flex: 0 0 auto;
}

.search-field span::after {
  content: "";
  width: 10px;
  height: 3px;
  position: absolute;
  right: -8px;
  bottom: -5px;
  border-radius: 99px;
  background: #7a8088;
  transform: rotate(45deg);
}

.search-field input {
  height: 44px;
  border: 0;
  border-radius: 0;
  padding: 0 0 0 8px;
  color: #111827;
  background: transparent;
  outline: 0;
  font-size: 16px;
}

.search-field input::placeholder {
  color: #8b93a2;
}

.icon-btn {
  min-height: 50px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  padding: 0 14px;
  background: #fff;
  color: #344054;
  cursor: pointer;
  font-weight: 800;
}

.client-table {
  min-width: 1180px;
  border-collapse: separate;
  border-spacing: 0;
  color: #001432;
  font-size: 17px;
}

.client-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 58px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  color: #020817;
  background: #f2f6fb;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

.client-table td {
  height: 86px;
  padding: 15px 22px;
  border-bottom: 1px solid #eef2f7;
  color: #001432;
  vertical-align: middle;
}

.client-table tbody tr:nth-child(even) {
  background: #fbfcfe;
}

.client-table tbody tr.row-ok {
  background: linear-gradient(90deg, rgba(15, 159, 143, 0.08), rgba(255, 255, 255, 0.98) 36%);
}

.client-table tbody tr.row-error {
  background: linear-gradient(90deg, rgba(226, 39, 39, 0.08), rgba(255, 255, 255, 0.98) 36%);
}

.client-table tbody tr.row-blocked {
  background: linear-gradient(90deg, rgba(223, 123, 0, 0.1), rgba(255, 255, 255, 0.98) 36%);
}

.client-table tbody tr:hover {
  background: #eef7fb;
}

.row-subtitle {
  display: block;
  margin-top: 5px;
  color: #64748b;
  font-size: 13px;
}

.table-link {
  display: block;
  color: #064c86;
  font-weight: 700;
  text-decoration: none;
}

.status-pill {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 104px;
  height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: 0 12px 22px rgba(15, 23, 42, 0.15);
}

.status-pill.success {
  background: #16a34a;
}

.status-pill.error {
  background: #e22727;
}

.status-pill.blocked {
  background: #df7b00;
}

.status-pill.pending {
  background: #64748b;
}

.row-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(58px, 1fr));
  gap: 8px;
  width: 152px;
}

.table-action {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0 8px;
  background: #f3f6fa;
  color: #42526a;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
}

.table-action:hover {
  transform: translateY(-1px);
}

.table-action.test {
  color: #15547b;
  background: #e9f4fb;
}

.table-action.sync {
  color: #0f766e;
  background: #e8f7f5;
}

.table-action.edit {
  color: #6d4fc2;
  background: #f1edff;
}

.table-action.danger {
  color: #b42318;
  background: #fff0f0;
}

.table-action.danger:hover {
  color: #dc2626;
  background: #fee2e2;
}

.empty-row {
  height: 160px;
  color: #667085;
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(7, 21, 38, 0.62);
  backdrop-filter: blur(8px);
}

.modal {
  width: min(560px, 100%);
  max-height: min(760px, calc(100vh - 44px));
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.42);
  box-shadow: 0 30px 80px rgba(7, 21, 38, 0.28);
}

.hidden {
  display: none;
}

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

  .sidebar {
    display: none;
  }

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

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

  .admin-page {
    padding: 12px;
  }

  .admin-hero {
    grid-template-columns: 1fr;
    padding: 24px;
  }

  .hero-copy h1 {
    font-size: 34px;
  }

  .hero-actions {
    flex-wrap: wrap;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 14px 0;
  }

  .client-toolbar {
    grid-template-columns: 1fr;
  }

  .toolbar-controls {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .toolbar-controls select,
  .search-field {
    width: 100%;
    min-width: 0;
  }

  .client-workspace {
    border-radius: 16px;
  }
}

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

  .hero-actions .btn {
    width: 100%;
  }
}
