/* ─── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 220px;
  --bg:        #0f172a;
  --surface:   #1e293b;
  --surface2:  #263347;
  --border:    #334155;
  --accent:    #6366f1;
  --accent-h:  #818cf8;
  --text:      #e2e8f0;
  --muted:     #94a3b8;
  --success:   #22c55e;
  --danger:    #f87171;
  --warning:   #fbbf24;
  --radius:    10px;
  --shadow:    0 4px 24px rgba(0,0,0,.35);
}

html, body { height: 100%; font-family: system-ui, -apple-system, sans-serif; font-size: 14px; }
body { background: var(--bg); color: var(--text); overflow: hidden; }

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.layout { display: flex; height: 100vh; }

/* ─── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  gap: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
}
.brand-icon {
  width: 34px; height: 34px;
  background: var(--accent);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff; letter-spacing: 0.5px;
}
.brand-text { font-size: 15px; font-weight: 600; color: var(--text); }

/* Nav */
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius);
  color: var(--muted); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: all .15s;
}
.nav-item svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(99,102,241,.18); color: var(--accent-h); }

/* Client box */
.client-box { margin-top: auto; }
.client-label { font-size: 11px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin-bottom: 7px; padding: 0 4px; }
.client-row { display: flex; gap: 6px; }
.client-select {
  flex: 1; background: var(--surface2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: 13px; cursor: pointer;
}
.btn-add {
  width: 32px; height: 32px; background: var(--accent); color: #fff;
  border: none; border-radius: 8px; font-size: 18px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.btn-add:hover { background: var(--accent-h); }

/* ─── Main ───────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.header {
  padding: 18px 28px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 16px;
}
.page-title { font-size: 18px; font-weight: 600; flex: 1; }

/* ─── Pages ──────────────────────────────────────────────────────────────── */
.page { display: none; flex: 1; overflow-y: auto; padding: 24px 28px; flex-direction: column; gap: 20px; }
.page.active { display: flex; }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.cards-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.card-full { grid-column: 1 / -1; }
.card-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.card-title-row { display: flex; align-items: center; justify-content: space-between; }
.card-title-row > span { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; }
label { font-size: 12px; color: var(--muted); font-weight: 500; }
.hint { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: 6px; }

.input {
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-size: 13px; width: 100%;
  outline: none; transition: border-color .15s;
}
.input:focus { border-color: var(--accent); }
.input:disabled { opacity: .5; cursor: not-allowed; }
select.input { cursor: pointer; }

.input-sm { padding: 5px 10px; font-size: 12px; width: auto; }

.textarea { resize: vertical; min-height: 130px; line-height: 1.6; font-family: inherit; }

/* Secret inputs */
.secret-wrap { position: relative; }
.secret-wrap .input { padding-right: 38px; }
.eye-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; color: var(--muted);
  padding: 2px; display: flex; align-items: center;
  transition: color .15s;
}
.eye-btn:hover { color: var(--text); }
.eye-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Webhook URL */
.webhook-url { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; padding: 8px 0 2px; }
.label-muted { color: var(--muted); }
.webhook-url code { color: var(--accent-h); font-size: 11.5px; word-break: break-all; }

/* Tools list */
.tools-list { display: flex; flex-direction: column; gap: 8px; }
.tool-item { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.tool-item input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.tool-item span { font-size: 13px; }
.tool-item .tool-badge {
  margin-left: auto;
  font-size: 10px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase;
  padding: 2px 6px; border-radius: 4px;
  background: rgba(248,113,113,.15); color: var(--danger);
}

/* ─── Bottom bar ─────────────────────────────────────────────────────────── */
.bottom-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 0 4px;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: transparent;
  transition: background .3s;
}
.status-dot.ok   { background: var(--success); }
.status-dot.err  { background: var(--danger); }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: 8px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; transition: all .15s; white-space: nowrap;
}
.btn-primary  { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: var(--accent-h); }
.btn-ghost    { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover    { border-color: var(--accent); color: var(--accent-h); }
.btn-danger   { background: rgba(248,113,113,.15); color: var(--danger); border: 1px solid rgba(248,113,113,.3); }
.btn-danger:hover   { background: rgba(248,113,113,.25); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

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

/* ─── Stats row ──────────────────────────────────────────────────────────── */
.stats-row { display: flex; gap: 12px; flex-wrap: wrap; padding-bottom: 4px; }
.stat-chip {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 14px;
  font-size: 12px; color: var(--muted);
  display: flex; flex-direction: column; gap: 2px;
}
.stat-chip strong { font-size: 20px; font-weight: 700; color: var(--text); }

/* ─── Table ──────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 9px 14px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: var(--muted);
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.table td { padding: 10px 14px; border-bottom: 1px solid rgba(51,65,85,.5); vertical-align: middle; }
.table tbody tr:hover td { background: var(--surface2); }
.table tbody tr:last-child td { border-bottom: none; }

/* Status badges */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-pending  { background: rgba(251,191,36,.15); color: var(--warning); }
.badge-shipped  { background: rgba(99,102,241,.15);  color: var(--accent-h); }
.badge-completed{ background: rgba(34,197,94,.15);   color: var(--success); }
.badge-cancelled{ background: rgba(248,113,113,.15); color: var(--danger); }

/* ─── Pagination ─────────────────────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; padding: 12px 0 4px; flex-wrap: wrap; }
.pg-btn {
  min-width: 32px; height: 32px; border-radius: 7px;
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 0 8px; transition: all .15s;
}
.pg-btn:hover { border-color: var(--accent); }
.pg-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.pg-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
  width: 480px; max-width: 95vw; max-height: 90vh;
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-title { padding: 18px 20px 14px; font-size: 15px; font-weight: 600; border-bottom: 1px solid var(--border); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ─── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  padding: 7px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  opacity: 0; pointer-events: none;
  transition: opacity .25s;
  max-width: 360px;
}
.toast.show { opacity: 1; }
.toast.ok  { background: rgba(34,197,94,.15); color: var(--success); border: 1px solid rgba(34,197,94,.3); }
.toast.err { background: rgba(248,113,113,.15); color: var(--danger); border: 1px solid rgba(248,113,113,.3); }

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── Empty state ────────────────────────────────────────────────────────── */
.empty { padding: 40px; text-align: center; color: var(--muted); font-size: 13px; }
