:root {
  --brand: #0f766e;
  --brand-light: #14b8a6;
  --brand-dark: #0d5c56;
  --bg: #f0f4f3;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #059669;
  --sidebar-w: 240px;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 118, 110, 0.08), 0 4px 16px rgba(15, 118, 110, 0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Login */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f766e 0%, #134e4a 50%, #115e59 100%);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 20px;
  padding: 40px 36px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 24px;
  color: var(--brand);
  margin-top: 8px;
}

.login-logo p {
  color: var(--text-muted);
  font-size: 14px;
  margin-top: 4px;
}

.login-logo .icon {
  width: 56px;
  height: 56px;
  background: linear-gradient(135deg, var(--brand-light), var(--brand));
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #fff;
}

.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--brand);
  color: #fff;
  width: 100%;
  padding: 13px;
  font-size: 15px;
}

.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}

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

.btn-danger { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-warning { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.btn-warning:hover { background: #d97706; color: #fff; border-color: #d97706; }

.row-hidden { background: #fafafa; }
.row-hidden td { opacity: 0.85; }

.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

.btn-brand { background: #ecfdf5; color: var(--brand); border: 1px solid #a7f3d0; }
.btn-brand:hover { background: var(--brand); color: #fff; }

.login-hint {
  margin-top: 20px;
  padding: 12px;
  background: #f0fdfa;
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* App shell */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, #0f766e 0%, #134e4a 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand h2 { font-size: 18px; font-weight: 700; }
.sidebar-brand span { font-size: 12px; opacity: 0.7; }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
  margin-bottom: 4px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-item.active { background: rgba(255,255,255,0.18); color: #fff; font-weight: 600; }

.nav-icon { width: 20px; text-align: center; font-size: 16px; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.admin-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.admin-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.admin-name { font-size: 13px; font-weight: 600; }
.admin-phone { font-size: 11px; opacity: 0.6; }

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 { font-size: 20px; font-weight: 700; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

.content { padding: 24px 28px 40px; flex: 1; }

/* Cards & stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.stat-card-link {
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.stat-card-link:hover {
  border-color: var(--brand);
  box-shadow: 0 4px 16px rgba(25, 183, 178, 0.12);
  transform: translateY(-1px);
}

.stat-card-link:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.stat-card-sub-link {
  color: var(--brand);
  text-decoration: underline;
  cursor: pointer;
}

.stat-card .label { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.stat-card .value { font-size: 28px; font-weight: 700; color: var(--brand); }
.stat-card .sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.panel-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.panel-header h3 { font-size: 16px; font-weight: 700; }

.panel-subtitle {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}
.panel-body { padding: 0; }
.panel-body.padded { padding: 20px 22px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* Toolbar */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.search-input {
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  min-width: 220px;
}

.search-input:focus {
  outline: none;
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}

/* Table */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  text-align: left;
  padding: 12px 18px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:hover { background: #f8fffe; }
tbody tr:last-child td { border-bottom: none; }

.td-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-brand { background: #ecfdf5; color: var(--brand); }
.badge-gray { background: #f1f5f9; color: var(--text-muted); }
.badge-danger { background: #fef2f2; color: var(--danger); }
.badge-admin { background: #fef3c7; color: #b45309; }

.text-ellipsis {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: #475569;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-mono-block {
  max-width: none;
  white-space: normal;
  word-break: break-all;
  line-height: 1.5;
}

.text-muted { color: var(--text-muted); font-size: 13px; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.pagination-btns { display: flex; gap: 6px; }

/* Chart bars */
.bar-chart { padding: 16px 22px 22px; }

.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.bar-label { width: 80px; font-size: 12px; color: var(--text-muted); text-align: right; flex-shrink: 0; }

.bar-track {
  flex: 1;
  height: 24px;
  background: #f1f5f9;
  border-radius: 6px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--brand-light));
  border-radius: 6px;
  transition: width 0.4s ease;
  min-width: 2px;
}

.bar-value { width: 48px; font-size: 13px; font-weight: 600; color: var(--brand); }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.modal {
  background: var(--surface);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-lg { max-width: 720px; }

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

.modal-header h3 { font-size: 17px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

.modal-close:hover { background: var(--bg); }

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 500px) { .form-row { grid-template-columns: 1fr; } }

/* Toast */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  animation: slideIn 0.3s ease;
}

.toast-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.toast-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Comment card in admin */
.comment-card {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}

.comment-card:last-child { border-bottom: none; }

.comment-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e2e8f0;
  object-fit: cover;
}

.table-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  background: #e2e8f0;
}

.table-user-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #475569;
  background: linear-gradient(135deg, #ccfbf1, #99f6e4);
}

.comment-meta { flex: 1; }
.comment-author { font-weight: 600; font-size: 14px; }
.comment-time { font-size: 12px; color: var(--text-muted); }

.comment-content { font-size: 14px; margin-bottom: 8px; line-height: 1.6; }
.comment-img { max-width: 120px; border-radius: 8px; margin-bottom: 8px; }

.replies { margin-left: 42px; margin-top: 10px; }

.reply-item {
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 6px;
  font-size: 13px;
}

.reply-item.admin-reply { background: #ecfdf5; border-left: 3px solid var(--brand); }

.reply-actions { margin-top: 6px; }

.comment-actions { display: flex; gap: 8px; margin-top: 10px; }

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }

.video-preview {
  width: 100%;
  max-height: 240px;
  border-radius: 10px;
  background: #000;
  margin-top: 12px;
}

.spot-preview-cell {
  width: 148px;
  padding: 10px 12px !important;
  vertical-align: middle;
}

.spot-list-preview {
  width: 132px;
  height: 74px;
  border-radius: 8px;
  background: #0f172a;
  object-fit: cover;
  display: block;
}

.spot-list-preview-img {
  cursor: zoom-in;
}

.spot-preview-empty {
  width: 132px;
  height: 74px;
  border-radius: 8px;
  background: #f1f5f9;
  color: var(--text-muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 16px;
}

.upload-zone:hover { border-color: var(--brand-light); background: #f0fdfa; }
.upload-zone.has-file { border-color: var(--brand); background: #ecfdf5; }

.upload-zone input { display: none; }

.field-hint {
  font-size: 13px;
  color: var(--text-muted);
  margin: 6px 0 12px;
}

.map-key-banner {
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  font-size: 13px;
  line-height: 1.6;
}

.map-key-banner code {
  background: rgba(255, 255, 255, 0.7);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.map-key-banner a {
  color: var(--brand);
  font-weight: 600;
}

.rule-preview {
  margin-top: 8px;
  padding: 14px 16px;
  background: #f0fdfa;
  border: 1px solid #99f6e4;
  border-radius: 12px;
  font-size: 14px;
  color: #115e59;
}

.rule-preview-list {
  margin: 8px 0 0 18px;
  line-height: 1.8;
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.toggle-row:last-of-type {
  border-bottom: none;
}

.toggle-row input {
  margin-top: 4px;
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.toggle-row .block-hint {
  display: block;
  margin-top: 4px;
}

.location-search-wrap {
  position: relative;
}

.location-search-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.location-search-row input {
  flex: 1;
  min-width: 0;
}

.location-search-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.location-search-wrap input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 14px;
  background: #fff;
}

.location-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow: auto;
}

.location-suggestion-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border: none;
  background: #fff;
  cursor: pointer;
}

.badge-admin { background: #fef3c7; color: #b45309; }
.badge-success { background: #ecfdf5; color: #059669; }
.badge-warn { background: #fffbeb; color: #d97706; }

.feedback-media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.feedback-media {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f8fafc;
}

.location-suggestion-item:hover {
  background: #f0fdfa;
}

.suggestion-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.suggestion-address {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.location-toolbar {
  margin: 10px 0 12px;
}

.map-picker {
  width: 100%;
  height: 360px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #e2e8f0;
}

.modal .map-picker {
  height: 300px;
}

.location-summary {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #f0fdfa;
  color: #0f766e;
  font-size: 13px;
  line-height: 1.5;
}

.location-summary.is-empty {
  background: #f8fafc;
  color: var(--text-muted);
}
