:root {
  --bg: #eef0f4;
  --surface: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #d6d9e0;
  --primary: #2563eb;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 { margin: 0; font-size: 1.25rem; letter-spacing: .02em; }

main { padding: 12px; }

.empty { text-align: center; color: var(--muted); margin-top: 4rem; }

/* ---------- tlačidlá ---------- */
.btn {
  font: inherit;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn:hover { filter: brightness(.96); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- widget ---------- */
.widget {
  --w-bg: #ffffff;
  --w-fg: #1f2430;
  display: flex;
  flex-direction: column;
  background: var(--w-bg);
  color: var(--w-fg);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgb(0 0 0 / .12);
  overflow: hidden !important;
}

.w-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 12px;
  cursor: move;
  background: rgb(0 0 0 / .06);
  user-select: none;
}

.w-title {
  flex: 1;
  font-weight: 600;
  font-size: .9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.w-actions { display: flex; gap: 2px; opacity: .35; transition: opacity .15s; }
.widget:hover .w-actions, .w-actions:focus-within { opacity: 1; }

.w-actions button {
  border: 0;
  background: transparent;
  color: inherit;
  font-size: .95rem;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  cursor: pointer;
}
.w-actions button:hover { background: rgb(0 0 0 / .1); }

.w-body {
  flex: 1;
  min-height: 0;
  padding: 10px 14px;
  container-type: size;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
}

.w-foot {
  font-size: .72rem;
  opacity: .6;
  padding: 0 12px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.w-foot.error { opacity: 1; color: #b91c1c; }
.widget.dark .w-foot.error { color: #fca5a5; }

.w-loading, .w-error { opacity: .6; text-align: center; }
.w-error { opacity: 1; color: #b91c1c; font-size: .9rem; }
.widget.dark .w-error { color: #fca5a5; }

/* číslo */
.n-label { font-size: .85rem; opacity: .75; }
.n-value {
  font-size: clamp(1.2rem, 28cqmin, 4.5rem);
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.n-unit { font-size: .55em; font-weight: 600; margin-left: .15em; opacity: .8; }
.n-change { font-weight: 600; font-size: .9rem; }
.n-change.up { color: #15803d; }
.n-change.down { color: #b91c1c; }
.widget.dark .n-change.up { color: #86efac; }
.widget.dark .n-change.down { color: #fca5a5; }
.n-detail { font-size: .8rem; opacity: .7; margin-top: 2px; }

/* text */
.t-value {
  white-space: pre-wrap;
  overflow: auto;
  max-height: 100%;
  line-height: 1.45;
}
.w-body:has(.t-value) { justify-content: flex-start; }

/* obrázok */
.w-body:has(.img-wrap) { padding: 6px; }
.img-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.img-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; }
.img-caption {
  font-size: .8rem;
  text-align: center;
  padding-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.img-caption a { color: inherit; }

/* ---------- dialóg ---------- */
dialog {
  border: 0;
  border-radius: var(--radius);
  padding: 20px 22px;
  width: min(440px, calc(100vw - 32px));
  box-shadow: 0 10px 40px rgb(0 0 0 / .25);
}
dialog::backdrop { background: rgb(15 23 42 / .45); }
dialog h2 { margin: 0 0 14px; font-size: 1.15rem; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: .85rem; font-weight: 600; }
.field small { color: var(--muted); font-size: .78rem; }
.field input:not([type=color]), .field select, .field textarea {
  font: inherit;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
}
.field textarea { min-height: 90px; resize: vertical; }

.colors { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid rgb(0 0 0 / .2);
  cursor: pointer;
  padding: 0;
}
.swatch.selected { outline: 2px solid var(--primary); outline-offset: 2px; }
#f-color { width: 40px; height: 30px; border: 0; padding: 0; background: none; cursor: pointer; }

.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* gridstack placeholder */
.grid-stack-placeholder > .placeholder-content {
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  background: rgb(37 99 235 / .06);
}

/* ---------- odhlásenie / prihlásenie ---------- */
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.topbar-actions form { margin: 0; }

.login-body { display: grid; place-items: center; padding: 16px; }
.login-box {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.login-box h1 { margin: 0 0 4px; font-size: 1.4rem; }
.login-box input { font: inherit; padding: 8px; border: 1px solid var(--border); border-radius: 8px; }
.login-error { margin: 0; color: #b91c1c; }
