/* ═══════════════════════════════════════════════════
   TTSMarker Admin — Studio-matched dark theme
   ═══════════════════════════════════════════════════ */
:root {
  --bg:           #0a0c10;
  --bg-elevated:  #12151c;
  --surface:      #181c26;
  --surface-hover:#1e2430;
  --border:       rgba(255,255,255,0.08);
  --border-hover: rgba(91,140,255,0.3);
  --text:         #f0f2f7;
  --muted:        #94a0b8;
  --accent:       #5b8cff;
  --accent-2:     #3dd6c5;
  --success:      #3dd68c;
  --danger:       #ff5f5f;
  --warn:         #f5c542;
  --radius:       10px;
  --radius-sm:    7px;
  --sidebar-w:    248px;
  --topbar-h:     52px;
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
}

body { display: flex; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: #8eb0ff; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
[hidden] { display: none !important; }
code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.85em;
  color: var(--accent-2);
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* ════════════════════════ SIDEBAR ════════════════════════ */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  height: 100vh;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  z-index: 100;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  padding: 16px 16px 12px;
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}
.sidebar-brand img {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
  object-fit: cover;
}
.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}
.sidebar-brand-name {
  font-weight: 800;
  font-size: 1.02rem;
  letter-spacing: -0.02em;
}
.sidebar-brand-sub {
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 8px;
}

.sidebar-section-label {
  padding: 14px 18px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--muted);
  opacity: 0.7;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
  transition: color 0.15s, background 0.15s;
}
.sidebar-item svg { flex-shrink: 0; }
.sidebar-item:hover { color: var(--text); background: rgba(255,255,255,0.05); }
.sidebar-item.active {
  color: #0a0c10;
  background: var(--accent-2);
  font-weight: 700;
}
.sidebar-item.active svg { stroke: #0a0c10; }

.sidebar-user {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 10px;
  flex-shrink: 0;
}

.sidebar-user-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.03);
}

