:root {
  --bg: #0f1115;
  --card: #171a21;
  --border: #2a2e37;
  --text: #e7e9ee;
  --muted: #9aa1ac;
  --accent: #5b8cff;
  --danger: #e5534b;
  --success: #2ea043;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
}
.brand { color: var(--text); font-weight: 700; text-decoration: none; }
.logout { color: var(--muted); text-decoration: none; font-size: 14px; }
.topnav { display: flex; gap: 16px; margin-left: 24px; margin-right: auto; }
.topnav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.topnav a:hover { color: var(--text); }

.container { max-width: 1000px; margin: 0 auto; padding: 24px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
}

h1 { font-size: 18px; margin: 0 0 14px; }
h2 { font-size: 15px; margin: 18px 0 8px; color: var(--muted); }
.muted { color: var(--muted); font-size: 13px; }
code { background: #1e2230; padding: 1px 5px; border-radius: 4px; }

label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type="text"], input[type="password"], input[type="file"], textarea {
  width: 100%;
  background: #0f1115;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
.field-row { margin-bottom: 12px; }

.btn {
  display: inline-block;
  background: #232833;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: white; }
.btn-small { padding: 5px 10px; font-size: 13px; }

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

.flashes { margin-bottom: 16px; }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 8px; font-size: 14px; }
.flash-success { background: rgba(46, 160, 67, 0.15); border: 1px solid var(--success); }
.flash-error { background: rgba(229, 83, 75, 0.15); border: 1px solid var(--danger); }

.bulk-category-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
  padding: 10px 14px;
}
.bulk-category-section summary {
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  padding: 4px 0;
}
.bulk-category-section[open] summary { margin-bottom: 10px; }

.templates-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.templates-table th, .templates-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.badge { padding: 2px 8px; border-radius: 999px; font-size: 12px; text-transform: uppercase; }
.badge-docx { background: rgba(91,140,255,0.2); color: #8fb0ff; }
.badge-psd { background: rgba(180,91,255,0.2); color: #cba3ff; }
.badge-pdf { background: rgba(229,83,75,0.2); color: #ff9d97; }
.badge-live { background: rgba(46,160,67,0.2); color: #5fd67d; }
.badge-hidden { background: rgba(154,161,172,0.2); color: var(--muted); }
.actions { display: flex; gap: 8px; }
.actions form { display: inline; }
.inline-form { display: inline; }
.inline-form select { width: auto; padding: 5px 8px; }

.login-card { max-width: 320px; margin: 60px auto; }

.background-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
}
.background-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}
.background-card img {
  width: 100%;
  height: 100px;
  object-fit: cover;
  border-radius: 4px;
  display: block;
  margin-bottom: 6px;
}
.background-card-name { font-size: 13px; margin-bottom: 4px; }
.background-card-frame { font-size: 11px; margin-bottom: 8px; }
.background-card-actions { display: flex; gap: 6px; justify-content: center; }

.settings-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; margin-bottom: 6px; }
.settings-form .field-row { flex: 1; min-width: 200px; margin-bottom: 0; }

.paragraph-list { display: flex; flex-direction: column; gap: 8px; }
.paragraph-row { display: flex; gap: 10px; align-items: flex-start; }
.paragraph-index { color: var(--muted); font-size: 12px; padding-top: 8px; width: 34px; flex-shrink: 0; }

.zone-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }

.page-editor { margin-bottom: 20px; }
.zone-canvas {
  border: 1px solid var(--border);
  max-width: 100%;
  cursor: crosshair;
  background: #000;
}

#zone-list { max-height: 70vh; overflow-y: auto; overflow-x: auto; }
.zone-list-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 16px; }
.zone-list-table th, .zone-list-table td {
  text-align: left;
  padding: 3px 5px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.zone-list-table th { position: sticky; top: 0; background: var(--card); z-index: 1; }
.zone-list-table input[type="text"], .zone-list-table select {
  width: auto;
  min-width: 90px;
  max-width: 130px;
  padding: 3px 5px;
  font-size: 12px;
}
.zone-list-table input[type="number"] { width: 55px; padding: 3px 5px; font-size: 12px; }
.zone-list-table tr { cursor: pointer; }
.zone-row-selected { background: rgba(91, 140, 255, 0.12); }
.zone-label-cell {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-style: italic;
}
