/* App shell: replaces the tokens the dashboard host used to provide. */
:root {
  --color-fg: #1f1f1f;
  --color-fg-muted: #5e6370;
  --color-bg: #f6f6f6;
  --color-panel: #ffffff;
  --color-border-line: #e5e7eb;
  --color-ok: #1f8a4c;
  --color-warn: #b7791f;
  --color-bad: #c53030;
  --font-anthropic-sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-anthropic-serif: Georgia, "Times New Roman", serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --color-fg: #f4ecf5;
    --color-fg-muted: #c4b4c6;
    --color-bg: #1b0f1c;
    --color-panel: #2a1a2d;
    --color-border-line: #45304a;
  }
}
:root[data-theme="dark"] {
  --color-fg: #f4ecf5;
  --color-fg-muted: #c4b4c6;
  --color-bg: #1b0f1c;
  --color-panel: #2a1a2d;
  --color-border-line: #45304a;
}

html, body { margin: 0; padding: 0; background: var(--color-bg); color: var(--color-fg); }
body { font-family: var(--font-anthropic-sans); -webkit-font-smoothing: antialiased; }
#dash-root { min-height: 100vh; }

/* Loading skeleton (was provided by the dashboard host) */
.dash-skeleton { color: transparent !important; background: linear-gradient(90deg, #0000000d, #0000001a, #0000000d); background-size: 200% 100%; border-radius: 6px; animation: dash-sk 1.4s ease-in-out infinite; }
@keyframes dash-sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .dash-skeleton { animation: none; } }

/* Top bar: title above the action row so the extra interval picker never overlaps the title */
#dash-root .ff-topbar { flex-direction: column; gap: 12px; }
#dash-root .ff-actions { position: static; transform: none; flex-wrap: wrap; justify-content: center; align-items: center; }

/* Interval picker in the top bar */
.ff-interval { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: #472449; background: #ffffff; border: 1px solid #baadbb; border-radius: 999px; padding: 6px 8px 6px 14px; }
.ff-interval select { font: inherit; font-weight: 600; color: inherit; background: transparent; border: 0; padding: 4px 2px; cursor: pointer; }
.ff-interval select:focus-visible { outline: 2px solid #ea412a; outline-offset: 2px; border-radius: 6px; }
.ff--dark .ff-interval { background: #2a1a2d; color: #f1dff2; border-color: #6a5070; }
.ff--dark .ff-interval select option { color: #1f1f1f; }

/* Server status banner (shown only when the last DB run failed) */
.app-alert { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 50; max-width: min(640px, calc(100vw - 32px)); background: #fff4f2; color: #7a1d10; border: 1px solid #f0b4a8; border-radius: 12px; padding: 10px 14px; font-size: 14px; box-shadow: 0 10px 24px #0000001f; }
.app-alert[hidden] { display: none; }

/* OdinAdmin: lock marker + password dialog */
.app-lock { font-size: 12px; margin-left: 2px; opacity: .8; }
.app-modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: #1b0f1c99; backdrop-filter: blur(2px); }
.app-modal-card { width: min(380px, 100%); background: #fff; color: #1f1f1f; border-radius: 18px; padding: 24px; box-shadow: 0 24px 48px #00000040; font-family: Roboto, var(--font-anthropic-sans); display: grid; gap: 12px; }
.app-modal-lock { font-size: 26px; }
.app-modal-card h2 { margin: 0; font-size: 20px; color: #472449; }
.app-modal-what { margin: 0; color: #5e6370; font-size: 14px; line-height: 1.45; }
.app-modal-lbl { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: #472449; }
.app-modal-lbl input { font: inherit; font-size: 16px; font-weight: 400; padding: 10px 12px; border: 1px solid #baadbb; border-radius: 10px; }
.app-modal-lbl input:focus-visible { outline: 2px solid #ea412a; outline-offset: 1px; }
.app-modal-err { margin: 0; color: #c53030; font-size: 14px; }
.app-modal-err[hidden] { display: none; }
.app-modal-btns { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.app-modal-btns button { font: inherit; font-size: 14px; font-weight: 600; border-radius: 999px; padding: 10px 18px; cursor: pointer; border: 1px solid #baadbb; background: #fff; color: #472449; }
.app-modal-btns .app-modal-ok { background: #472449; border-color: #472449; color: #fff; }
.app-modal-btns button:disabled { opacity: .6; cursor: progress; }

/* --- Finn din salong + Min salong (pinned) --------------------------------- */
.ff-pin { position: sticky; top: 10px; z-index: 30; display: flex; align-items: stretch; gap: 6px; background: var(--ff-primary); color: #fff; border-radius: 999px; padding: 6px; box-shadow: 0 12px 28px #47244940; }
.ff-pin[hidden] { display: none; }
.ff--dark .ff-pin { background: #f1dff2; color: #472449; }
.ff-pin-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; background: transparent; color: inherit; border: 0; font: inherit; text-align: left; cursor: pointer; padding: 4px 10px; border-radius: 999px; }
.ff-pin-main:focus-visible, .ff-pin-x:focus-visible { outline: 2px solid var(--ff-accent); outline-offset: 2px; }
.ff-pin-star { color: #ffb4a6; font-size: 20px; }
.ff--dark .ff-pin-star { color: var(--ff-accent); }
.ff-pin-txt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ff-pin-lbl { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .75; }
.ff-pin-name { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ff-pin-rank { font-size: 14px; opacity: .9; white-space: nowrap; }
.ff-pin-votes { font-weight: 700; font-size: 16px; white-space: nowrap; background: var(--ff-accent); color: #fff; border-radius: 999px; padding: 4px 12px; }
.ff-pin-x { flex: none; width: 36px; border: 0; border-radius: 999px; background: #ffffff1f; color: inherit; font-size: 14px; cursor: pointer; }
.ff--dark .ff-pin-x { background: #4724491a; }
@media (max-width: 560px) { .ff-pin-rank { display: none; } .ff-pin-main { gap: 8px; } }

.ff-find-box { position: relative; margin-top: 8px; }
.ff-find-ico { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--ff-muted); pointer-events: none; }
.ff-find-ico svg { width: 100%; height: 100%; }
.ff-find-input { width: 100%; box-sizing: border-box; font: inherit; font-size: 17px; padding: 14px 16px 14px 46px; border: 1.5px solid var(--ff-border-2); border-radius: 14px; background: var(--ff-card); color: var(--ff-text); }
.ff-find-input:focus { outline: none; border-color: var(--ff-accent); box-shadow: 0 0 0 4px #ea412a22; }
.ff-find-list { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 25; list-style: none; margin: 0; padding: 6px; background: var(--ff-card); border: 1px solid var(--ff-border); border-radius: 14px; box-shadow: var(--ff-shadow); max-height: 360px; overflow-y: auto; }
.ff-find-list[hidden] { display: none; }
.ff-find-hit { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
.ff-find-hit.is-active, .ff-find-hit:hover { background: var(--ff-soft); }
.ff-hit-l { display: flex; flex-direction: column; min-width: 0; }
.ff-hit-l b { color: var(--ff-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ff-hit-l span { font-size: 13px; color: var(--ff-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ff-hit-r { font-size: 14px; font-weight: 600; color: var(--ff-accent); white-space: nowrap; }
.ff-find-none { padding: 12px; color: var(--ff-muted); font-size: 14px; }

.ff-res { margin-top: 14px; border: 1.5px solid var(--ff-border); border-radius: 16px; padding: 18px; display: grid; gap: 16px; background: var(--ff-soft); }
.ff-res.is-fav { border-color: var(--ff-accent); }
.ff-res-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ff-res-title { min-width: 0; }
.ff-res-title h3 { margin: 0; color: var(--ff-primary); font-size: 22px; }
.ff-res-title span { color: var(--ff-muted); font-size: 14px; }
.ff-res-pin { font: inherit; font-weight: 600; font-size: 14px; border-radius: 999px; padding: 10px 16px; cursor: pointer; border: 1.5px solid var(--ff-primary); background: transparent; color: var(--ff-primary); }
.ff-res-pin.is-on { background: var(--ff-accent); border-color: var(--ff-accent); color: #fff; }
.ff-res-pin:focus-visible { outline: 2px solid var(--ff-accent); outline-offset: 2px; }
.ff-res-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.ff-res-stat { background: var(--ff-card); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.ff-res-stat .lbl { font-size: 13px; color: var(--ff-muted); }
.ff-res-stat .val { font-family: var(--ff-serif); font-weight: 400; font-size: 32px; color: var(--ff-accent); line-height: 1.1; }
.ff-res-stat .sub { font-size: 13px; color: var(--ff-text); }
.ff-res-emps .lbl { font-size: 13px; color: var(--ff-muted); }
.ff-res-emps ol { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 4px; }
.ff-res-emps li span { color: var(--ff-text); }
.ff-res-emps li b { margin-left: 8px; color: var(--ff-accent); font-weight: 600; }

/* pinned salon highlighted in the top-15 table */
table[data-source="salons"] tbody tr.is-mine td { background: #ea412a14; }
table[data-source="salons"] tbody tr.is-mine td:first-child { box-shadow: inset 4px 0 0 var(--ff-accent); }
.ff-res-logo { width: 56px; height: 56px; object-fit: contain; border-radius: 12px; background: #fff; border: 1px solid var(--ff-border); flex: none; }
.ff-res-head .ff-res-title { flex: 1; }
.ff-pin-logo { width: 32px; height: 32px; object-fit: contain; border-radius: 8px; background: #fff; flex: none; }
.ff-pin-logo[hidden] { display: none; }
.ff-res-quotes .lbl { font-size: 13px; color: var(--ff-muted); }
.ff-res-quotes ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; max-height: 22rem; overflow-y: auto; scrollbar-width: thin; }
.ff-res-quotes li { background: var(--ff-card); border-radius: 12px; padding: 10px 14px; display: grid; gap: 4px; }
.ff-res-quotes q { color: var(--ff-primary); font-size: 15px; line-height: 1.45; quotes: "«" "»"; }
.ff-res-quotes li span { font-size: 12px; color: var(--ff-muted); }

/* --- «Mine salonger» (up to 3) --------------------------------------------- */
.ff-pin { flex-wrap: wrap; align-items: center; border-radius: 22px; padding: 6px 8px; gap: 6px; }
.ff-pin-head { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px 0 8px; }
.ff-pin-head .ff-pin-lbl { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; opacity: .8; white-space: nowrap; }
.ff-pin-item { flex: 1 1 240px; min-width: 0; display: flex; align-items: center; gap: 4px; background: #ffffff14; border-radius: 999px; padding: 2px; }
.ff--dark .ff-pin-item { background: #47244914; }
.ff-pin-item .ff-pin-main { padding: 3px 8px; gap: 8px; }
.ff-pin-item .ff-pin-logo { width: 28px; height: 28px; }
.ff-pin-item .ff-pin-txt { line-height: 1.2; }
.ff-pin-item .ff-pin-name { font-size: 15px; }
.ff-pin-item .ff-pin-rank { font-size: 12px; opacity: .8; }
.ff-pin-item .ff-pin-votes { font-size: 14px; padding: 3px 10px; }
.ff-pin-item .ff-pin-x { width: 30px; height: 30px; flex: none; }
.ff-res-warn { margin: 0; color: #c53030; font-size: 14px; font-weight: 600; }
.ff-res-warn[hidden] { display: none; }
.ff-res-pin.is-full { opacity: .6; }
@media (max-width: 560px) { .ff-pin-item .ff-pin-rank { display: block; } .ff-pin-head { width: 100%; } }

/* --- Admin controls (interval, «Oppdater», «Admin») kept discreet: faint until hover/focus.
   Only «TV-visning» stays prominent for salon staff. ------------------------------------- */
#dash-root #top .ff-actions .ff-interval,
#dash-root #top .ff-actions #ff-refresh,
#dash-root #top .ff-actions #ff-admin {
  opacity: .32; background: transparent; color: var(--ff-muted); border: 1px solid transparent; box-shadow: none;
  font-size: 12px; font-weight: 500; padding: 5px 9px; gap: 5px; transition: opacity .2s, border-color .2s;
}
#dash-root #top .ff-actions .ff-interval select { font-size: 12px; font-weight: 500; color: inherit; padding: 2px 0; }
#dash-root #top .ff-actions #ff-refresh svg { width: 13px; height: 13px; }
#dash-root #top .ff-actions .app-lock { font-size: 10px; }
#dash-root #top .ff-actions .ff-interval:hover, #dash-root #top .ff-actions .ff-interval:focus-within,
#dash-root #top .ff-actions #ff-refresh:hover, #dash-root #top .ff-actions #ff-refresh:focus-visible,
#dash-root #top .ff-actions #ff-admin:hover, #dash-root #top .ff-actions #ff-admin:focus-visible,
#dash-root #top .ff-actions #ff-refresh.is-busy {
  opacity: 1; border-color: var(--ff-border-2); transform: none;
}

/* --- Admin menu: interval, «Oppdater nå» and «Skjul salonger» grouped behind one faint «Admin ▾» --- */
.ff-admingroup { position: relative; display: inline-flex; }
#dash-root #top .ff-admintoggle { display: inline-flex; align-items: center; gap: 5px; font: inherit; font-size: 12px; font-weight: 500; color: var(--ff-muted); background: transparent; border: 1px solid transparent; border-radius: 999px; padding: 5px 10px; cursor: pointer; opacity: .32; transition: opacity .2s, border-color .2s; }
#dash-root #top .ff-admintoggle:hover, #dash-root #top .ff-admintoggle:focus-visible, #dash-root #top .ff-admintoggle[aria-expanded="true"] { opacity: 1; border-color: var(--ff-border-2); }
.ff-admintoggle-caret { font-size: 10px; }
.ff-adminmenu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 40; width: 250px; max-width: calc(100vw - 32px); background: var(--ff-card); border: 1px solid var(--ff-border); border-radius: 14px; box-shadow: var(--ff-shadow); padding: 10px; display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.ff-adminmenu[hidden] { display: none; }
.ff-adminmenu-lbl { margin: 0 4px 2px; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ff-muted); }
/* inside the menu the controls are normal, full-width and readable */
#dash-root #top .ff-actions #ff-adminmenu .ff-interval,
#dash-root #top .ff-actions #ff-adminmenu #ff-refresh,
#dash-root #top .ff-actions #ff-adminmenu #ff-admin {
  opacity: 1; width: 100%; box-sizing: border-box; justify-content: flex-start; font-size: 14px; font-weight: 600;
  color: var(--ff-primary); background: var(--ff-soft); border: 1px solid transparent; border-radius: 10px; padding: 9px 12px; box-shadow: none; transform: none;
}
#dash-root #top .ff-actions #ff-adminmenu .ff-interval { justify-content: space-between; }
#dash-root #top .ff-actions #ff-adminmenu .ff-interval select { font-size: 14px; font-weight: 600; }
#dash-root #top .ff-actions #ff-adminmenu .ff-interval:hover, #dash-root #top .ff-actions #ff-adminmenu #ff-refresh:hover, #dash-root #top .ff-actions #ff-adminmenu #ff-admin:hover { border-color: var(--ff-border-2); }
#dash-root #top .ff-actions #ff-adminmenu .app-lock { display: none; }

/* KPI the data source does not provide (e.g. unique voters) */
.ff-kpi[hidden] { display: none !important; }
