:root {
  --brand: #10b981;
  --brand-dark: #0e9f6e;
  --ink: #111827;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f3f4f6;
  --card: #ffffff;
  --sidebar: #111827;
  --sidebar-text: #9ca3af;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #059669;
  --info: #2563eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(17, 24, 39, 0.08), 0 1px 2px rgba(17, 24, 39, 0.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 24px; margin: 0 0 4px; color: var(--ink); }
h2 { font-size: 18px; margin: 0 0 12px; color: var(--ink); }
h3 { font-size: 15px; margin: 0 0 8px; color: var(--ink); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
code { background: #eef2f7; padding: 2px 6px; border-radius: 6px; font-size: 13px; word-break: break-all; }

/* ---------- Layout ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand-mark { padding: 20px 20px 12px; font-size: 19px; }
.brand-mark { font-weight: 800; color: #fff; letter-spacing: -0.3px; }
.brand-mark span { color: var(--brand); }
.auth-card .brand-mark, .pub-footer .brand-mark { color: var(--ink); font-size: 22px; }
.sidebar .biz-name {
  padding: 0 20px 16px; font-size: 12px; color: #6b7280;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar nav { flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 20px;
  color: var(--sidebar-text); font-size: 14px; text-decoration: none;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { color: #fff; background: rgba(255,255,255,0.04); }
.sidebar nav a.active { color: #fff; border-left-color: var(--brand); background: rgba(16,185,129,0.1); }
.sidebar nav a .ico { width: 18px; text-align: center; opacity: 0.9; }
.sidebar .badge-dot {
  background: var(--danger); color: #fff; border-radius: 99px; font-size: 11px;
  padding: 1px 7px; margin-left: auto; font-weight: 700;
}
.sidebar .side-bottom { padding: 14px 20px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar .side-bottom button {
  background: none; border: 1px solid rgba(255,255,255,0.15); color: var(--sidebar-text);
  border-radius: 8px; padding: 7px 12px; width: 100%; cursor: pointer; font-size: 13px;
}
.sidebar .side-bottom button:hover { color: #fff; border-color: rgba(255,255,255,0.4); }
.main { flex: 1; padding: 28px 32px 60px; max-width: 1200px; min-width: 0; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); font-size: 14px; max-width: 640px; }

/* ---------- Cards / grids ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card h2 { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1100px) { .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar nav { display: flex; flex-wrap: wrap; }
  .sidebar nav a { border-left: none; border-bottom: 2px solid transparent; padding: 8px 12px; }
  .sidebar nav a.active { border-bottom-color: var(--brand); }
  .main { padding: 18px 14px 50px; }
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
}

.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat-card .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; }
.stat-card .value { font-size: 26px; font-weight: 800; color: var(--ink); margin-top: 2px; }
.stat-card .hint { font-size: 12px; color: var(--muted); }
.stat-card.accent .value { color: var(--brand-dark); }
.stat-card.neg .value { color: var(--danger); }

/* ---------- Forms ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 14px; }
label input, label select, label textarea {
  display: block; width: 100%; margin-top: 5px; font-weight: 400;
}
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="number"],
input[type="date"], select, textarea {
  font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(16,185,129,0.35); border-color: var(--brand); }
textarea { min-height: 80px; resize: vertical; }
input[type="color"] { width: 52px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-top: 5px; }
.checkbox { display: flex; align-items: flex-start; gap: 8px; font-weight: 400; font-size: 14px; }
.checkbox input { width: auto; margin-top: 3px; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > label { flex: 1; min-width: 180px; }
.field-hint { font-size: 12px; color: var(--muted); font-weight: 400; margin-top: 3px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; font: inherit; font-weight: 600; font-size: 14px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none !important; text-align: center;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn-secondary:hover { border-color: #9ca3af; }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line);
}
table.data td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafafa; }
.table-wrap { overflow-x: auto; }

/* ---------- Badges & alerts ---------- */
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-gray { background: #e5e7eb; color: #374151; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.alert { padding: 11px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 16px; }
.alert-error { background: #fee2e2; color: #991b1b; }
.alert-success { background: #d1fae5; color: #065f46; }
.alert-info { background: #dbeafe; color: #1e40af; }
.alert-warning { background: #fef3c7; color: #92400e; }

/* ---------- Stars ---------- */
.stars { color: #f59e0b; font-size: 15px; letter-spacing: 1px; white-space: nowrap; }
.stars .off { color: #d1d5db; }

/* ---------- Auth pages ---------- */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 34px 36px; width: 100%; max-width: 420px; }
.auth-card h1 { font-size: 20px; margin: 18px 0 14px; }
.auth-card .tagline { font-size: 13px; margin: 4px 0 0; }
.auth-links { font-size: 14px; margin: 14px 0 0; }
.lang-switch { font-size: 12px; text-align: center; margin-top: 22px; color: var(--muted); }

/* ---------- Public survey page ---------- */
.pub-body { display: flex; flex-direction: column; align-items: center; min-height: 100vh; padding: 24px 14px; background: var(--bg); }
.pub-card {
  background: #fff; border-radius: 18px; box-shadow: 0 4px 24px rgba(17,24,39,0.09);
  padding: 32px 28px; width: 100%; max-width: 480px; text-align: center; margin-top: 4vh;
}
.pub-card .pub-logo { max-height: 72px; max-width: 180px; margin: 0 auto 14px; display: block; }
.pub-card h1 { font-size: 22px; }
.pub-card .pub-sub { color: var(--muted); margin: 6px 0 0; }
.star-row { display: flex; justify-content: center; gap: 8px; margin: 24px 0 6px; }
.star-btn {
  font-size: 42px; line-height: 1; background: none; border: none; cursor: pointer;
  color: #d1d5db; transition: transform 0.08s ease, color 0.08s ease; padding: 2px;
}
.star-btn:hover { transform: scale(1.12); }
.star-btn.on { color: #f59e0b; }
.pub-section { margin-top: 18px; text-align: left; }
.pub-msg { font-size: 15px; padding: 12px 14px; border-radius: 10px; margin: 16px 0; text-align: left; }
.pub-msg.pos { background: #d1fae5; color: #065f46; }
.pub-msg.neg { background: #fef3c7; color: #92400e; }
.review-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.review-btn {
  display: block; padding: 13px 16px; border-radius: 10px; font-weight: 700; font-size: 15px;
  color: #fff; text-decoration: none !important; text-align: center;
}
.review-btn:hover { filter: brightness(0.95); }
.pub-footer { margin-top: auto; padding: 26px 0 8px; font-size: 12px; color: var(--muted); text-align: center; }
.pub-footer a { color: var(--muted); font-weight: 700; }
.pub-thanks-icon { font-size: 52px; margin: 8px 0; }

/* ---------- Misc ---------- */
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.copy-area { display: flex; gap: 8px; align-items: stretch; }
.copy-area input, .copy-area textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px; background: #f9fafb; }
.qr-preview { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: inline-block; }
.qr-preview img, .qr-preview svg { display: block; width: 160px; height: 160px; }
.inline-form { display: inline; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.toolbar label { margin-bottom: 0; min-width: 130px; }
.chart-svg { width: 100%; height: auto; }
.progress { background: var(--line); height: 8px; border-radius: 99px; overflow: hidden; }
.progress > div { background: var(--brand); height: 100%; border-radius: 99px; }
.notif-item { display: flex; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: #f0fdf4; }
.notif-dot { width: 8px; height: 8px; border-radius: 99px; background: var(--brand); margin-top: 7px; flex-shrink: 0; }
.notif-item.read .notif-dot { background: transparent; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .big { font-size: 40px; margin-bottom: 8px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 8px 14px; font-size: 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; text-decoration: none; }
.tabs a.active { color: var(--brand-dark); border-bottom-color: var(--brand); }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 0; }
.steps li { counter-increment: step; display: flex; gap: 12px; padding: 8px 0; align-items: baseline; }
.steps li::before {
  content: counter(step); background: var(--brand); color: #fff; font-weight: 700; font-size: 12px;
  width: 22px; height: 22px; border-radius: 99px; display: inline-flex; align-items: center;
  justify-content: center; flex-shrink: 0; position: relative; top: 3px;
}
.logo-thumb { max-height: 56px; max-width: 140px; border: 1px solid var(--line); border-radius: 8px; padding: 4px; background: #fff; }
.flash-saved { position: fixed; top: 16px; right: 16px; z-index: 50; }
