*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --bg: #020617;
  --surface: #0f172a;
  --surface-soft: #111c34;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: #22304a;
  --primary: #4f46e5;
  --primary-2: #22d3ee;
  --danger: #ef4444;
  --success: #22c55e;
  --radius-xl: 18px;
  --radius-md: 12px;
  --shadow-lg: 0 24px 60px rgba(2, 6, 23, 0.5);
}

body.theme-light {
  --bg: #eef2ff;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #0f172a;
  --muted: #475569;
  --border: #cbd5e1;
  --shadow-lg: 0 18px 40px rgba(30, 41, 59, 0.15);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, Segoe UI, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1000px 500px at 10% -10%, rgba(79, 70, 229, 0.18), transparent 60%),
    radial-gradient(1000px 500px at 100% 0%, rgba(34, 211, 238, 0.12), transparent 50%),
    var(--bg);
  animation: ambientGlow 14s ease-in-out infinite alternate;
}

a {
  color: inherit;
}

.layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

aside {
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(2, 6, 23, 0.95));
  backdrop-filter: blur(8px);
  padding: 20px;
}

aside h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
}

aside a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  border-radius: 10px;
  color: #dbeafe;
  text-decoration: none;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

aside a:hover {
  background: rgba(79, 70, 229, 0.24);
  border-color: rgba(99, 102, 241, 0.55);
}

aside a.active {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.45), rgba(34, 211, 238, 0.25));
  border-color: rgba(103, 232, 249, 0.4);
}

main {
  padding: 28px;
}

.hero {
  margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.35), rgba(34, 211, 238, 0.2));
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: var(--radius-xl);
  padding: 22px;
}

.hero h1,
.hero h2,
.hero h3 {
  margin: 0 0 8px;
}

.card {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.95), rgba(17, 28, 52, 0.92));
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 18px;
  margin-bottom: 16px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

body.theme-light .card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(241, 245, 249, 0.98));
}

body.theme-light input,
body.theme-light textarea,
body.theme-light select {
  background: #ffffff;
  color: #0f172a;
  border-color: #cbd5e1;
}

body.theme-light aside {
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.95), rgba(241, 245, 249, 0.95));
}

body.theme-light aside a {
  color: #1e293b;
}

.card:hover {
  transform: translateY(-2px);
  border-color: rgba(129, 140, 248, 0.45);
}

.card h3 {
  margin-top: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

label {
  display: block;
  margin: 10px 0 6px;
  font-size: 0.9rem;
  color: #bfdbfe;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #334155;
  background: #0b1220;
  color: #f8fafc;
  border-radius: var(--radius-md);
  padding: 11px 12px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: #818cf8;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  box-shadow: 0 10px 25px rgba(79, 70, 229, 0.45);
}

button:hover,
.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  color: #cbd5e1;
  font-weight: 600;
}

tr:hover td {
  background: rgba(15, 23, 42, 0.35);
}

.status-ok {
  color: #86efac;
}

.status-error {
  color: #fca5a5;
}

.muted {
  color: var(--muted);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  margin-bottom: 14px;
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(8px);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-status-approved {
  color: #86efac;
  background: rgba(20, 83, 45, 0.4);
  border-color: rgba(34, 197, 94, 0.45);
}

.badge-status-pending {
  color: #fde68a;
  background: rgba(120, 53, 15, 0.36);
  border-color: rgba(245, 158, 11, 0.45);
}

.badge-status-declined,
.badge-status-cancelled {
  color: #fecaca;
  background: rgba(127, 29, 29, 0.36);
  border-color: rgba(239, 68, 68, 0.45);
}

.badge-source {
  color: #bfdbfe;
  background: rgba(30, 58, 138, 0.26);
  border-color: rgba(59, 130, 246, 0.4);
}

.icon {
  width: 16px;
  height: 16px;
  opacity: 0.92;
}

.kanban {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 10px;
}

.kanban-col {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(2, 6, 23, 0.3);
  min-height: 320px;
  padding: 10px;
}

.kanban-col h4 {
  margin: 0 0 10px;
  font-size: 0.95rem;
}

.kanban-dropzone {
  min-height: 250px;
}

.kanban-card {
  display: grid;
  gap: 4px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid #334155;
  border-radius: 12px;
  padding: 10px;
  margin-bottom: 8px;
  cursor: grab;
}

.kanban-card small {
  color: var(--muted);
}

.kanban-card.dragging {
  opacity: 0.6;
}

body.theme-light .kanban-col {
  background: rgba(255, 255, 255, 0.7);
}

body.theme-light .kanban-card {
  background: #ffffff;
  border-color: #cbd5e1;
}

.map-editor {
  position: relative;
  height: 520px;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(2, 6, 23, 0.65), rgba(15, 23, 42, 0.8)),
    repeating-linear-gradient(0deg, rgba(51, 65, 85, 0.25), rgba(51, 65, 85, 0.25) 1px, transparent 1px, transparent 32px),
    repeating-linear-gradient(90deg, rgba(51, 65, 85, 0.25), rgba(51, 65, 85, 0.25) 1px, transparent 1px, transparent 32px);
  border: 1px solid #334155;
  overflow: hidden;
}

