* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #f4f5f7; color: #1f2937; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: #111827; color: #fff; }
.topbar h1 { font-size: 18px; margin: 0; }
.lang-switcher { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 13px; color: #cbd5e1; }
.lang-switcher select { padding: 6px 10px; border: 1px solid #374151; background: #1f2937; color: #fff; border-radius: 6px; font-size: 15px; }
.lang-switcher select:focus { outline: 2px solid #2563eb; outline-offset: -1px; }

.tabs { display: flex; gap: 4px; }
.tab { background: transparent; color: #cbd5e1; border: 0; padding: 8px 16px; cursor: pointer; border-radius: 6px; font-size: 14px; }
.tab:hover { background: rgba(255,255,255,0.06); }
.tab.active { background: #2563eb; color: #fff; }

.container { padding: 24px; max-width: 1200px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.panel-head h2 { margin: 0; font-size: 20px; }
.filters { display: flex; gap: 12px; align-items: center; }
.filters label { font-size: 13px; color: #475569; }
.filters select { padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; font-size: 15px; }
.filters .search-input { padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; font-size: 15px; min-width: 200px; }
.filters .search-input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,.15); }

.hashtag-filter { position: relative; display: inline-block; }
.hashtag-filter-toggle {
  padding: 8px 28px 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
  cursor: pointer;
  min-width: 160px;
  max-width: 260px;
  text-align: left;
  color: #1e293b;
  position: relative;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hashtag-filter-toggle::after {
  content: '▾';
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 10px;
}
.hashtag-filter-toggle.has-selection { border-color: #2563eb; color: #1d4ed8; font-weight: 500; }
.hashtag-filter-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
  min-width: 240px;
  max-width: 320px;
  max-height: 300px;
  display: flex;
  flex-direction: column;
  padding: 6px;
}
.hashtag-filter-menu.hidden { display: none; }
.hashtag-filter-menu .menu-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 6px 6px;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 4px;
  font-size: 11px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.hashtag-filter-menu .menu-head button {
  background: transparent;
  border: 0;
  color: #2563eb;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  text-transform: none;
  letter-spacing: normal;
}
.hashtag-filter-menu .menu-head button:disabled { color: #cbd5e1; cursor: not-allowed; }
.hashtag-filter-menu .menu-body { overflow-y: auto; flex: 1 1 auto; }
.hashtag-filter-menu .hashtag-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: #1e293b;
  font-weight: 400;
}
.hashtag-filter-menu .hashtag-opt:hover { background: #f8fafc; }
.hashtag-filter-menu .hashtag-opt input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: #2563eb;
  flex-shrink: 0;
}
.hashtag-filter-menu .empty-opts { padding: 12px 8px; color: #94a3b8; font-size: 12px; }

table.data { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #e5e7eb; font-size: 13px; vertical-align: middle; }
table.data th { background: #f8fafc; color: #475569; font-weight: 600; }
table.data tr:last-child td { border-bottom: 0; }
table.data img.thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 4px; background: #f1f5f9; }
.id-cell { font-family: ui-monospace, monospace; font-size: 11px; color: #64748b; }

.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 13px; color: #475569; }
.pager button { padding: 4px 10px; border: 1px solid #cbd5e1; background: #fff; border-radius: 6px; cursor: pointer; }
.pager button:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: #2563eb; color: #fff; border: 0; padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500; }
.btn-primary:hover { background: #1d4ed8; }
.btn-ghost { background: transparent; border: 1px solid #cbd5e1; padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.btn-danger { background: #dc2626; color: #fff; border: 0; padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; }
.btn-edit { background: #f59e0b; color: #fff; border: 0; padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; margin-right: 4px; }
.btn-upload { background: #10b981; color: #fff; border: 0; padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; margin-right: 4px; }
.btn-icon { background: transparent; border: 0; font-size: 24px; cursor: pointer; color: #64748b; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-backdrop.hidden { display: none; }
.modal { background: #fff; border-radius: 8px; width: 520px; max-width: 95vw; max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid #e5e7eb; flex: 0 0 auto; }
.modal-head h3 { margin: 0; font-size: 16px; }
#modal-form { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; overflow: hidden; }
#modal-body { padding: 18px; overflow-y: auto; overflow-x: hidden; flex: 1 1 auto; min-height: 0; }
.modal-foot { padding: 12px 18px; border-top: 1px solid #e5e7eb; display: flex; justify-content: flex-end; gap: 8px; flex: 0 0 auto; background: #fff; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: #475569; margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 13px; font-family: inherit; }
.field select { font-size: 15px; padding: 9px 10px; }
.field input:focus, .field select:focus { outline: 2px solid #2563eb; outline-offset: -1px; border-color: #2563eb; }
.field .hint { font-size: 11px; color: #94a3b8; margin-top: 4px; }
.names-grid { display: grid; grid-template-columns: 80px 1fr; gap: 6px; align-items: center; }
.upload-row { display: flex; gap: 12px; align-items: center; }
.upload-row input[type="file"] { flex: 1; padding: 6px 0; border: 0; font-size: 12px; }
.upload-preview { width: 40px; height: 40px; object-fit: cover; border-radius: 4px; background: #f1f5f9; flex-shrink: 0; }

/* Multi-path editor (Image Steps) */
.path-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.path-list:empty { display: none; }
.path-row { display: flex; gap: 6px; align-items: center; padding: 6px; border: 1px solid #e5e7eb; border-radius: 6px; background: #f8fafc; }
.path-row img { width: 36px; height: 36px; object-fit: cover; border-radius: 4px; background: #fff; flex-shrink: 0; }
.path-row .path-index { font-size: 11px; color: #64748b; font-family: ui-monospace, monospace; width: 22px; text-align: center; flex-shrink: 0; }
.path-row input[type="text"] { flex: 1; padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 4px; font-size: 12px; }
.path-row .row-actions { display: flex; gap: 2px; flex-shrink: 0; }
.path-row .row-actions button { background: transparent; border: 1px solid #cbd5e1; padding: 2px 8px; border-radius: 4px; cursor: pointer; font-size: 12px; color: #475569; }
.path-row .row-actions button:hover { background: #fff; }
.path-row .row-actions .btn-remove { color: #dc2626; border-color: #fecaca; }
.steps-cell { display: flex; align-items: center; gap: 6px; }
.steps-cell .step-count { font-size: 11px; color: #475569; background: #e0e7ff; padding: 2px 8px; border-radius: 10px; font-weight: 500; }

.toast { position: fixed; bottom: 24px; right: 24px; background: #111827; color: #fff; padding: 10px 16px; border-radius: 6px; font-size: 13px; z-index: 200; }
.toast.hidden { display: none; }
.toast.error { background: #dc2626; }
.toast.success { background: #16a34a; }

.empty { text-align: center; padding: 32px; color: #94a3b8; font-size: 13px; }

/* Login overlay */
.btn-logout { background: #374151; color: #fff; border: 0; padding: 6px 12px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.btn-logout:hover { background: #4b5563; }
.btn-logout.hidden { display: none; }
.login-backdrop { position: fixed; inset: 0; background: #111827; display: flex; align-items: center; justify-content: center; z-index: 300; }
.login-backdrop.hidden { display: none; }
.login-card { background: #fff; border-radius: 10px; padding: 28px 28px 24px; width: 360px; max-width: 92vw; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.login-card h2 { margin: 0 0 6px; font-size: 20px; color: #111827; }
.login-card .login-hint { margin: 0 0 18px; font-size: 12px; color: #64748b; }
.login-card .btn-primary { width: 100%; padding: 10px 14px; font-size: 14px; }
.login-error { background: #fee2e2; color: #b91c1c; padding: 8px 10px; border-radius: 6px; font-size: 12px; margin-bottom: 12px; }
.login-error.hidden { display: none; }
