:root {
  --bg: #f5f6f2;
  --panel: #ffffff;
  --ink: #1a2a2a;
  --muted: #5a6868;
  --line: #d8dfdf;
  --accent: #0c7a5e;
  --accent-2: #e2f4ed;
  --danger: #b63a2e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background:
    radial-gradient(circle at 0% 0%, #e9f8e9 0%, transparent 30%),
    radial-gradient(circle at 100% 100%, #f8efdf 0%, transparent 30%),
    var(--bg);
  color: var(--ink);
}

.container {
  width: min(1100px, 94vw);
  margin: 28px auto;
  display: grid;
  gap: 16px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.05);
}

.hero {
  background: linear-gradient(130deg, #f7fff8, #fefaf3);
}

.hero-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

h1,
h2 {
  margin: 0 0 10px;
}

p {
  margin: 0;
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 10px;
}

textarea {
  margin-top: 12px;
  width: 100%;
  resize: vertical;
}

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

button {
  border: none;
  border-radius: 9px;
  padding: 10px 14px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

button.secondary {
  background: #edf1f1;
  color: #223;
}

button.danger {
  background: var(--danger);
}

.hidden {
  display: none !important;
}

.error {
  min-height: 20px;
  color: var(--danger);
  margin: 8px 0 0;
}

.table-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.table-wrap {
  overflow-x: auto;
}

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

th,
td {
  text-align: left;
  padding: 8px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
  font-size: 14px;
}

td .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  color: #344;
  word-break: break-all;
}

.qr-thumb {
  width: 72px;
  height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.channel-pill {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--accent-2);
  color: #0e5f4c;
  font-size: 12px;
}

@media (max-width: 800px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

/* --- Enhanced UI Styles --- */

.hero-actions {
  display: flex;
  gap: 8px;
}

.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.card {
  background: #fff;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  text-align: center;
}

.card-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
}

.card-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.filter-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-controls input,
.filter-controls select {
  padding: 8px;
  font-size: 14px;
}

#search-input {
  min-width: 200px;
}

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  text-transform: capitalize;
  background: var(--accent-2);
  color: var(--accent);
}

.badge-active {
  background: #d4f4dd;
  color: #0c6832;
}

.badge-paused {
  background: #fff4e6;
  color: #c87000;
}

.badge-expired {
  background: #ffe6e6;
  color: #b63a2e;
}

.tags {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.tag {
  background: #e8f0fe;
  color: #1967d2;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
}

.url-display {
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--muted);
  background: #f9fafb;
  padding: 2px 6px;
  border-radius: 4px;
}

.notes {
  color: var(--muted);
  font-style: italic;
}

.actions-cell {
  white-space: nowrap;
}

.btn-icon {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 18px;
  padding: 4px 8px;
  filter: grayscale(50%);
  transition: all 0.15s;
}

.btn-icon:hover {
  filter: grayscale(0%);
  transform: scale(1.15);
}

.btn-icon-inline {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 4px;
  opacity: 0.6;
  transition: all 0.15s;
}

.btn-icon-inline:hover {
  opacity: 1;
  transform: scale(1.1);
}

.panel-details {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fafbfb;
}

.panel-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--accent);
}

.panel-details[open] summary {
  margin-bottom: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal-content {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  max-width: 800px;
  width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header button {
  font-size: 24px;
  background: transparent;
  color: var(--muted);
  padding: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.modal-header button:hover {
  background: var(--line);
}

.analytics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat {
  background: #f9fafb;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  border: 1px solid var(--line);
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

.scans-table {
  margin-top: 12px;
  font-size: 13px;
}

.scans-table th {
  background: #f9fafb;
}

input[type="color"] {
  cursor: pointer;
  height: 40px;
}

input[type="date"] {
  cursor: pointer;
}

.info-text {
  display: block;
  margin-top: 6px;
  padding: 8px 10px;
  background: #e8f5e9;
  border-left: 3px solid #4caf50;
  color: #2e7d32;
  font-size: 12px;
  border-radius: 4px;
  line-height: 1.4;
}

.logo-options {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.logo-preview {
  margin-top: 12px;
  padding: 12px;
  background: #f9fafb;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.logo-preview img {
  max-width: 120px;
  max-height: 120px;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.logo-preview-label {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

input[type="file"] {
  padding: 8px;
  font-size: 14px;
  cursor: pointer;
}

input[type="file"]::file-selector-button {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  cursor: pointer;
  margin-right: 8px;
}

input[type="file"]::file-selector-button:hover {
  background: var(--accent-2);
}

.files-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 13px;
}

.files-table th {
  background: #f9fafb;
  padding: 10px 8px;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--line);
}

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

.files-table tr:hover {
  background: #f9fafb;
}

.files-table img {
  display: block;
}

#modal-body {
  max-height: 600px;
  overflow-y: auto;
}