.table-item {
  position: absolute;
  width: 92px;
  height: 92px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
  background: linear-gradient(135deg, #4338ca, #0ea5e9);
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 14px 30px rgba(37, 99, 235, 0.35);
  cursor: move;
  user-select: none;
}

.table-square {
  border-radius: 14px;
}

.public-wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px;
}

.public-hero {
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.38), rgba(6, 182, 212, 0.2));
  padding: 28px;
  margin: 20px 0;
}

.public-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.public-card {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow-lg);
}

.lang-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  padding: 5px 10px;
  margin-right: 6px;
  font-size: 0.78rem;
  text-decoration: none;
}

.flag-icon {
  width: 18px;
  height: 13px;
  border-radius: 2px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.35);
  vertical-align: middle;
}

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }
  aside {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .kanban {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .kanban {
    grid-template-columns: 1fr;
  }
}

@keyframes ambientGlow {
  0% {
    background-position: 0 0, 100% 0, 0 0;
  }
  100% {
    background-position: 2% 4%, 98% -3%, 0 0;
  }
}

/* --- Julkinen teema, lomakkeet, API, pöytäkartta --- */
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.form-actions--top {
  margin-top: 0;
  margin-bottom: 10px;
}

.form-actions--footer {
  margin-top: 24px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.form-actions--reserve {
  margin-top: 18px;
  padding-top: 4px;
}

form .g-recaptcha {
  margin: 16px 0 4px;
}

.settings-form .form-section-title {
  margin: 22px 0 10px;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #cbd5e1;
  border-left: 3px solid rgba(129, 140, 248, 0.85);
  padding-left: 10px;
}

.settings-form .form-section-title:first-of-type {
  margin-top: 4px;
}

.settings-form .form-section-hint {
  margin: -4px 0 12px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.settings-form > label {
  margin-top: 16px;
}

.map-toolbar,
.map-editor--v2,
.map-table,
.map-draw {
  font-family: inherit;
}

.map-editor--v2,
.map-editor.map-editor--v2 {
  position: relative;
  min-height: 400px;
  border-radius: var(--radius-xl);
  background:
    linear-gradient(180deg, rgba(2, 6, 23, 0.65), rgba(15, 23, 42, 0.85)),
    repeating-linear-gradient(0deg, rgba(51, 65, 85, 0.22), rgba(51, 65, 85, 0.22) 1px, transparent 1px, transparent 16px),
    repeating-linear-gradient(90deg, rgba(51, 65, 85, 0.22), rgba(51, 65, 85, 0.22) 1px, transparent 1px, transparent 16px);
  border: 1px solid #334155;
  overflow: auto;
}

/* Editorin canvas: lapset position:absolute – ilman tätä left/top eivät toimi */
.map-editor__inner {
  position: relative;
  display: block;
}

.map-editor__inner .map-table {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.1;
  background: linear-gradient(135deg, #4338ca, #0ea5e9);
  border: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 8px 22px rgba(37, 99, 235, 0.35);
  color: #f8fafc;
  border-radius: 999px;
  z-index: 2;
}

.map-editor__inner .map-table--sq {
  border-radius: 10px;
}

.map-editor__inner .map-draw--rect {
  position: absolute;
  z-index: 1;
}

.map-editor__inner .map-draw--line {
  position: absolute;
  z-index: 1;
}

.map-editor__inner .map-draw--label {
  position: absolute;
  z-index: 3;
  user-select: none;
  cursor: move;
  padding: 2px 4px;
  border-radius: 4px;
  white-space: nowrap;
}

.map-editor__inner .map-draw--frame,
.map-editor__inner .map-draw--rect {
  box-sizing: border-box;
}

.map-resize-h {
  position: absolute;
  width: 10px;
  height: 10px;
  margin-left: 0;
  margin-top: 0;
  background: #22d3ee;
  border: 1px solid #0e7490;
  border-radius: 2px;
  z-index: 6;
  box-sizing: border-box;
  padding: 0;
}

.map-resize-h--nw { cursor: nwse-resize; }
.map-resize-h--se { cursor: nwse-resize; }
.map-resize-h--ne { cursor: nesw-resize; }
.map-resize-h--sw { cursor: nesw-resize; }

.map-line-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #22d3ee;
  border: 1px solid #0e7490;
  border-radius: 50%;
  z-index: 6;
  box-sizing: border-box;
  cursor: crosshair;
}

.map-toolbar--v3 {
  display: block;
  margin-bottom: 12px;
}

.map-toolbar--v3 .map-toolbar__row--main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.map-tl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  font-size: 0.84rem;
}

.map-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 0;
  align-items: center;
}

.btn--sm {
  padding: 7px 12px;
  font-size: 0.86rem;
  border-radius: 10px;
}

.btn--ghost {
  background: rgba(15, 23, 42, 0.7) !important;
  color: #e2e8f0 !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
}

.btn--ghost:hover {
  background: rgba(30, 41, 59, 0.95) !important;
}

.map-table {
  user-select: none;
}

.map-table--on {
  outline: 2px solid rgba(34, 211, 238, 0.9);
  z-index: 2;
}

.floorplan-outer {
  position: relative;
  border-radius: 14px;
  overflow: auto;
  max-height: 520px;
  border: 1px solid var(--t-border, #1e293b);
  background: linear-gradient(180deg, rgba(2, 6, 23, 0.5), rgba(15, 23, 42, 0.75));
}

.floorplan,
.floorplan--readonly {
  position: relative;
  min-height: 240px;
  width: 100%;
  max-width: 100%;
  background:
    repeating-linear-gradient(0deg, rgba(51, 65, 85, 0.16), rgba(51, 65, 85, 0.16) 1px, transparent 1px, transparent 24px),
    repeating-linear-gradient(90deg, rgba(51, 65, 85, 0.16), rgba(51, 65, 85, 0.16) 1px, transparent 1px, transparent 24px);
  border-radius: 10px;
}

.floorplan .floor-table,
.floorplan--readonly .floor-table {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.1;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.5), rgba(6, 182, 212, 0.35));
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #f1f5f9;
  box-shadow: 0 6px 18px rgba(2, 6, 23, 0.35);
  z-index: 1;
  pointer-events: none;
  padding: 2px;
}

