/* ===== Reset & Base ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Noto Sans TC', 'Segoe UI', sans-serif; background: #0f1117; color: #e0e0e0; min-height: 100vh; }

/* ===== Navigation ===== */
nav { background: #1a1d27; padding: 12px 24px; display: flex; gap: 24px; align-items: center; border-bottom: 1px solid #2a2d37; flex-wrap: wrap; }
nav a { color: #9ca3af; text-decoration: none; font-size: 14px; padding: 6px 12px; border-radius: 6px; transition: all 0.2s; cursor: pointer; }
nav a:hover, nav a.active { color: #fff; background: #2a2d37; }
nav .logo { color: #f59e0b; font-weight: 700; font-size: 16px; margin-right: 12px; cursor: default; }

/* ===== Layout ===== */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.container.full { max-width: 100%; }
h1 { font-size: 24px; margin-bottom: 16px; color: #f9fafb; }

/* ===== Cards & Sections ===== */
.section, .card, .status-card { background: #1a1d27; border-radius: 12px; padding: 20px; border: 1px solid #2a2d37; margin-bottom: 16px; }
.section h2 { font-size: 16px; margin-bottom: 16px; color: #f9fafb; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 32px; }
.card .label, .info-item .label { font-size: 12px; color: #9ca3af; text-transform: uppercase; letter-spacing: 0.5px; }
.card .value { font-size: 32px; font-weight: 700; color: #f9fafb; margin-top: 4px; }
.card .value.highlight { color: #f59e0b; }
.card .value.green { color: #22c55e; }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 16px; }
.info-item { background: #16213e; border-radius: 8px; padding: 12px; }
.info-item .value { font-size: 1.3rem; font-weight: 700; color: #fff; margin-top: 4px; }
.info-item .value.small { font-size: 0.95rem; font-weight: 400; }
.info-item .value.success { color: #4ade80; }
.info-item .value.fail { color: #f87171; }
.info-item .value.warn { color: #facc15; }

/* ===== Tables ===== */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 10px 12px; color: #9ca3af; border-bottom: 1px solid #2a2d37; font-weight: 500; }
td { padding: 10px 12px; border-bottom: 1px solid #1f222c; }
tr:hover { background: #1f222c; }

.table-wrap { background: #1a1d27; border-radius: 12px; border: 1px solid #2a2d37; overflow-x: auto; }

/* ===== Badges & Tags ===== */
.badge { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; }
.badge.done, .badge.completed { background: #166534; color: #86efac; }
.badge.running, .badge.scanning { background: #854d0e; color: #fde047; }
.badge.error { background: #991b1b; color: #fca5a5; }
.badge.pending { background: #374151; color: #9ca3af; }

.tag { display: inline-block; padding: 2px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.tag.yes, .tag.built { background: #166534; color: #86efac; }
.tag.no, .tag.not-built { background: #374151; color: #6b7280; }
.tag.contacted { background: #1e3a5f; color: #93c5fd; }
.tag.checked { background: #854d0e; color: #fde047; }
.tag.chain { background: #5b21b6; color: #c4b5fd; }

.result-tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.result-tag.success { background: #166534; color: #4ade80; }
.result-tag.fail { background: #7f1d1d; color: #f87171; }
.result-tag.skip { background: #78350f; color: #fbbf24; }

.sub-badge { display: inline-block; padding: 2px 10px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.sub-badge.free { background: #374151; color: #9ca3af; }
.sub-badge.pro { background: #854d0e; color: #fde047; }
.sub-badge.business { background: #166534; color: #86efac; }

.plan-tag { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 500; }
.plan-unpublished { background: #374151; color: #6b7280; }
.plan-trial { background: #7c3aed20; color: #a78bfa; border: 1px solid #7c3aed40; }
.plan-free { background: #374151; color: #6b7280; }
.plan-pro { background: #92400e20; color: #fbbf24; border: 1px solid #f59e0b40; }
.plan-business { background: #1e3a5f; color: #60a5fa; border: 1px solid #3b82f640; }

/* ===== Buttons ===== */
.btn { padding: 8px 18px; border-radius: 8px; border: 1px solid #2a2d37; background: #1a1d27; color: #e0e0e0; cursor: pointer; font-size: 13px; transition: all 0.2s; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: #2a2d37; filter: brightness(1.15); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.green { background: #166534; color: #86efac; border-color: #166534; }
.btn.blue { background: #1e3a5f; color: #93c5fd; border-color: #1e3a5f; }
.btn.amber { background: #854d0e; color: #fde047; border-color: #854d0e; }
.btn.red { background: #7f1d1d; color: #fca5a5; border-color: #7f1d1d; }
.btn-primary { background: #f59e0b; color: #000; border-color: #f59e0b; font-weight: 600; }
.btn-primary:hover { background: #d97706; }
.btn-skip { background: #facc15; color: #000; }
.btn-stop { background: #f87171; color: #fff; }
.btn-confirm { background: #4ade80; color: #000; }

/* ===== Forms ===== */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: center; }
.filters select, .filters input { padding: 8px 12px; border-radius: 6px; border: 1px solid #2a2d37; background: #1a1d27; color: #e0e0e0; font-size: 13px; }
.filters label { font-size: 13px; color: #9ca3af; display: flex; align-items: center; gap: 4px; }
.filters input[type="checkbox"] { accent-color: #f59e0b; }

textarea { width: 100%; min-height: 80px; padding: 10px; border-radius: 8px; border: 1px solid #2a2d37; background: #0f1117; color: #e0e0e0; font-size: 14px; font-family: inherit; resize: vertical; }

.quick-scan, .scan-form { display: flex; gap: 8px; margin-bottom: 24px; }
.quick-scan input, .scan-form input[type="text"] { flex: 1; padding: 10px 14px; border-radius: 8px; border: 1px solid #2a2d37; background: #1a1d27; color: #e0e0e0; font-size: 14px; }
.quick-scan input::placeholder, .scan-form input::placeholder { color: #6b7280; }
.quick-scan button, .scan-form button { padding: 10px 20px; border-radius: 8px; border: none; background: #f59e0b; color: #000; font-weight: 600; cursor: pointer; font-size: 14px; }
.quick-scan button:hover, .scan-form button:hover { background: #d97706; }
.quick-scan button:disabled, .scan-form button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Pagination ===== */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 16px; }
.pagination button { padding: 6px 12px; border-radius: 6px; border: 1px solid #2a2d37; background: #1a1d27; color: #e0e0e0; cursor: pointer; font-size: 13px; }
.pagination button:hover { background: #2a2d37; }
.pagination button.active { background: #f59e0b; color: #000; border-color: #f59e0b; }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }

/* ===== Dashboard ===== */
.categories { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-tag { background: #2a2d37; padding: 4px 12px; border-radius: 16px; font-size: 13px; }
.cat-tag .count { color: #f59e0b; margin-left: 4px; }

/* ===== Build Daemon ===== */
.status-header { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.status-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; animation: pulse 2s infinite; }
.status-dot.building { background: #4ade80; }
.status-dot.sleeping { background: #facc15; animation: none; }
.status-dot.done { background: #60a5fa; animation: none; }
.status-dot.idle { background: #9ca3af; animation: none; }
.status-dot.stopped, .status-dot.not_running, .status-dot.unknown { background: #6b7280; animation: none; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
.status-label { font-size: 1.1rem; font-weight: 600; }
.controls { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.countdown { color: #facc15; font-size: 0.85rem; margin-top: 4px; }
.error-msg { color: #f87171; font-size: 0.85rem; margin-top: 8px; }
.history-table { font-size: 0.85rem; }
.history-table th { padding: 8px 10px; border-bottom: 1px solid #2a2a4a; }
.history-table td { padding: 8px 10px; border-bottom: 1px solid #1a1a2e; }
.history-table tr:hover td { background: #16213e; }
.refresh-note { font-size: 0.75rem; color: #6b7280; text-align: right; margin-bottom: 8px; }
.site-link { color: #60a5fa; text-decoration: none; }
.site-link:hover { text-decoration: underline; }
.photo-count { color: #facc15; cursor: pointer; text-decoration: underline; font-size: 0.75rem; }
.photo-count:hover { color: #fde047; }

/* ===== Shops Table ===== */
.shops-table td { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
th[data-sort]:hover { color: #e0e0e0; }
th.sorted { color: #f59e0b; }
.star { color: #f59e0b; }
.has-web { color: #22c55e; }
.no-web { color: #6b7280; }
.build-btn { padding: 3px 10px; border-radius: 4px; border: 1px solid #f59e0b; background: transparent; color: #f59e0b; cursor: pointer; font-size: 12px; white-space: nowrap; }
.build-btn:hover { background: #f59e0b; color: #000; }
.build-btn.building, .enhance-btn.building { pointer-events: none; border-color: #6b7280; color: #9ca3af; display: inline-flex; align-items: center; gap: 4px; }
.enhance-btn { padding: 3px 8px; border-radius: 4px; border: 1px solid #60a5fa; background: transparent; color: #60a5fa; cursor: pointer; font-size: 11px; white-space: nowrap; }
.enhance-btn:hover { background: #60a5fa; color: #000; }
.spinner { width: 12px; height: 12px; border: 2px solid #6b7280; border-top-color: #f59e0b; border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Build Modal ===== */
.build-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.build-modal { background: #1a1d27; border: 1px solid #2a2d37; border-radius: 12px; width: 520px; max-width: 90vw; max-height: 80vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,0.5); }
.build-modal-header { padding: 16px 20px; border-bottom: 1px solid #2a2d37; display: flex; align-items: center; gap: 10px; }
.build-modal-header h3 { flex: 1; font-size: 15px; color: #f9fafb; }
.build-modal-header .status-badge { padding: 3px 10px; border-radius: 50px; font-size: 11px; font-weight: 600; }
.status-running { background: #f59e0b22; color: #f59e0b; border: 1px solid #f59e0b44; }
.status-done { background: #22c55e22; color: #22c55e; border: 1px solid #22c55e44; }
.status-error { background: #ef444422; color: #ef4444; border: 1px solid #ef444444; }
.build-modal-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.build-log { font-family: 'Consolas', 'Monaco', monospace; font-size: 12px; line-height: 1.8; color: #9ca3af; white-space: pre-wrap; word-break: break-all; }
.build-log .step { color: #f59e0b; font-weight: 600; }
.build-log .ok { color: #22c55e; }
.build-log .err { color: #ef4444; }
.build-modal-footer { padding: 12px 20px; border-top: 1px solid #2a2d37; display: flex; justify-content: flex-end; gap: 8px; }
.build-modal-footer button { padding: 6px 16px; border-radius: 6px; border: 1px solid #2a2d37; background: #0f1117; color: #e0e0e0; cursor: pointer; font-size: 13px; }
.build-modal-footer button:hover { background: #2a2d37; }
.build-modal-footer button.primary { background: #f59e0b; color: #000; border-color: #f59e0b; }

/* ===== Shop Detail ===== */
.back { color: #9ca3af; text-decoration: none; font-size: 13px; display: inline-block; margin-bottom: 16px; }
.back:hover { color: #e0e0e0; }
.header-row { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; flex-wrap: wrap; }
.header-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.subtitle { color: #9ca3af; font-size: 14px; margin-bottom: 20px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.link-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; }
.link-card { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px; background: #0f1117; border: 1px solid #2a2d37; border-radius: 10px; color: #e0e0e0; text-decoration: none; font-size: 13px; font-weight: 600; transition: all 0.2s; }
.link-card:hover { border-color: #f59e0b; color: #f59e0b; }
.photo-link { cursor: pointer; text-decoration: underline; color: #60a5fa; }
.photo-link:hover { color: #93c5fd; }
.sub-info { margin-top: 8px; font-size: 13px; color: #9ca3af; }
.save-btn { margin-top: 8px; padding: 8px 20px; border-radius: 8px; border: none; background: #f59e0b; color: #000; font-weight: 600; cursor: pointer; font-size: 13px; }
.save-btn:hover { background: #d97706; }
.shop-detail-info { display: grid; grid-template-columns: 120px 1fr; gap: 8px 16px; font-size: 14px; }
.shop-detail-info .label { color: #9ca3af; }
.shop-detail-info .value { color: #e0e0e0; word-break: break-all; }
.shop-detail-info a { color: #60a5fa; text-decoration: none; }
.shop-detail-info a:hover { text-decoration: underline; }
.toast { position: fixed; bottom: 24px; right: 24px; background: #166534; color: #86efac; padding: 10px 20px; border-radius: 8px; font-size: 14px; display: none; z-index: 100; }

/* ===== Edit Monitor ===== */
.source { display: inline-block; padding: 1px 6px; border-radius: 3px; font-size: 11px; }
.source-telegram { background: #0088cc22; color: #29b6f6; border: 1px solid #0088cc44; }
.source-web { background: #4ade8022; color: #4ade80; border: 1px solid #4ade8044; }

/* ===== Scans ===== */
.rescan-btn { padding: 3px 10px; border-radius: 4px; border: 1px solid #2a2d37; background: transparent; color: #9ca3af; cursor: pointer; font-size: 12px; }
.rescan-btn:hover { background: #2a2d37; color: #e0e0e0; }
.msg { padding: 10px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; display: none; }
.msg.success { background: #166534; color: #86efac; display: block; }
.msg.error { background: #991b1b; color: #fca5a5; display: block; }

/* ===== Backup ===== */
.log-box { background: #0d1117; border-radius: 8px; padding: 12px; font-family: monospace; font-size: 0.78rem; color: #8b949e; max-height: 300px; overflow-y: auto; white-space: pre-wrap; word-break: break-all; line-height: 1.6; }
.log-line-ok { color: #4ade80; }
.log-line-err { color: #f87171; }
.log-line-info { color: #facc15; }
.file-list { font-size: 0.8rem; color: #9ca3af; }
.file-item { display: flex; justify-content: space-between; padding: 2px 0; }
.file-item .fname { color: #e0e0e0; }
.file-item .fsize { color: #60a5fa; }
.badge-ok { background: #166534; color: #4ade80; }
.badge-old { background: #78350f; color: #fbbf24; }
.badge-err { background: #7f1d1d; color: #f87171; }

/* ===== Gallery ===== */
.gallery-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.92); z-index: 1000; overflow-y: auto; padding: 20px; }
.gallery-overlay.open { display: block; }
.gallery-header { display: flex; align-items: center; justify-content: space-between; padding: 0 0 16px; position: sticky; top: 0; background: rgba(0,0,0,0.85); z-index: 1; }
.gallery-header h2 { font-size: 1.1rem; color: #fff; }
.gallery-back { background: rgba(0,0,0,0.7); border: 1px solid #555; color: #fff; font-size: 0.95rem; padding: 8px 18px; border-radius: 6px; cursor: pointer; }
.gallery-back:hover { background: rgba(60,60,60,0.9); }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.gallery-grid img { width: 100%; height: 220px; object-fit: cover; border-radius: 8px; cursor: pointer; transition: transform 0.15s; }
.gallery-grid img:hover { transform: scale(1.03); }
.photo-full { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.95); z-index: 1100; align-items: center; justify-content: center; cursor: pointer; }
.photo-full.open { display: flex; }
.photo-full img { max-width: 95vw; max-height: 95vh; object-fit: contain; border-radius: 4px; }
.photo-full-back { position: fixed; top: 16px; left: 16px; z-index: 1200; background: rgba(0,0,0,0.7); border: 1px solid #555; color: #fff; font-size: 0.95rem; padding: 8px 18px; border-radius: 6px; cursor: pointer; }
.photo-full-back:hover { background: rgba(60,60,60,0.9); }

/* ===== Toolbar ===== */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.toolbar .info { font-size: 13px; color: #9ca3af; }
.toolbar button { padding: 6px 14px; border-radius: 6px; border: 1px solid #2a2d37; background: #1a1d27; color: #e0e0e0; cursor: pointer; font-size: 13px; }
.toolbar button:hover { background: #2a2d37; }

/* ===== Mobile ===== */
@media (max-width: 768px) {
  nav { padding: 8px 12px; gap: 6px; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  nav::-webkit-scrollbar { display: none; }
  nav .logo { font-size: 13px; margin-right: 6px; white-space: nowrap; }
  nav a { font-size: 12px; padding: 6px 8px; white-space: nowrap; flex-shrink: 0; }
  .container { padding: 16px 12px; }
  h1 { font-size: 20px; margin-bottom: 16px; }
  .section { padding: 14px; }
  table { font-size: 14px; }
  th, td { padding: 8px 6px; }
  .hide-mobile { display: none; }
  .filters select, .filters label:has(input[type="checkbox"]) { display: none; }
  .filters input[type="text"] { width: 100% !important; }
  .table-wrap { overflow-x: hidden; }
  .scan-form input[type="text"] { font-size: 16px; padding: 10px; }
}
