/* Interní novinky — sober light corporate look, no framework. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --border: #dfe3e8;
  --text: #1c2430;
  --text-muted: #63707f;
  --accent: #1a5fb4;
  --accent-dark: #16508f;
  --danger-bg: #fdecec;
  --danger-border: #f3c2c2;
  --danger-text: #8f2222;
  --radius: 8px;
  --maxw: 900px;
  --maxw-wide: 1320px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

[hidden] { display: none !important; }

.muted { color: var(--text-muted); }

/* --- screens ------------------------------------------------------------ */

.screen { min-height: 100vh; }

.screen--center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

#screen-app {
  display: flex;
  flex-direction: column;
}

/* --- login -------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 28px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-title {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 600;
}

.login-lead {
  margin: 0 0 24px;
  color: var(--text-muted);
  font-size: 15px;
}

.login-note {
  margin: 20px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

.alert {
  margin: 18px 0 0;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  text-align: left;
}

.alert--error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
}

/* --- buttons ------------------------------------------------------------ */

.btn {
  font: inherit;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid transparent;
  transition: background-color .12s ease, border-color .12s ease;
}

.btn:disabled { opacity: .55; cursor: default; }

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn--google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 0 18px;
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  font-weight: 500;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}

.btn--google:hover:not(:disabled) { background: #f2f4f7; }

.google-mark { width: 18px; height: 18px; flex: none; }

.btn--ghost {
  padding: 6px 12px;
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
  font-size: 14px;
}

.btn--ghost:hover:not(:disabled) {
  background: #f2f4f7;
  color: var(--text);
}

/* --- app bar ------------------------------------------------------------ */

.appbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.appbar__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.appbar__brand { font-weight: 600; }

.appbar__user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.appbar__email {
  font-size: 14px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- tabs --------------------------------------------------------------- */

.tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.tabs__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  gap: 4px;
  overflow-x: auto;
}

.tab {
  font: inherit;
  cursor: pointer;
  padding: 12px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  white-space: nowrap;
}

.tab:hover { color: var(--text); }

.tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.tab--active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* --- content ------------------------------------------------------------ */

.content {
  flex: 1;
  width: 100%;
  max-width: var(--maxw);
}

/* Statistiky mají široké tabulky — na úzký sloupec pro čtení textu se nehodí. */
.content--wide,
.appbar--wide .appbar__inner,
.tabs--wide .tabs__inner,
.footer--wide .footer__inner {
  max-width: var(--maxw-wide);
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.content:focus { outline: none; }

.panel__title {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 600;
}

/* --- seznam novinek ----------------------------------------------------- */

.cards {
  display: grid;
  gap: 12px;
}

.card--link {
  display: block;
  padding: 16px 18px;
  text-decoration: none;
  color: inherit;
  transition: border-color .12s ease, box-shadow .12s ease;
}

.card--link:hover {
  border-color: #c4ccd6;
  box-shadow: 0 1px 4px rgba(16, 24, 40, .07);
}

.card--link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card__title {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 600;
  color: var(--accent);
}

.card__date {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.card__summary {
  margin: 0;
  color: #37424f;
}

.empty {
  margin: 0;
  color: var(--text-muted);
}

/* --- detail novinky ----------------------------------------------------- */

.backlink {
  font: inherit;
  cursor: pointer;
  padding: 0;
  margin-bottom: 14px;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 14px;
}

.backlink:hover { color: var(--accent-dark); text-decoration: underline; }

.backlink:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.post__meta {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
}

/* The border lives on the wrapper so the frame itself has no box decoration —
   the height JS measures is then exactly the article's content height and no
   inner scrollbar can appear. See attachAutoHeight() in js/app.js. */
.post__frame-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.post__frame {
  display: block;
  width: 100%;
  height: 0;
  border: 0;
  padding: 0;
  background: var(--surface);
  /* No scroll context inside the frame — the outer page does all the scrolling. */
  overflow: hidden;
}

/* --- statistiky (admin) ------------------------------------------------- */

.stats-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 18px;
}

.stats-nav__item {
  font: inherit;
  cursor: pointer;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 14px;
}

.stats-nav__item:hover { color: var(--text); border-color: #c4ccd6; }

.stats-nav__item--active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.stats-nav__item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
  font-size: 13px;
}

/* Široká tabulka scrolluje uvnitř sebe, stránka nikdy do stran. */
.stats-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 22px;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  white-space: nowrap;
}

.stats-table th,
.stats-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #eef1f4;
  text-align: left;
}

.stats-table tbody tr:last-child td { border-bottom: none; }
.stats-table tbody tr:hover { background: #f7f9fb; }

.stats-th {
  position: sticky;
  top: 0;
  background: #f4f6f8;
  color: var(--text-muted);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.stats-th:hover { color: var(--text); }
.stats-th::after { content: ''; display: inline-block; width: 12px; }
.stats-th[data-sort="asc"]::after { content: ' ▲'; }
.stats-th[data-sort="desc"]::after { content: ' ▼'; }

.stats-legend {
  margin: -14px 0 20px;
  font-size: 13px;
}

.stats-detail {
  margin-top: 6px;
  padding: 18px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
}

.stats-detail h3 { margin: 0 0 14px; font-size: 17px; }
.stats-detail h4 { margin: 18px 0 8px; font-size: 14px; color: var(--text-muted); }
.stats-detail h4:first-of-type { margin-top: 0; }

.linkish {
  font: inherit;
  cursor: pointer;
  padding: 0;
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
}

.linkish:hover { text-decoration: underline; }

/* --- footer ------------------------------------------------------------- */

.footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.footer__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-muted);
}

/* --- small screens ------------------------------------------------------ */

@media (max-width: 520px) {
  .appbar__inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .appbar__user { width: 100%; justify-content: space-between; }
  .card { padding: 26px 20px; }
}