.sidebar-avatar-wrap {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  flex-shrink: 0;
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
}
.sidebar-avatar-fallback {
  font-size: 0.85rem;
  font-weight: 700;
  color: #0a0c10;
}
.sidebar-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.sidebar-username {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-hint {
  font-size: 0.72rem;
  color: var(--muted);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 90;
}

/* ════════════════════════ BODY / TOPBAR ════════════════════════ */
.admin-body {
  flex: 1;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.topbar-hamburger {
  display: none;
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px;
  border-radius: 8px;
}
.topbar-hamburger:hover { background: rgba(255,255,255,0.06); color: var(--text); }

.topbar-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-badge {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(91,140,255,0.15);
  color: #8eb0ff;
  border: 1px solid rgba(91,140,255,0.25);
}

.btn-logout {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.btn-logout:hover {
  color: var(--text);
  border-color: var(--border-hover);
  background: rgba(255,255,255,0.04);
}

/* ════════════════════════ PANEL ════════════════════════ */
.panel {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 20px 22px 32px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.page-head h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.page-desc {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.85rem;
  max-width: 640px;
  line-height: 1.45;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 14px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.card-title {
  font-size: 0.92rem;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
  margin: 0 -6px;
  padding: 0 6px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.table th, .table td {
  padding: 11px 10px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
}
.table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.table tbody tr:hover { background: rgba(255,255,255,0.025); }
.table tbody tr:last-child td { border-bottom: none; }
.cell-sub {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

/* ════════════════════════ FORMS / BUTTONS ════════════════════════ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.form-grid label {
  display: grid;
  gap: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 4px;
}

.panel input,
.panel select,
.panel textarea,
.modal input,
.modal select,
.modal textarea,
.login-card input {
  width: 100%;
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  color-scheme: dark;
}
.panel textarea,
.modal textarea { resize: vertical; min-height: 64px; }
.panel input:focus,
.panel select:focus,
.panel textarea:focus,
.modal input:focus,
.modal select:focus,
.modal textarea:focus,
.login-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91,140,255,0.15);
}
.panel input[readonly],
.modal input[readonly] {
  opacity: 0.7;
  cursor: default;
}

.btn, .panel button, .modal button, .login-card button {
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-weight: 650;
  font-size: 0.85rem;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  transition: filter 0.15s, transform 0.1s;
}
.btn:hover, .panel button:hover, .modal button:hover, .login-card button:hover { filter: brightness(1.08); }
.btn:active, .panel button:active, .modal button:active { transform: translateY(1px); }

.btn-primary, .panel button.btn-primary, .modal button.btn-primary {
  background: var(--accent-2);
  color: #0a0c10;
}
.btn-ghost, .panel button.btn-ghost, .modal button.btn-ghost {
  background: transparent !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
}
.btn-ghost:hover, .panel button.btn-ghost:hover, .modal button.btn-ghost:hover {
  border-color: var(--border-hover) !important;
  background: rgba(255,255,255,0.04) !important;
  filter: none;
}
.btn-ok, .panel button.btn-ok, .modal button.btn-ok {
  background: var(--accent-2) !important;
  color: #0a0c10 !important;
}
.btn-danger, .panel button.btn-danger, .modal button.btn-danger {
  background: var(--danger) !important;
  color: #fff !important;
}
.btn-sm, .panel button.btn-sm, .modal button.btn-sm {
  padding: 6px 10px;
  font-size: 0.78rem;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.filter-bar .btn-ghost.active {
  background: rgba(61,214,197,0.12) !important;
  border-color: rgba(61,214,197,0.4) !important;
  color: var(--accent-2) !important;
}

.search-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  max-width: 420px;
}
.search-bar input { flex: 1; min-width: 180px; }

/* ════════════════════════ BADGES / STATUS ════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.badge-ok {
  background: rgba(61,214,140,0.14);
  color: var(--success);
  border: 1px solid rgba(61,214,140,0.28);
}
.badge-off {
  background: rgba(148,160,184,0.12);
  color: var(--muted);
  border: 1px solid rgba(148,160,184,0.22);
}
.badge-pending {
  background: rgba(245,197,66,0.14);
  color: var(--warn);
  border: 1px solid rgba(245,197,66,0.3);
}
.badge-done {
  background: rgba(61,214,197,0.14);
  color: var(--accent-2);
  border: 1px solid rgba(61,214,197,0.28);
}
.badge-bad {
  background: rgba(255,95,95,0.14);
  color: var(--danger);
  border: 1px solid rgba(255,95,95,0.28);
}

.delta-pos { color: var(--success); font-weight: 650; }
.delta-neg { color: var(--danger); font-weight: 650; }

.muted { color: var(--muted); }
.err { color: var(--danger); font-size: 0.85rem; }
.ok-msg { color: var(--success); font-size: 0.85rem; }

/* ════════════════════════ LOADING ════════════════════════ */
.loading-state {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0;
}
.skeleton {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}
.skeleton-card {
  height: 120px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
}
.skeleton.w40 { width: 40%; }
.skeleton.w60 { width: 60%; }
.skeleton.w80 { width: 80%; }
.skeleton.w100 { width: 100%; }

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
  vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
}
.empty-state p { margin-top: 8px; font-size: 0.9rem; }

audio {
  max-width: 200px;
  height: 32px;
  margin-top: 4px;
  display: block;
}

/* ════════════════════════ MODAL ════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(6, 8, 14, 0.82);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.is-open {
  display: flex;
  animation: overlayIn 0.18s ease both;
}
.modal-overlay[hidden] { display: none !important; }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 720px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 28px 80px rgba(0,0,0,0.55);
  animation: modalIn 0.2s ease both;
  overflow: hidden;
}
.modal.modal-sm { max-width: 420px; }
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.98) translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.modal-header {
  padding: 16px 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}
.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.modal-close {
  border: none !important;
  background: transparent !important;
  color: var(--muted) !important;
  padding: 6px !important;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  filter: none !important;
  transform: none !important;
}
.modal-close:hover {
  background: rgba(255,255,255,0.06) !important;
  color: var(--text) !important;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  background: var(--surface);
}
.modal-body .form-grid label {
  color: var(--muted);
}
.modal-footer {
  padding: 14px 20px;
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
  background: var(--bg-elevated);
}
.modal-footer:empty { display: none; }

.table-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ════════════════════════ LOGIN ════════════════════════ */
.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  width: 100%;
  overflow: auto;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(61,214,197,0.12), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 80%, rgba(91,140,255,0.1), transparent 50%),
    var(--bg);
}

.login-card {
  width: min(400px, 92vw);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 26px;
  display: grid;
  gap: 14px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}
.login-brand img {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  object-fit: cover;
}
.login-card h1 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.login-card .login-sub {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2px;
}
.login-card label {
  display: grid;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}
.login-card button {
  margin-top: 4px;
  background: var(--accent-2);
  color: #0a0c10;
  padding: 11px 14px;
  font-weight: 700;
}

/* ════════════════════════ RESPONSIVE ════════════════════════ */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  body.sidebar-open .sidebar { transform: translateX(0); }
  body.sidebar-open .sidebar-backdrop { display: block; }
  .topbar-hamburger { display: inline-flex; }
  .panel { padding: 16px; }
}
