@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

svg {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}

:root {
  --bg: #0f1117;
  --bg-card: #16191f;
  --bg-input: #0d0f14;
  --border: #262a33;
  --border-2: #313740;
  --accent: #6366f1;
  --accent-dim: #6366f120;
  --green: #22c55e;
  --red: #ef4444;
  --orange: #f59e0b;
  --blue: #3b82f6;
  --purple: #6366f1;
  --text: #e4e6ea;
  --text-2: #8b909a;
  --text-3: #4b5060;
  --radius: 8px;
  --radius-lg: 12px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  font-size: 14px;
}

/* ── LAYOUT ─────────────────────────────── */
.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
}

.wrap-lg {
  max-width: 1020px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ── TOPBAR ─────────────────────────────── */
.topbar {
  height: 52px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  text-decoration: none;
}

.logo-box {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.topbar-link {
  font-size: 13px;
  color: var(--text-2);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.topbar-link:hover {
  color: var(--text);
}

/* ── CARD ───────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}

.card-title svg {
  color: var(--text-2);
}

/* ── FORM ───────────────────────────────── */
.fg {
  margin-bottom: 14px;
}

.fg label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 5px;
}

.fg label .req {
  color: var(--accent);
}

.fg input,
.fg select,
.fg textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.15s;
}

.fg input:focus,
.fg select:focus,
.fg textarea:focus {
  border-color: var(--accent);
}

.fg input::placeholder,
.fg textarea::placeholder {
  color: var(--text-3);
}

.fg textarea {
  resize: vertical;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238b909a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
  cursor: pointer;
}

select option {
  background: var(--bg-card);
}

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

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

/* ── BUTTON ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: opacity 0.15s, background 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active {
  opacity: 0.75;
}

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

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: #4f51d4;
}

.btn-success {
  background: #22c55e18;
  color: var(--green);
  border-color: #22c55e30;
}

.btn-success:hover {
  background: #22c55e28;
}

.btn-danger {
  background: #ef444418;
  color: var(--red);
  border-color: #ef444430;
}

.btn-danger:hover {
  background: #ef444428;
}

.btn-warning {
  background: #f59e0b18;
  color: var(--orange);
  border-color: #f59e0b30;
}

.btn-warning:hover {
  background: #f59e0b28;
}

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--bg-card);
  color: var(--text);
}

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

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-lg {
  padding: 10px 18px;
  font-size: 14px;
}

/* ── BADGE ──────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid transparent;
}

.b-pending {
  background: #f59e0b15;
  color: var(--orange);
  border-color: #f59e0b25;
}

.b-approved {
  background: #3b82f615;
  color: var(--blue);
  border-color: #3b82f625;
}

.b-warning {
  background: #f59e0b15;
  color: var(--orange);
  border-color: #f59e0b25;
}

.b-progress {
  background: #6366f115;
  color: var(--purple);
  border-color: #6366f125;
}

.b-done {
  background: #22c55e15;
  color: var(--green);
  border-color: #22c55e25;
}

.b-error {
  background: #ef444415;
  color: var(--red);
  border-color: #ef444425;
}

.b-rejected {
  background: #ef444415;
  color: var(--red);
  border-color: #ef444425;
}

/* ── STATS ──────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.stat-n {
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.stat-l {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 4px;
}

@media (max-width: 560px) {
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── TABS ───────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.15s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.tab-count {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  border-radius: 100px;
  padding: 0 5px;
  min-width: 17px;
  height: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── QUEUE ITEM ─────────────────────────── */
.q-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.q-item:hover {
  border-color: var(--border-2);
}

.q-item.dragging {
  opacity: 0.4;
  border-style: dashed;
  border-color: var(--accent);
}

.q-item.drag-over {
  border-color: var(--blue);
  background: #3b82f608;
}

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

.drag-handle {
  color: var(--text-3);
  cursor: grab;
  padding: 2px;
  flex-shrink: 0;
}

.drag-handle:active {
  cursor: grabbing;
}

.q-num {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
  color: var(--text-2);
}

.q-name {
  font-weight: 600;
  font-size: 14px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.q-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.q-meta {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  margin-left: 36px;
  font-size: 12px;
  color: var(--text-3);
  flex-wrap: wrap;
  align-items: center;
}

.q-meta span {
  display: flex;
  align-items: center;
  gap: 3px;
}

.q-detail {
  display: none;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-top: 10px;
  margin-left: 36px;
  font-size: 13px;
}

.q-detail.open {
  display: block;
}

.q-detail table {
  width: 100%;
  border-collapse: collapse;
}

.q-detail td {
  padding: 4px 0;
  vertical-align: top;
}

.q-detail td:first-child {
  color: var(--text-2);
  width: 110px;
  padding-right: 10px;
}

/* ── TABLE (public queue) ───────────────── */
.qtable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.qtable th {
  padding: 8px 12px;
  text-align: left;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.qtable td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.qtable tr:last-child td {
  border-bottom: none;
}

/* ── LOGIN ──────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 360px;
}

.login-box .card {
  padding: 28px;
}

/* ── TOAST ──────────────────────────────── */
.toast-wrap {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 16px #00000040;
  min-width: 220px;
  max-width: 320px;
  animation: fin 0.2s ease;
}

@keyframes fin {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.toast.ok {
  border-left: 3px solid var(--green);
}

.toast.err {
  border-left: 3px solid var(--red);
}

/* ── EMPTY ──────────────────────────────── */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
}

.empty svg {
  margin-bottom: 8px;
}

.empty p {
  font-size: 13px;
}

/* ── SUCCESS ─────────────────────────────── */
.success-box {
  text-align: center;
  padding: 36px 20px;
}

.success-box svg {
  color: var(--green);
  margin-bottom: 12px;
}

/* ── HERO ───────────────────────────────── */
.hero {
  padding: 40px 0 28px;
}

.hero h1 {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 6px;
}

.hero p {
  font-size: 14px;
  color: var(--text-2);
}

/* ── MISC ───────────────────────────────── */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.hidden {
  display: none !important;
}

.mt2 {
  margin-top: 16px;
}

.mt1 {
  margin-top: 8px;
}

.err-msg {
  font-size: 12px;
  color: var(--red);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
}