@import url('https://fonts.googleapis.com/css2?family=Onest:wght@300;400;500;600;700&family=Unbounded:wght@600;700&family=DM+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #F0F4F8;
  --surface:     #FFFFFF;
  --surface-2:   #F8FAFC;
  --border:      #E3E9F0;
  --border-2:    #D0D9E4;
  --primary:     #4361EE;
  --primary-h:   #3451D1;
  --primary-bg:  #EEF1FD;
  --primary-dim: rgba(67,97,238,.1);
  --danger:      #E53935;
  --danger-bg:   #FEF2F2;
  --success:     #16A34A;
  --success-bg:  #F0FDF4;
  --warning:     #D97706;
  --text:        #111827;
  --text-2:      #374151;
  --muted:       #6B7280;
  --muted-light: #9CA3AF;
  --radius:      12px;
  --radius-sm:   8px;
  --radius-xs:   6px;
  --shadow-sm:   0 1px 2px rgba(0,0,0,.05);
  --shadow:      0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:   0 4px 16px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:   0 12px 40px rgba(0,0,0,.14), 0 4px 12px rgba(0,0,0,.06);
}

body {
  font-family: 'Onest', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Subtle dot-grid background texture */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: -1;
  background-image: radial-gradient(circle, #C9D4E0 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: .45;
  pointer-events: none;
}

/* ── Header ──────────────────────────────────────────────── */

.header {
  position: sticky; top: 0; z-index: 200;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,.03), var(--shadow-sm);
}

.header-inner {
  max-width: 1400px; margin: 0 auto;
  display: flex; align-items: stretch;
  padding: 0 28px; height: 58px; gap: 4px;
}

/* Logo */
.logo {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; flex-shrink: 0;
  padding-right: 20px;
  margin-right: 6px;
  border-right: 1px solid var(--border);
}

.logo-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #4361EE 0%, #7B8FF5 100%);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 8px rgba(67,97,238,.3), inset 0 1px 0 rgba(255,255,255,.2);
  flex-shrink: 0;
}
.logo-mark svg { width: 16px; height: 16px; }

.logo-text {
  font-family: 'Unbounded', sans-serif;
  font-size: 13px; font-weight: 700;
  color: var(--text); letter-spacing: -.2px;
  white-space: nowrap;
}

/* Nav tabs */
.main-nav {
  display: flex; align-items: stretch; gap: 0;
  flex: 1;
}

.nav-item {
  display: flex; align-items: center; gap: 7px;
  padding: 0 14px; color: var(--muted);
  text-decoration: none; font-size: 13.5px; font-weight: 500;
  white-space: nowrap; position: relative;
  transition: color .15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  letter-spacing: -.1px;
}
.nav-item:hover { color: var(--text-2); }
.nav-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.nav-icon { font-size: 13px; }

/* Status pill */
.header-status {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto; flex-shrink: 0;
  align-self: center;
  padding: 5px 14px 5px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
}

.status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted-light); flex-shrink: 0;
  transition: all .4s;
}
.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-bg);
}
.status-dot.pending {
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(217,119,6,.12);
  animation: pulse-dot 1.4s infinite;
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}

.status-label {
  font-size: 12.5px; font-weight: 500; color: var(--text-2);
}

/* ── Page layout ─────────────────────────────────────────── */

.content {
  max-width: 1400px; margin: 0 auto;
  padding: 32px 28px 100px;
}

.page-header { margin-bottom: 24px; }
.page-header h1 {
  font-size: 20px; font-weight: 700;
  letter-spacing: -.5px; color: var(--text);
  margin-bottom: 3px;
}
.page-header a { color: var(--primary); text-decoration: none; }
.page-header a:hover { text-decoration: underline; }
.subtitle { color: var(--muted); font-size: 13.5px; }

/* ── Tabs ────────────────────────────────────────────────── */
.tab        { display: none; animation: fadeUp .2s ease; }
.tab.active { display: block; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Card ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card-title {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; font-weight: 600; color: var(--text);
  margin-bottom: 20px;
}
.card-icon { font-size: 17px; }

.step-num {
  width: 23px; height: 23px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px var(--primary-dim);
}

.step-hint {
  font-size: 13px; color: var(--muted); margin-bottom: 18px;
  line-height: 1.6; padding: 10px 14px;
  background: var(--surface-2); border-radius: var(--radius-xs);
  border-left: 3px solid var(--border-2);
}

/* ── Forms ───────────────────────────────────────────────── */
.form-row { display: flex; gap: 16px; margin-bottom: 0; }
.form-row .form-group { flex: 1; }
.form-group { margin-bottom: 16px; }

.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-2); margin-bottom: 6px;
  letter-spacing: .2px; text-transform: uppercase;
}

input[type="text"],
input[type="password"] {
  width: 100%; background: var(--surface);
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; font-family: inherit;
  padding: 9px 13px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}
input::placeholder { color: var(--muted-light); }

.input-wrap { position: relative; }
.input-wrap input { padding-right: 76px; }

.toggle-pass {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--muted);
  font-size: 12px; font-weight: 500; font-family: inherit; cursor: pointer; padding: 0;
  transition: color .15s;
}
.toggle-pass:hover { color: var(--text); }

.form-note {
  font-size: 12.5px; color: var(--muted); line-height: 1.6; margin-top: 8px;
  padding: 9px 13px; background: var(--surface-2);
  border-radius: var(--radius-xs); border: 1px solid var(--border);
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  padding: 8px 18px;
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500; font-family: inherit;
  cursor: pointer; transition: all .15s;
  display: inline-flex; align-items: center; gap: 6px;
  letter-spacing: -.1px; white-space: nowrap;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(.98); }