.floor-table__lbl {
  display: block;
  font-size: 0.72rem;
}

.floor-table small {
  font-size: 0.6rem;
  font-weight: 500;
  opacity: 0.9;
}

.floor-shape--rect,
.floor-shape--frame,
.floor-line,
.floor-label {
  position: absolute;
  z-index: 0;
  pointer-events: none;
}

.floor-label {
  z-index: 0;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.code-block {
  background: #020617;
  color: #e2e8f0;
  padding: 16px 18px;
  border-radius: 12px;
  border: 1px solid #22304a;
  overflow: auto;
  font-size: 0.8rem;
  line-height: 1.5;
  margin: 8px 0 0;
  max-height: 200px;
}

.api-hero {
  border: 1px solid rgba(129, 140, 248, 0.35);
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9), rgba(2, 6, 23, 0.95));
}

.api-restaurant-card--new {
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.55), var(--shadow-lg);
  border-color: rgba(34, 211, 238, 0.45);
}

.form-inline-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: flex-end;
  margin-bottom: 14px;
}

.form-inline-filter label {
  margin: 0 0 4px;
  display: block;
}

.reserve-card {
  background: var(--t-card, rgba(15, 23, 42, 0.94)) !important;
  border: 1px solid var(--t-border, #22304a) !important;
  border-radius: var(--t-rad, 20px) !important;
  padding: 24px;
  box-shadow: 0 24px 60px rgba(2, 6, 23, 0.45) !important;
}
