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

:root {
  --bg:        #080e0a;
  --bg2:       #0f1a12;
  --bg3:       #141f16;
  --border:    #1a2e1e;
  --border2:   #243b28;
  --muted:     #3d6b47;
  --sub:       #7ab588;
  --text:      #e8f5eb;
  --accent:    #22c55e;
  --accent-d:  #15803d;
  --danger:    #ef4444;
  --warn:      #f59e0b;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; min-height: 100vh; }

/* ── NAV ── */
nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

.back-link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s;
}
.back-link:hover { color: var(--sub); }

.nav-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.auth-info {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
}

.auth-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
}
.auth-dot.connected { background: var(--accent); box-shadow: 0 0 0 2px rgba(34,197,94,.25); }

/* ── LAYOUT ── */
.layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - 53px);
}

/* ── SIDEBAR ── */
.sidebar {
  width: 260px;
  min-width: 260px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.section {}

.section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
}

.field-label {
  display: block;
  font-size: 11px;
  color: var(--sub);
  margin-bottom: 5px;
  margin-top: 12px;
}
.field-label:first-of-type { margin-top: 0; }

.field-input,
.field-textarea,
select.field-input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.field-input:focus,
.field-textarea:focus,
select.field-input:focus {
  border-color: var(--accent-d);
}
.field-textarea { resize: vertical; min-height: 60px; }

select.field-input option { background: var(--bg2); }

.field-hint {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 6px;
}
.field-hint a { color: var(--accent); text-decoration: none; }
.field-hint a:hover { text-decoration: underline; }

/* Slots */
.slots-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
  min-height: 26px;
}

.slot-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg3);
  border: 1px solid var(--border2);
  border-radius: 99px;
  padding: 3px 8px 3px 10px;
  font-size: 12px;
  color: var(--sub);
}

.slot-rm {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 1px;
  transition: color 0.1s;
}
.slot-rm:hover { color: var(--danger); }

.slot-add-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.field-input-sm {
  width: 80px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.field-input-sm:focus { border-color: var(--accent-d); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #0a1209;
}
.btn-primary:not(:disabled):hover { background: #16a34a; }

.btn-ghost {
  background: var(--bg3);
  color: var(--sub);
  border: 1px solid var(--border2);
}
.btn-ghost:not(:disabled):hover { border-color: var(--sub); color: var(--text); }

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

/* ── CONTENT AREA ── */
.content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── EMPTY STATE ── */
.view-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.drop-zone {
  border: 2px dashed var(--border2);
  border-radius: 20px;
  padding: 60px 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  max-width: 480px;
  width: 100%;
}

.drop-zone:hover,
.drop-zone.over {
  border-color: var(--accent);
  background: rgba(34,197,94,.04);
}

.drop-icon {
  font-size: 40px;
  color: var(--border2);
  line-height: 1;
  margin-bottom: 16px;
  font-weight: 300;
}

.drop-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.drop-sub {
  font-size: 13px;
  color: var(--sub);
  margin-bottom: 8px;
}

.drop-hint {
  font-size: 11px;
  color: var(--muted);
}

/* ── QUEUE ── */
.view-queue {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: outline 0.15s;
}
.view-queue.drag-target { outline: 2px dashed var(--accent); outline-offset: -4px; }

.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
  flex-shrink: 0;
}

.queue-count {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.queue-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.table-wrap {
  flex: 1;
  overflow-y: auto;
}
.table-wrap::-webkit-scrollbar { width: 4px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

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

.queue-table thead {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}

.queue-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

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

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

.queue-table tr.row-done  td { opacity: 0.55; }
.queue-table tr.row-error td { background: rgba(239,68,68,.05); }

.td-order {
  width: 32px;
  color: var(--muted);
  font-size: 12px;
}

.td-title { min-width: 200px; }

.title-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.title-input:not(:disabled):hover {
  border-color: var(--border2);
  background: var(--bg2);
}
.title-input:not(:disabled):focus {
  border-color: var(--accent-d);
  background: var(--bg2);
}
.title-input:disabled { opacity: 0.6; }

.td-size {
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
  width: 80px;
}

.td-when {
  white-space: nowrap;
  font-size: 12px;
  color: var(--sub);
  width: 140px;
}
.td-when.past { color: var(--warn); }

.td-status { width: 80px; }

.s-uploading { color: var(--accent);  font-size: 12px; font-weight: 600; }
.s-done      { color: var(--accent);  font-size: 12px; }
.s-error     { color: var(--danger);  font-size: 12px; cursor: help; }

.td-rm { width: 36px; text-align: center; }

.btn-rm {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.1s, background 0.1s;
}
.btn-rm:hover { color: var(--danger); background: rgba(239,68,68,.1); }

/* Progress bar inside table */
.prog-bar {
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  margin-top: 5px;
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s;
}

/* ── SETUP NOTICE ── */
.setup-notice {
  background: rgba(34,197,94,.06);
  border: 1px solid rgba(34,197,94,.2);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 11px;
  color: var(--sub);
  line-height: 1.6;
  margin-top: 6px;
}
.setup-notice strong { color: var(--accent); }
.setup-notice ol { padding-left: 14px; margin-top: 6px; }
.setup-notice li { margin-bottom: 3px; }
.setup-notice a  { color: var(--accent); text-decoration: none; }
.setup-notice a:hover { text-decoration: underline; }

/* ── HELP BUTTON ── */
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title-row .section-title { margin-bottom: 0; }

.help-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid var(--border2);
  background: var(--bg3);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
  line-height: 1;
}
.help-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }

.modal-body {
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-track { background: transparent; }
.modal-body::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* Tutorial steps */
.tutorial-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.step-num {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 50%;
  background: rgba(34,197,94,.12);
  border: 1px solid rgba(34,197,94,.3);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
}

.step-content {}

.step-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.step-desc {
  font-size: 12px;
  color: var(--sub);
  line-height: 1.6;
}
.step-desc a    { color: var(--accent); text-decoration: none; }
.step-desc a:hover { text-decoration: underline; }
.step-desc strong { color: var(--text); font-weight: 600; }
.step-desc code {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  color: var(--accent);
}

/* ── UTILS ── */
.hidden { display: none !important; }

@media (max-width: 720px) {
  .layout { flex-direction: column; height: auto; }
  .sidebar { width: 100%; min-width: unset; border-right: none; border-bottom: 1px solid var(--border); }
  .content { min-height: 60vh; }
}