.btn-primary {
  background: var(--primary); color: #fff;
  border-color: var(--primary);
  box-shadow: 0 1px 3px rgba(67,97,238,.25);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-h);
  border-color: var(--primary-h);
  box-shadow: 0 3px 10px rgba(67,97,238,.3);
  transform: translateY(-1px);
}

.btn-ghost {
  background: var(--surface); color: var(--text-2);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-2);
}

.btn-danger {
  background: transparent; color: var(--danger);
  border-color: #FECACA;
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger-bg);
  border-color: #FCA5A5;
}

.btn-sm { padding: 5px 12px; font-size: 12.5px; }

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

.save-status {
  font-size: 13px; opacity: 0; transition: opacity .3s; font-weight: 500;
}
.save-status.visible { opacity: 1; color: var(--success); }
.save-status.error   { opacity: 1; color: var(--danger); }

/* ── Lock card ───────────────────────────────────────────── */
.lock-card {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 60px; gap: 14px; text-align: center;
  border-style: dashed; background: var(--surface-2);
}
.lock-icon { font-size: 32px; filter: grayscale(1); opacity: .3; }
.lock-text  { font-size: 14.5px; color: var(--muted); font-weight: 500; }

/* ── Channels list ───────────────────────────────────────── */
.ch-item {
  display: flex; align-items: center; gap: 13px;
  padding: 9px 12px; border-radius: var(--radius-xs);
  cursor: pointer; transition: background .1s;
}
.ch-item:hover { background: var(--primary-bg); }
.ch-item input[type="checkbox"] {
  width: 15px; height: 15px; accent-color: var(--primary);
  cursor: pointer; flex-shrink: 0;
}
.ch-info { flex: 1; min-width: 0; }
.ch-title {
  font-size: 13.5px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ch-handle { font-size: 12px; color: var(--primary); font-family: 'DM Mono', monospace; margin-top: 1px; }
.ch-type {
  font-size: 11px; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 2px 9px; border-radius: 20px; flex-shrink: 0;
  font-weight: 500; letter-spacing: .1px;
}
.ch-sep {
  font-size: 10.5px; color: var(--muted-light);
  padding: 10px 12px 4px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .7px;
}

/* ── Empty / Spinner ─────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 32px;
  color: var(--muted); font-size: 13.5px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.spinner {
  display: inline-block; width: 15px; height: 15px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .65s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Tables ──────────────────────────────────────────────── */
.table-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
}

.table-count {
  font-size: 12px; color: var(--muted); font-weight: 500;
  margin-left: auto;
  background: var(--surface); border: 1px solid var(--border);
  padding: 3px 11px; border-radius: 20px;
  font-family: 'DM Mono', monospace;
}

.check-all-wrap {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--text-2);
  cursor: pointer; user-select: none; font-weight: 500;
}
.check-all-wrap input {
  width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer;
}

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

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

thead th {
  text-align: left; padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 10.5px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px;
  white-space: nowrap; background: var(--surface-2);
}
thead th:first-child { padding-left: 18px; }

tbody tr { transition: background .1s; }
tbody tr:hover { background: #EEF1FD; }
tbody tr:hover td { color: var(--text); }

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid #F3F6FA;
  color: var(--text-2); white-space: nowrap;
}
tbody td:first-child { padding-left: 18px; }
tbody tr:last-child td { border-bottom: none; }

/* Selected row */
tbody tr.selected { background: var(--primary-bg); }
tbody tr.selected td { color: var(--text); }

.col-chk { width: 40px; padding: 10px 6px 10px 18px !important; }
.col-chk input[type="checkbox"] {
  width: 15px; height: 15px; accent-color: var(--primary); cursor: pointer;
}

.cell-ellipsis { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.cell-num    {
  text-align: right; font-variant-numeric: tabular-nums;
  font-family: 'DM Mono', monospace; font-size: 12.5px;
}
.cell-center { text-align: center; }
.cell-mono   {
  font-family: 'DM Mono', monospace; font-size: 12px; color: var(--muted);
}

/* Tag pills in table */
.tag {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 500;
  white-space: nowrap;
}
.tag-blue   { background: var(--primary-bg); color: var(--primary); }
.tag-green  { background: var(--success-bg); color: var(--success); }
.tag-muted  { background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }

/* ── Action bar ──────────────────────────────────────────── */
.action-bar {
  position: sticky; bottom: 20px;
  display: flex; align-items: center; gap: 16px;
  background: var(--text);
  border-radius: var(--radius);
  padding: 13px 18px 13px 22px;
  margin-top: 12px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .2s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.action-bar-sel {
  width: 22px; height: 22px; border-radius: 6px;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: white; flex-shrink: 0;
  font-family: 'DM Mono', monospace;
}
.action-bar-info {
  font-size: 13.5px; font-weight: 500; color: rgba(255,255,255,.6);
}
.action-bar-btns { display: flex; gap: 8px; margin-left: auto; }

.action-bar .btn-ghost {
  background: rgba(255,255,255,.1);
  border-color: rgba(255,255,255,.15);
  color: rgba(255,255,255,.9);
  box-shadow: none;
}
.action-bar .btn-ghost:hover {
  background: rgba(255,255,255,.16);
  border-color: rgba(255,255,255,.25);
}
.action-bar .btn-danger {
  background: rgba(239,68,68,.15);
  border-color: rgba(239,68,68,.3);
  color: #FCA5A5;
}
.action-bar .btn-danger:hover {
  background: rgba(239,68,68,.25);
  border-color: rgba(239,68,68,.5);
}

/* ── Divider in card actions ─────────────────────────────── */
.actions-divider {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #B0BAC9; }
