:root {
  --tgf-color-primary: #0B3D91;
  --tgf-color-accent: #D72638;
  --tgf-color-text: #0F172A;
  --tgf-color-link: #0B3D91;
  --tgf-color-muted: #64748b;
  --tgf-color-dark: #0F172A;
  --tgf-color-light: #F8FAFC;
  --tgf-color-panel: #ffffff;
  --tgf-login-bg: #0B3D91;
  --tgf-dashboard-bg: #F8FAFC;
  --tgf-bg: var(--tgf-dashboard-bg);
  --tgf-panel: var(--tgf-color-panel);
  --tgf-text: var(--tgf-color-text);
  --tgf-muted: var(--tgf-color-muted);
  --tgf-border: #e5e7eb;
  --tgf-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --tgf-accent-soft-bg: color-mix(in srgb, var(--tgf-color-primary) 14%, white);
  --tgf-accent-soft-text: var(--tgf-color-primary);
  --tgf-icon-muted-bg: #e2e8f0;
  --tgf-icon-muted-text: #64748b;
  --tgf-sidebar-width: 280px;
  --tgf-content-padding: 32px;
}

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--tgf-bg);
  color: var(--tgf-text);
  overflow-x: hidden;
}
img,
video,
svg {
  max-width: 100%;
  height: auto;
}
body.sidebar-open {
  overflow: hidden;
}

.tgf-app-chrome {
  position: relative;
  z-index: 20000;
  isolation: isolate;
  pointer-events: none;
}

.tgf-app-chrome .nav-toggle {
  pointer-events: auto;
}

.nav-toggle {
  display: none;
  position: fixed;
  top: max(12px, env(safe-area-inset-top, 0px));
  left: max(12px, env(safe-area-inset-left, 0px));
  z-index: 1;
  border: 0;
  background: var(--tgf-color-primary);
  color: #fff;
  font-size: 1.25rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.18);
  touch-action: manipulation;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 19980;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(15, 23, 42, 0.5);
  cursor: pointer;
}
.sidebar-backdrop:not([hidden]) {
  display: block;
}

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  width: var(--tgf-sidebar-width);
  height: 100vh;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--tgf-color-dark), #111827);
  color: #fff;
  padding: 22px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.brand { font-size: 1.25rem; font-weight: 800; margin-bottom: 0.35rem; }
.user-line { opacity: 0.85; font-size: 0.9rem; margin: 0 0 1.25rem; }
.sidebar nav,
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
}
.sidebar-nav-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sidebar-nav-group.is-collapsible {
  gap: 0;
}
.sidebar-nav-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin: 1.1rem 0 0.25rem;
  padding: 8px 0.35rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #94a3b8;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
}
.sidebar-nav-group.is-collapsible:first-of-type .sidebar-nav-toggle {
  margin-top: 0;
}
.sidebar-nav-toggle:hover,
.sidebar-nav-group.is-open > .sidebar-nav-toggle {
  color: #dbeafe;
}
.sidebar-nav-toggle-label {
  flex: 1;
  min-width: 0;
}
.sidebar-nav-chevron {
  flex-shrink: 0;
  width: 0.45rem;
  height: 0.45rem;
  margin-left: 0.5rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}
.sidebar-nav-group.is-open .sidebar-nav-chevron {
  transform: rotate(-135deg);
}
.sidebar-nav-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 0.15rem;
}
.sidebar-nav-items[hidden] {
  display: none !important;
}
.sidebar a,
.sidebar-nav-link {
  display: block;
  color: #dbeafe;
  text-decoration: none;
  padding: 11px 14px;
  border-radius: 12px;
  font-weight: 500;
}
.sidebar a:hover,
.sidebar-nav-link:hover,
.sidebar a.active,
.sidebar-nav-link.active {
  background: var(--tgf-color-primary);
  color: #fff;
}
.sidebar-version {
  margin: 1rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.75rem;
  color: #94a3b8;
}
.sidebar-footer {
  margin-top: auto;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-help:hover,
.sidebar-help.active {
  background: rgba(59, 130, 246, 0.22);
  color: #dbeafe;
}
.sidebar-logout:hover,
.sidebar-logout.active {
  background: rgba(215, 38, 56, 0.22);
  color: #fecaca;
}

.content {
  flex: 1;
  min-width: 0;
  margin-left: var(--tgf-sidebar-width);
  padding: var(--tgf-content-padding);
  max-width: none;
}
.dev-publish-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: calc(-1 * var(--tgf-content-padding)) calc(-1 * var(--tgf-content-padding)) var(--tgf-content-padding);
  padding: 10px var(--tgf-content-padding);
  background: linear-gradient(90deg, var(--tgf-color-primary), color-mix(in srgb, var(--tgf-color-primary) 75%, #2563eb));
  color: #eff6ff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  font-size: 0.92rem;
  font-weight: 500;
}
.dev-publish-bar-text {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}
.dev-publish-bar-label {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.btn-dev-publish {
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  background: #fff;
  color: var(--tgf-color-primary);
  font-weight: 700;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
  font: inherit;
}
.btn-dev-publish:hover {
  background: #eff6ff;
}
.dev-publish-notice {
  margin-top: 0;
}
.card {
  background: var(--tgf-panel);
  border-radius: 18px;
  padding: 1.35rem 1.5rem;
  box-shadow: var(--tgf-shadow);
  border: 1px solid rgba(148, 163, 184, 0.2);
  margin-bottom: 1rem;
  min-width: 0;
}
.card:has(table),
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
h1 { margin-top: 0; font-size: 1.65rem; font-weight: 800; }
h2 { font-size: 1.1rem; margin: 1rem 0 0.75rem; font-weight: 700; }
h2:first-child { margin-top: 0; }

.page-toolbar {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.page-toolbar .btn,
.page-toolbar button {
  max-width: 100%;
}

.hint { color: var(--tgf-muted); margin: 0 0 1rem; line-height: 1.5; }
.hint a { color: var(--tgf-color-link); }

.content a:not(.btn):not(.btn-secondary):not(.btn-link):not(.doc-status-tab):not(.doc-folder-tile) {
  color: var(--tgf-color-link);
}

label.field-label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 600; font-size: 0.9rem; }

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea {
  font: inherit;
  width: 100%;
  max-width: 420px;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--tgf-border);
}

input[type="checkbox"],
input[type="radio"] {
  width: 1rem;
  height: 1rem;
  max-width: none;
  margin: 0.15rem 0 0;
  flex-shrink: 0;
  padding: 0;
  accent-color: var(--tgf-color-primary);
}

button, .btn {
  display: inline-block;
  width: auto;
  background: var(--tgf-color-primary);
  color: #fff;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  padding: 0.6rem 1.1rem;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
}
.btn-secondary { background: var(--tgf-icon-muted-text); }
.btn-secondary:hover { background: #475569; }

.tgf-btn-fit-line {
  display: inline-block;
  white-space: nowrap;
  line-height: 1.15;
  max-width: 100%;
  box-sizing: border-box;
  font-size: 0.875rem;
  padding: 0.5rem 0.65rem;
}

.content .card table .actions a.btn.tgf-btn-fit-line,
.content .doc-folder-contents table .actions a.btn.tgf-btn-fit-line {
  display: block;
  width: 100%;
  max-width: 100%;
  white-space: nowrap;
  padding: 0.4rem 0.45rem;
  text-align: center;
  line-height: 1.15;
}

.tgf-cell-fit-name {
  min-width: 0;
  vertical-align: top;
}

.tgf-name-fit {
  display: inline-block;
  max-width: 100%;
  line-height: 1.25;
}

.tgf-name-fit.is-single-line {
  white-space: nowrap;
}

.tgf-name-fit.is-word-lines {
  display: block;
}

.tgf-name-fit-part {
  display: block;
  white-space: nowrap;
}

table { width: 100%; border-collapse: collapse; background: var(--tgf-panel); }
th, td { text-align: left; padding: 0.75rem; border-bottom: 1px solid var(--tgf-border); vertical-align: top; }
th { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--tgf-muted); }
code { font-size: 0.85rem; background: var(--tgf-color-light); padding: 0.1rem 0.35rem; border-radius: 6px; }

.form-actions { margin-top: 1.25rem; display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }

.notice { padding: 0.85rem 1rem; border-radius: 12px; margin: 0.75rem 0; border: 1px solid transparent; }
.notice.error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.notice.success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.notice.info { background: var(--tgf-accent-soft-bg); color: var(--tgf-accent-soft-text); border-color: color-mix(in srgb, var(--tgf-color-primary) 25%, white); }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--tgf-color-primary), var(--tgf-color-dark));
}
.login-box {
  background: #fff;
  padding: 2rem;
  border-radius: 14px;
  width: min(420px, calc(100% - 2rem));
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
}
.login-box h1 { color: var(--tgf-color-primary); }
.login-box a { color: var(--tgf-color-link); }
.login-box label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 600; }
.login-box input { width: 100%; max-width: none; }

.login-mode-intro {
  margin: 0 0 1rem;
  color: var(--tgf-muted);
  line-height: 1.5;
}
.login-mode-panel[hidden] {
  display: none !important;
}
.login-mode-switch {
  margin: 1rem 0 0;
  text-align: center;
}
.login-mode-switch-btn {
  font-size: 0.88rem;
  font-weight: 500;
}
.login-box-links {
  margin: 0.85rem 0 0;
  text-align: center;
  font-size: 0.92rem;
}
.login-box #passkeyLoginBtn,
.login-box #passwordLoginForm button[type="submit"] {
  width: 100%;
  margin-top: 1rem;
}

.passkey-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
}
.passkey-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--tgf-border);
}
.passkey-list li:last-child {
  border-bottom: 0;
}
.passkey-list small {
  color: var(--tgf-muted);
  margin-right: auto;
}

.login-box-logo {
  text-align: center;
  margin-bottom: 1rem;
}

.login-box-logo img {
  display: inline-block;
  max-width: min(180px, 100%);
  max-height: 120px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.login-box-lead {
  margin: 0 0 1.25rem;
  line-height: 1.55;
  color: var(--tgf-muted);
  text-align: center;
  font-size: 0.98rem;
}

.login-box-lead strong {
  color: var(--tgf-color-primary);
}

.login-box--register button[type="submit"] {
  margin-top: 0.5rem;
}

.perm-group-title {
  font-size: 1rem;
  color: var(--tgf-color-primary);
  border-bottom: 1px solid #e2e8f0;
  padding-bottom: 0.35rem;
  margin-top: 1.25rem;
}
.perm-group-title:first-child { margin-top: 0; }

.perm-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.5rem;
  margin-bottom: 0.5rem;
}

.perm-grid > .perm-item {
  display: flex;
  flex: 1 1 260px;
  max-width: 100%;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 0;
  font-weight: 400;
  line-height: 1.4;
  cursor: pointer;
}

.perm-grid input[type="checkbox"],
.perm-grid input[type="radio"] {
  width: 1rem;
  height: 1rem;
  max-width: none;
  flex: 0 0 auto;
  margin: 0.15rem 0 0;
}

.perm-label { flex: 1 1 auto; min-width: 0; word-break: break-word; }

.perm-nd {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  background: #fee2e2;
  color: #991b1b;
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  margin-left: 0.25rem;
  vertical-align: middle;
}

.perm-table code { word-break: break-all; }

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin: 0;
  padding: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}
.subnav a {
  color: var(--tgf-color-link);
  text-decoration: none;
  font-size: 0.92rem;
}
.subnav a:hover { text-decoration: underline; }
.subnav a.active { font-weight: 700; text-decoration: underline; }
.card .subnav {
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--tgf-border);
}

.doc-section-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.doc-section-head .page-toolbar {
  margin-bottom: 0;
}
.doc-section-head .hint {
  margin-bottom: 0;
}

.doc-status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.doc-status-tab {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--tgf-border);
  background: #fff;
  color: var(--tgf-text);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.doc-status-tab:hover {
  border-color: color-mix(in srgb, var(--tgf-color-primary) 35%, white);
  background: var(--tgf-accent-soft-bg);
  color: var(--tgf-color-primary);
}
.doc-status-tab.is-active {
  border-color: var(--tgf-color-primary);
  background: var(--tgf-color-primary);
  color: #fff;
}
.doc-status-tab.is-active:hover {
  color: #fff;
  background: var(--tgf-color-primary);
  border-color: var(--tgf-color-primary);
}

.doc-folder-heading,
.doc-folder-contents__title {
  margin: 0 0 0.85rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--tgf-text);
}
.doc-folder-heading {
  margin-top: 0.25rem;
}

.doc-folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.35rem;
}

.doc-folder-tile {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 132px;
  padding: 1rem 1rem 0.95rem;
  border-radius: 16px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.doc-folder-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
  border-color: color-mix(in srgb, var(--tgf-color-primary) 28%, white);
}
.doc-folder-tile.is-active {
  border-color: var(--tgf-color-primary);
  background: linear-gradient(180deg, color-mix(in srgb, var(--tgf-color-primary) 8%, white) 0%, #ffffff 100%);
  box-shadow: 0 8px 20px rgba(11, 61, 145, 0.12);
}

.doc-folder-tile__icon {
  position: relative;
  width: 2.6rem;
  height: 2rem;
  border-radius: 6px 6px 4px 4px;
  flex-shrink: 0;
}
.doc-folder-tile__icon::before,
.doc-folder-tile__icon::after {
  content: "";
  position: absolute;
  left: 0;
  border-radius: 4px;
}
.doc-folder-tile__icon::before {
  top: 0;
  width: 1.15rem;
  height: 0.45rem;
  border-radius: 4px 4px 0 0;
}
.doc-folder-tile__icon::after {
  top: 0.28rem;
  width: 100%;
  height: calc(100% - 0.28rem);
  border-radius: 0 6px 6px 6px;
}
.doc-folder-tile--club .doc-folder-tile__icon::before,
.doc-folder-tile--club .doc-folder-tile__icon::after {
  background: color-mix(in srgb, var(--tgf-color-primary) 72%, white);
}
.doc-folder-tile--club .doc-folder-tile__icon::before {
  background: color-mix(in srgb, var(--tgf-color-primary) 55%, white);
}
.doc-folder-tile--personal .doc-folder-tile__icon::before,
.doc-folder-tile--personal .doc-folder-tile__icon::after {
  background: color-mix(in srgb, #0f766e 72%, white);
}
.doc-folder-tile--personal .doc-folder-tile__icon::before {
  background: color-mix(in srgb, #0f766e 55%, white);
}

.doc-folder-tile__body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}
.doc-folder-tile__name {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.35;
  word-break: break-word;
}
.doc-folder-tile__count {
  font-size: 0.8rem;
  color: var(--tgf-muted);
}

.doc-folder-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}
.doc-folder-toolbar .doc-folder-contents__title {
  margin-bottom: 0;
}
.doc-folder-toolbar .btn {
  padding: 0.45rem 0.85rem;
  font-size: 0.88rem;
}

.doc-folder-contents {
  padding-top: 0.35rem;
  border-top: 1px solid var(--tgf-border);
}

.help-handbook-toc h2 {
  margin-top: 0;
}
.help-toc-list {
  margin: 0;
  padding-left: 1.25rem;
  columns: 2;
  column-gap: 2rem;
}
.help-toc-list li {
  margin: 0.35rem 0;
  break-inside: avoid;
}
.help-toc-list a {
  color: var(--tgf-color-link);
  text-decoration: none;
  font-weight: 600;
}
.help-toc-list a:hover {
  text-decoration: underline;
}

.help-handbook {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.help-chapter h2 {
  margin-top: 0;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--tgf-border);
}
.help-chapter.is-highlighted {
  border-color: color-mix(in srgb, var(--tgf-color-primary) 35%, white);
  box-shadow: 0 8px 24px rgba(11, 61, 145, 0.1);
}
.help-chapter-intro {
  margin-bottom: 1rem;
}
.help-section {
  margin-top: 1.25rem;
}
.help-section h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--tgf-color-primary);
}
.help-section p {
  margin: 0 0 0.65rem;
  line-height: 1.55;
}
.help-list {
  margin: 0 0 0.75rem;
  padding-left: 1.25rem;
  line-height: 1.55;
}
.help-list li {
  margin: 0.35rem 0;
}

.form-grid,
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem 1rem;
}

.filter-form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  align-items: flex-end;
}

.color-swatch {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 0.35rem;
  border: 1px solid rgba(15, 23, 42, 0.15);
}

.target-fields h4 {
  margin: 1rem 0 0.35rem;
  font-size: 0.95rem;
  color: var(--tgf-color-primary);
}

.color-row input[type="color"] {
  width: 100%;
  max-width: none;
  height: 2.5rem;
  padding: 0.15rem;
}

.design-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.design-color-item {
  min-width: 0;
}

.design-color-hint {
  margin: 0.15rem 0 0.65rem;
  font-size: 0.85rem;
}

.tgf-color-field {
  position: relative;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
}

.tgf-color-native {
  width: 52px;
  height: 42px;
  padding: 0.15rem;
  border: 1px solid var(--tgf-border);
  border-radius: 12px;
  background: var(--tgf-panel);
  cursor: pointer;
}

.tgf-color-hex {
  width: 100%;
  max-width: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  letter-spacing: 0.02em;
}

.tgf-color-palette-toggle {
  border: 1px solid var(--tgf-border);
  border-radius: 10px;
  background: var(--tgf-color-light);
  color: var(--tgf-color-text);
  padding: 0.5rem 0.75rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

.tgf-color-palette-toggle:hover {
  border-color: var(--tgf-color-primary);
}

.tgf-color-palette {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.45rem;
  padding: 0.75rem;
  background: var(--tgf-panel);
  border: 1px solid var(--tgf-border);
  border-radius: 14px;
  box-shadow: var(--tgf-shadow);
}

.tgf-color-palette[hidden] {
  display: none;
}

.tgf-color-swatch {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid var(--tgf-border);
  border-radius: 8px;
  padding: 0;
  cursor: pointer;
  background-color: var(--tgf-color-light);
}

.tgf-color-swatch.is-selected {
  border-color: var(--tgf-color-primary);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--tgf-color-primary) 35%, white);
}

.tgf-color-swatch[data-tgf-color-swatch="#0B3D91"] { background-color: #0B3D91; }
.tgf-color-swatch[data-tgf-color-swatch="#1D4ED8"] { background-color: #1D4ED8; }
.tgf-color-swatch[data-tgf-color-swatch="#2563EB"] { background-color: #2563EB; }
.tgf-color-swatch[data-tgf-color-swatch="#3B82F6"] { background-color: #3B82F6; }
.tgf-color-swatch[data-tgf-color-swatch="#0F172A"] { background-color: #0F172A; }
.tgf-color-swatch[data-tgf-color-swatch="#1E293B"] { background-color: #1E293B; }
.tgf-color-swatch[data-tgf-color-swatch="#334155"] { background-color: #334155; }
.tgf-color-swatch[data-tgf-color-swatch="#64748B"] { background-color: #64748B; }
.tgf-color-swatch[data-tgf-color-swatch="#D72638"] { background-color: #D72638; }
.tgf-color-swatch[data-tgf-color-swatch="#DC2626"] { background-color: #DC2626; }
.tgf-color-swatch[data-tgf-color-swatch="#B91C1C"] { background-color: #B91C1C; }
.tgf-color-swatch[data-tgf-color-swatch="#EF4444"] { background-color: #EF4444; }
.tgf-color-swatch[data-tgf-color-swatch="#16A34A"] { background-color: #16A34A; }
.tgf-color-swatch[data-tgf-color-swatch="#15803D"] { background-color: #15803D; }
.tgf-color-swatch[data-tgf-color-swatch="#059669"] { background-color: #059669; }
.tgf-color-swatch[data-tgf-color-swatch="#22C55E"] { background-color: #22C55E; }
.tgf-color-swatch[data-tgf-color-swatch="#F59E0B"] { background-color: #F59E0B; }
.tgf-color-swatch[data-tgf-color-swatch="#D97706"] { background-color: #D97706; }
.tgf-color-swatch[data-tgf-color-swatch="#CA8A04"] { background-color: #CA8A04; }
.tgf-color-swatch[data-tgf-color-swatch="#FBBF24"] { background-color: #FBBF24; }
.tgf-color-swatch[data-tgf-color-swatch="#7C3AED"] { background-color: #7C3AED; }
.tgf-color-swatch[data-tgf-color-swatch="#6D28D9"] { background-color: #6D28D9; }
.tgf-color-swatch[data-tgf-color-swatch="#9333EA"] { background-color: #9333EA; }
.tgf-color-swatch[data-tgf-color-swatch="#A855F7"] { background-color: #A855F7; }
.tgf-color-swatch[data-tgf-color-swatch="#0891B2"] { background-color: #0891B2; }
.tgf-color-swatch[data-tgf-color-swatch="#0E7490"] { background-color: #0E7490; }
.tgf-color-swatch[data-tgf-color-swatch="#06B6D4"] { background-color: #06B6D4; }
.tgf-color-swatch[data-tgf-color-swatch="#22D3EE"] { background-color: #22D3EE; }
.tgf-color-swatch[data-tgf-color-swatch="#F8FAFC"] { background-color: #F8FAFC; }
.tgf-color-swatch[data-tgf-color-swatch="#F1F5F9"] { background-color: #F1F5F9; }
.tgf-color-swatch[data-tgf-color-swatch="#E2E8F0"] { background-color: #E2E8F0; }
.tgf-color-swatch[data-tgf-color-swatch="#FFFFFF"] { background-color: #FFFFFF; }

.widget-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.widget-grid.is-editing .widget-card {
  animation: widget-wobble 0.32s ease-in-out infinite;
  cursor: grab;
}
.widget-grid.is-editing .widget-card.is-dragging {
  animation: none;
  opacity: 0.75;
  cursor: grabbing;
  z-index: 4;
}
.widget-card.is-flipping {
  transition: transform 0.22s cubic-bezier(0.2, 0, 0, 1);
}
.widget-editable {
  position: relative;
}
.widget-edit-remove {
  position: absolute;
  top: -0.45rem;
  left: -0.45rem;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  border: 2px solid #fff;
  background: #64748b;
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  z-index: 6;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25);
  display: none;
}
.widget-grid.is-editing .widget-edit-remove {
  display: block;
}
.widget-grid.is-editing .widget-card a,
.widget-grid.is-editing .widget-card iframe {
  pointer-events: none;
}
@keyframes widget-wobble {
  0% { transform: rotate(-0.7deg); }
  50% { transform: rotate(0.7deg); }
  100% { transform: rotate(-0.7deg); }
}
.dashboard-edit-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.65rem 1rem;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.08);
}
.dashboard-edit-bar[hidden] {
  display: none !important;
}
.dashboard-edit-add {
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 50%;
  border: 0;
  background: var(--tgf-color-primary);
  color: #fff;
  font-size: 1.45rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}
.dashboard-edit-label {
  flex: 1;
  font-weight: 600;
  color: #334155;
}
.dashboard-edit-done {
  flex-shrink: 0;
}
.dashboard-add-sheet {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 4rem 1rem 1rem;
}
.dashboard-add-sheet[hidden] {
  display: none !important;
}
.dashboard-add-sheet-inner {
  width: min(420px, 100%);
  max-height: 70vh;
  overflow: auto;
}
.dashboard-add-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
}
.dashboard-add-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.35rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font: inherit;
}
.dashboard-add-item:hover {
  border-color: var(--tgf-color-primary);
  background: #f8fbff;
}
.widget-card h2 { margin-top: 0; }
.stat-list { margin: 0; padding-left: 1.2rem; }

.widget-body {
  min-height: 0;
}
.widget-body.is-live-updated {
  animation: widget-live-flash 0.7s ease;
}
@keyframes widget-live-flash {
  0% { background: rgba(37, 99, 235, 0.08); }
  100% { background: transparent; }
}

.widget-pending-role {
  position: relative;
  overflow: hidden;
}
.widget-pending-role-fx {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}
.widget-pending-role-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 1.5rem 1rem;
}
.widget-pending-role-title {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
}
.widget-pending-role-content p {
  margin: 0;
}
@media (prefers-reduced-motion: no-preference) {
  .widget-pending-role.is-celebrating .widget-pending-role-title {
    animation: widget-pending-role-glow 2.4s ease-in-out 6;
  }
}
@keyframes widget-pending-role-glow {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.03); }
}

.widget-welcome {
  grid-column: 1 / -1;
  position: relative;
  overflow: hidden;
  border: 0;
  min-height: 160px;
  background-size: cover;
  background-position: center;
}
.widget-welcome-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.55), rgba(15, 23, 42, 0.35));
}
.widget-welcome-content {
  position: relative;
  z-index: 1;
  color: #fff;
}
.widget-welcome-content h2,
.widget-welcome-content p,
.widget-welcome-content .hint { color: #fff; }
.widget-welcome-content .hint { opacity: 0.9; }
.widget-weather-line { font-size: 0.95rem; margin-top: 0.75rem; }

.widget-welcome--default .widget-welcome-overlay {
  background: linear-gradient(135deg, rgba(11, 61, 145, 0.85), rgba(15, 23, 42, 0.65));
}
.widget-welcome--clear .widget-welcome-overlay {
  background: linear-gradient(135deg, rgba(14, 116, 214, 0.55), rgba(250, 204, 21, 0.35));
}
.widget-welcome--partly-cloudy .widget-welcome-overlay {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.55), rgba(148, 163, 184, 0.45));
}
.widget-welcome--cloudy .widget-welcome-overlay {
  background: linear-gradient(135deg, rgba(71, 85, 105, 0.7), rgba(100, 116, 139, 0.55));
}
.widget-welcome--rain .widget-welcome-overlay {
  background: linear-gradient(135deg, rgba(30, 58, 138, 0.75), rgba(51, 65, 85, 0.65));
}
.widget-welcome--snow .widget-welcome-overlay {
  background: linear-gradient(135deg, rgba(148, 163, 184, 0.75), rgba(226, 232, 240, 0.55));
}
.widget-welcome--fog .widget-welcome-overlay {
  background: linear-gradient(135deg, rgba(100, 116, 139, 0.75), rgba(203, 213, 225, 0.55));
}
.widget-welcome--storm .widget-welcome-overlay {
  background: linear-gradient(135deg, rgba(30, 27, 75, 0.85), rgba(67, 56, 202, 0.55));
}
.widget-welcome--night .widget-welcome-overlay {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.75));
}

.widget-welcome[style*="--widget-welcome-bg"] {
  background-image: var(--widget-welcome-bg);
}
.widget-welcome[style*="--widget-welcome-bg"] .widget-welcome-overlay {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.5), rgba(15, 23, 42, 0.35));
}

.sidebar-logo {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: 56px;
  object-fit: contain;
  margin-bottom: 0.75rem;
}
.club-logo-preview {
  display: block;
  max-width: 200px;
  max-height: 120px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.brand-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}
.brand-preview-card h2 { font-size: 1rem; margin-top: 0; }
.brand-preview-icon-wrap {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.brand-preview-icon {
  width: 128px;
  height: 128px;
  border-radius: 24px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
}
.brand-preview-icon-small {
  width: 48px;
  height: 48px;
  border-radius: 10px;
}

textarea {
  font: inherit;
  width: 100%;
  max-width: 420px;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--tgf-border);
}

.actions { white-space: nowrap; }
.actions .btn-link,
.actions form {
  white-space: normal;
}
.inline-form { display: inline; }
.btn-link {
  background: none;
  border: 0;
  color: var(--tgf-color-accent);
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-decoration: underline;
}
.filter-form select {
  max-width: 320px;
}

.content-topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
  position: relative;
}

.content-topbar.is-hidden {
  display: none;
  margin-bottom: 0;
}

.notification-bell {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font: inherit;
}

.notification-badge {
  display: inline-block;
  min-width: 1.1rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--tgf-color-accent);
  color: #fff;
  font-size: 0.75rem;
  margin-left: 0.25rem;
}

.notification-panel {
  position: absolute;
  top: 2.5rem;
  right: 0;
  width: min(360px, 92vw);
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
  z-index: 30;
}

.notification-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e2e8f0;
}

.notification-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 320px;
  overflow: auto;
}

.notification-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
}

.notification-item a {
  display: block;
  color: var(--tgf-color-link);
  text-decoration: none;
  font-weight: 600;
}

.notification-item.is-read { opacity: 0.65; }
.notification-empty { padding: 1rem; color: #64748b; }

.widget-notification-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.widget-notification-item + .widget-notification-item {
  margin-top: 0.5rem;
}
.widget-notification-link {
  display: block;
  color: inherit;
  text-decoration: none;
  border-radius: 8px;
  padding: 0.4rem 0.35rem;
  margin: 0 -0.35rem;
}
.widget-notification-link:hover {
  background: var(--tgf-surface-muted, rgba(0, 0, 0, 0.04));
  color: var(--tgf-link, #2563eb);
}
.widget-notification-link strong {
  display: block;
  font-weight: 600;
}
.widget-notification-link .hint {
  display: block;
  margin-top: 0.2rem;
}

.comment-item {
  border-bottom: 1px solid #e2e8f0;
  padding: 0.75rem 0;
}

.row-unread td { font-weight: inherit; }
.message-new-badge {
  display: inline-block;
  margin-right: 0.4rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1.2;
  vertical-align: middle;
}
.row-clickable { cursor: pointer; }
.row-clickable:hover td { background: var(--tgf-surface-muted, rgba(0, 0, 0, 0.04)); }
.doc-file-link {
  color: var(--tgf-link, #2563eb);
  font-weight: 600;
}
.row-clickable:hover .doc-file-link {
  text-decoration: underline;
}
a.doc-file-link {
  text-decoration: none;
}
a.doc-file-link:hover {
  text-decoration: underline;
}
.doc-file-hint {
  display: block;
  margin-top: 0.15rem;
}

.checklist-row { margin-bottom: 0.5rem; }

.sort-order-input {
  width: 5rem;
  max-width: none;
}

.status-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.status-ok { background: #dcfce7; color: #166534; }
.status-warn { background: #fef9c3; color: #854d0e; }
.status-error { background: #fee2e2; color: #991b1b; }
.status-info { background: #e0f2fe; color: #075985; }

.inline-form {
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.btn-danger {
  background: var(--tgf-color-accent);
  border-color: var(--tgf-color-accent);
}

.filter-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 0.75rem 1rem;
  align-items: end;
}

.dashboard-embed {
  width: 100%;
  min-height: 200px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin-top: 0.5rem;
}

.player-photo-preview {
  max-width: 120px;
  border-radius: 8px;
  margin-bottom: 0.5rem;
}

.message-reactions { margin-top: 0.5rem; }
.message-reaction-form { display: inline-flex; gap: 0.35rem; flex-wrap: wrap; align-items: center; }
.reaction-badge {
  display: inline-block;
  margin-right: 0.35rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: #f1f5f9;
  font-size: 0.9rem;
}
.message-attachment-image {
  max-width: 240px;
  max-height: 180px;
  border-radius: 6px;
  margin-top: 0.35rem;
}

tr.row-highlight td {
  background: var(--tgf-color-light);
}

/* Lightbox (Termin-Muster, Präfix tgf-) */
.tgf-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 21000;
  box-sizing: border-box;
  pointer-events: none;
  padding: 24px;
  align-items: center;
  justify-content: center;
}

.tgf-lightbox.is-open {
  display: flex !important;
  pointer-events: auto;
}

.tgf-lightbox-backdrop,
.tgf-lightbox-dialog,
.tgf-lightbox-dialog-wide {
  pointer-events: auto;
}

.tgf-lightbox[aria-hidden="true"] {
  display: none !important;
  pointer-events: none;
}

.tgf-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.58);
  backdrop-filter: blur(4px);
  z-index: 0;
}

.player-edit-section,
.player-create-section {
  scroll-margin-top: calc(3.5rem + env(safe-area-inset-top, 0px));
}

.tgf-lightbox-dialog {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100vw - 48px));
  max-width: 760px;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  overflow: auto;
  background: var(--tgf-panel);
  color: var(--tgf-text);
  border-radius: 24px;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.28);
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.tgf-lightbox-dialog-wide {
  width: min(920px, calc(100vw - 48px));
  max-width: 920px;
}

.tgf-lightbox-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 28px 0;
}

.tgf-lightbox-header h2 {
  margin: 0 0 6px;
}

.tgf-lightbox-header p {
  margin: 0;
  color: var(--tgf-muted);
}

.tgf-lightbox-close {
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: var(--tgf-icon-muted-bg);
  color: var(--tgf-icon-muted-text);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.tgf-lightbox-close:hover {
  background: var(--tgf-border);
  color: var(--tgf-text);
}

.tgf-lightbox-body {
  padding: 20px 28px 28px;
}

.tgf-lightbox-body.form-grid,
.tgf-lightbox-body .form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem 1rem;
}

.tgf-lightbox-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.tgf-lightbox-footer .full,
.full.tgf-lightbox-footer {
  width: 100%;
}

body.tgf-lightbox-open {
  overflow: hidden;
}

body.tgf-lightbox-open .tgf-app-chrome,
body.tgf-lightbox-open .nav-toggle {
  z-index: 0;
  visibility: hidden;
  pointer-events: none;
}

.changelog h1 {
  font-size: 1.35rem;
  margin: 0 0 0.75rem;
}
.changelog h2 {
  font-size: 1.15rem;
  margin: 1.5rem 0 0.65rem;
  padding-top: 0.35rem;
  border-top: 1px solid var(--tgf-border);
}
.changelog h2:first-child {
  border-top: 0;
  padding-top: 0;
  margin-top: 0;
}
.changelog h3 {
  font-size: 1rem;
  margin: 1rem 0 0.4rem;
}
.changelog p {
  margin: 0.4rem 0;
  color: var(--tgf-muted);
}
.changelog-list {
  margin: 0.35rem 0 0.75rem;
  padding-left: 1.25rem;
}
.changelog-list li {
  margin: 0.25rem 0;
}
.changelog hr {
  border: 0;
  border-top: 1px solid var(--tgf-border);
  margin: 1.25rem 0;
}
.changelog code {
  font-size: 0.9em;
  background: var(--tgf-icon-muted-bg);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.profile-menu {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}

.profile-menu-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0;
}

.profile-menu-card h2 {
  margin: 0;
  font-size: 1.05rem;
}

.profile-menu-card .hint {
  flex: 1;
  margin: 0;
}

.profile-menu-card .btn {
  align-self: flex-start;
  margin-top: 0.35rem;
}

.tgf-edit-panels {
  display: none !important;
}

@media (max-width: 1200px) {
  :root {
    --tgf-content-padding: 24px;
  }
}

@media (max-width: 900px) {
  :root {
    --tgf-content-padding: 18px;
  }

  .nav-toggle { display: block; }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(var(--tgf-sidebar-width), 88vw);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 120;
    box-shadow: 8px 0 32px rgba(15, 23, 42, 0.22);
  }
  .sidebar.open {
    transform: translateX(0);
    z-index: 19990;
  }

  .content {
    margin-left: 0;
    padding-top: calc(var(--tgf-content-padding) + 2.75rem);
  }

  h1 { font-size: 1.45rem; }
  h2 { font-size: 1.02rem; }

  .card {
    padding: 1.1rem 1rem;
    border-radius: 14px;
  }

  .content input:not([type="checkbox"]):not([type="radio"]),
  .content select,
  .content textarea,
  .tgf-lightbox input:not([type="checkbox"]):not([type="radio"]),
  .tgf-lightbox select,
  .tgf-lightbox textarea {
    max-width: none;
  }

  .filter-form select {
    max-width: none;
  }

  .actions {
    white-space: normal;
  }

  th, td {
    padding: 0.6rem 0.5rem;
    font-size: 0.92rem;
  }

  th {
    font-size: 0.78rem;
  }

  .page-toolbar {
    justify-content: stretch;
  }
  .page-toolbar .btn,
  .page-toolbar button,
  .page-toolbar a.btn {
    flex: 1 1 auto;
    text-align: center;
  }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .form-actions .btn,
  .form-actions button,
  .form-actions a.btn {
    width: 100%;
    text-align: center;
  }

  .filter-form-row {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-form-row > * {
    width: 100%;
  }
  .filter-form {
    grid-template-columns: 1fr;
  }

  .dashboard-edit-bar {
    flex-wrap: wrap;
  }
  .dashboard-edit-label {
    flex: 1 1 100%;
    order: 2;
  }
  .dashboard-edit-done {
    margin-left: auto;
  }

  .dashboard-add-sheet {
    padding: 1rem 0.75rem;
    align-items: flex-end;
  }
  .dashboard-add-sheet-inner {
    max-height: 85vh;
  }

  .widget-grid {
    grid-template-columns: 1fr;
  }

  .design-color-grid,
  .profile-menu,
  .brand-preview-grid {
    grid-template-columns: 1fr;
  }

  .tgf-color-field {
    grid-template-columns: 52px minmax(0, 1fr);
  }
  .tgf-color-palette-toggle {
    grid-column: 1 / -1;
    width: 100%;
  }
  .tgf-color-palette {
    grid-template-columns: repeat(6, 1fr);
  }

  .brand-preview-icon-wrap {
    flex-wrap: wrap;
  }

  .content-topbar {
    position: fixed;
    top: max(10px, env(safe-area-inset-top, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    z-index: 125;
    margin-bottom: 0;
  }

  .dev-publish-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .btn-dev-publish {
    width: 100%;
  }

  .notification-panel {
    position: fixed;
    top: calc(2.85rem + env(safe-area-inset-top, 0px));
    right: max(10px, env(safe-area-inset-right, 0px));
    left: max(10px, env(safe-area-inset-left, 0px));
    width: auto;
    max-width: none;
  }

  .perm-grid > .perm-item { flex-basis: 100%; }

  .subnav {
    gap: 0.35rem 0.75rem;
  }

  .doc-folder-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.65rem;
  }

  .doc-folder-tile {
    min-height: 118px;
    padding: 0.85rem;
  }

  .help-toc-list {
    columns: 1;
  }

  .tgf-lightbox {
    padding: 12px;
  }
  .tgf-lightbox-dialog,
  .tgf-lightbox-dialog-wide {
    width: min(920px, calc(100vw - 24px));
    max-width: none;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    border-radius: 18px;
  }
  .tgf-lightbox-header {
    padding: 18px 18px 0;
  }
  .tgf-lightbox-body {
    padding: 16px 18px 20px;
  }
  .tgf-lightbox-body.form-grid,
  .tgf-lightbox-body .form-grid,
  .form-grid,
  .form-row {
    grid-template-columns: 1fr;
  }
  .tgf-lightbox-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .tgf-lightbox-footer .btn,
  .tgf-lightbox-footer button,
  .tgf-lightbox-footer a.btn {
    width: 100%;
    text-align: center;
  }
}

@media (max-width: 640px) {
  :root {
    --tgf-content-padding: 14px;
  }

  .nav-toggle {
    padding: 0.45rem 0.65rem;
    font-size: 1.15rem;
  }

  h1 { font-size: 1.3rem; }

  .card {
    padding: 0.95rem 0.85rem;
  }

  button, .btn {
    padding: 0.58rem 0.95rem;
  }

  .login-box {
    padding: 1.5rem 1.25rem;
    width: min(420px, calc(100% - 1.5rem));
  }

  .message-attachment-image {
    max-width: 100%;
    height: auto;
  }

  .tgf-color-palette {
    grid-template-columns: repeat(5, 1fr);
  }

  .perm-table code {
    word-break: break-word;
  }
}

@media (max-width: 900px) and (orientation: landscape) {
  .sidebar {
    width: min(260px, 72vw);
  }
  .content table {
    min-width: 32rem;
  }
  .tgf-lightbox {
    padding: 8px;
  }
  .tgf-lightbox-dialog,
  .tgf-lightbox-dialog-wide {
    width: min(920px, calc(100vw - 16px));
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 16px;
  }
}

.compose-mode-switch {
  display: inline-flex;
  gap: 0;
  margin-bottom: 1rem;
  padding: 0.2rem;
  border: 1px solid var(--tgf-border);
  border-radius: 999px;
  background: var(--tgf-panel);
}

.compose-mode-option {
  position: relative;
  margin: 0;
}

.compose-mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.compose-mode-option span {
  display: inline-block;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--tgf-muted);
  font-size: 0.95rem;
  line-height: 1.2;
}

.compose-mode-option input:checked + span {
  background: var(--tgf-accent-soft-bg);
  color: var(--tgf-accent-soft-text);
  font-weight: 600;
}

.address-fields {
  margin-bottom: 1rem;
}

.address-field-wrap input[data-address-city],
.address-field-wrap input[data-address-street] {
  border: 0;
  width: 100%;
  max-width: none;
  min-width: 12rem;
  padding: 0.25rem 0;
  background: transparent;
  color: var(--tgf-text);
  -webkit-text-fill-color: var(--tgf-text);
}

.address-field-wrap input[data-address-city]::placeholder,
.address-field-wrap input[data-address-street]::placeholder {
  color: var(--tgf-muted);
  opacity: 1;
}

.address-field-wrap input[data-address-city]:disabled,
.address-field-wrap input[data-address-street]:disabled {
  opacity: 0.65;
}

.message-compose-recipients {
  margin-bottom: 1rem;
}

.recipient-input-wrap {
  position: relative;
  border: 1px solid var(--tgf-border);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  background: var(--tgf-panel);
  color: var(--tgf-text);
  max-width: none;
}

.recipient-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.25rem;
}

.recipient-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--tgf-accent-soft-bg);
  color: var(--tgf-accent-soft-text);
  font-size: 0.92rem;
}

.recipient-chip-remove {
  border: 0;
  background: transparent;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  color: inherit;
}

.recipient-input-wrap input[data-recipient-input] {
  border: 0;
  width: 100%;
  max-width: none;
  min-width: 12rem;
  padding: 0.25rem 0;
  background: transparent;
  color: var(--tgf-text);
  -webkit-text-fill-color: var(--tgf-text);
}

.recipient-input-wrap input[data-recipient-input]::placeholder {
  color: var(--tgf-muted);
  opacity: 1;
}

.recipient-suggestions {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 2px);
  z-index: 30;
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--tgf-border);
  border-radius: 8px;
  background: var(--tgf-panel);
  color: var(--tgf-text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  max-height: 240px;
  overflow: auto;
}

.recipient-suggestions li button {
  display: block;
  width: 100%;
  max-width: none;
  text-align: left;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--tgf-text);
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  font: inherit;
  font-weight: inherit;
}

.recipient-suggestions li button:hover {
  background: var(--tgf-accent-soft-bg);
  color: var(--tgf-accent-soft-text);
}

.message-exception-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.message-exception-row select {
  min-width: 10rem;
}

.match-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.match-tile {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-size: cover;
  background-position: center;
  border: 0;
  box-shadow: var(--tgf-shadow);
}

.match-tile-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.55), rgba(15, 23, 42, 0.35));
}

.match-tile[style*="--match-tile-bg"] {
  background-image: var(--match-tile-bg);
}

.match-tile-content {
  position: relative;
  z-index: 1;
  padding: 1.25rem 1.25rem 0.75rem;
  color: #fff;
}

.match-tile-content h2,
.match-tile-content p,
.match-tile-content .btn-link {
  color: #fff;
}

.match-tile-date,
.match-tile-weather,
.match-tile-venue {
  font-size: 0.92rem;
  opacity: 0.92;
}

.match-tile-title {
  margin: 0.35rem 0;
  font-size: 1.15rem;
  line-height: 1.25;
}

.match-tile-score {
  margin: 0.15rem 0 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.match-tile-goals {
  margin: 0.35rem 0 0;
  padding-left: 1.1rem;
}

.match-score-form {
  margin-top: 0.5rem;
}

.match-score-preview {
  font-size: 1.1rem;
  margin: 0.5rem 0 1rem;
}

.match-goals-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.match-goal-row {
  display: grid;
  grid-template-columns: minmax(7rem, 1fr) minmax(8rem, 1.4fr) 5rem auto;
  gap: 0.5rem;
  align-items: center;
}

.match-goal-row select,
.match-goal-row input {
  max-width: none;
  width: 100%;
}

.match-tile-actions {
  margin-top: 0.75rem;
}

.match-tile-footer {
  position: relative;
  z-index: 1;
  padding: 0.75rem 1.25rem 1rem;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
}

.match-tile--default .match-tile-overlay {
  background: linear-gradient(135deg, rgba(11, 61, 145, 0.85), rgba(15, 23, 42, 0.65));
}
.match-tile--clear .match-tile-overlay {
  background: linear-gradient(135deg, rgba(14, 116, 214, 0.55), rgba(250, 204, 21, 0.35));
}
.match-tile--partly-cloudy .match-tile-overlay {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.55), rgba(148, 163, 184, 0.45));
}
.match-tile--cloudy .match-tile-overlay {
  background: linear-gradient(135deg, rgba(71, 85, 105, 0.7), rgba(100, 116, 139, 0.55));
}
.match-tile--rain .match-tile-overlay {
  background: linear-gradient(135deg, rgba(30, 58, 138, 0.75), rgba(51, 65, 85, 0.65));
}
.match-tile--snow .match-tile-overlay {
  background: linear-gradient(135deg, rgba(148, 163, 184, 0.75), rgba(226, 232, 240, 0.55));
}
.match-tile--fog .match-tile-overlay {
  background: linear-gradient(135deg, rgba(100, 116, 139, 0.75), rgba(203, 213, 225, 0.55));
}
.match-tile--storm .match-tile-overlay {
  background: linear-gradient(135deg, rgba(30, 27, 75, 0.85), rgba(67, 56, 202, 0.55));
}
.match-tile--night .match-tile-overlay {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(30, 41, 59, 0.75));
}

@media (orientation: portrait) {
  .tgf-col-phone,
  .tgf-col-email,
  .tgf-col-status,
  .tgf-col-category,
  .tgf-col-provided,
  .tgf-col-provided-by,
  .tgf-col-priority,
  .tgf-col-system-role {
    display: none !important;
  }

  .content .card:has(table) {
    overflow-x: visible;
    padding-inline: 0;
  }

  .content .card:has(table) > :not(table):not(.doc-folder-contents),
  .content .card:has(table) .doc-folder-contents__title {
    padding-inline: 1rem;
  }

  .content .card:has(table) .doc-folder-contents {
    padding-inline: 0;
  }

  .content .card table,
  .content .doc-folder-contents table {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    table-layout: auto;
  }

  .content .card table th,
  .content .card table td,
  .content .doc-folder-contents table th,
  .content .doc-folder-contents table td {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    word-break: break-word;
    hyphens: auto;
    padding: 0.55rem 0.5rem;
    font-size: 0.88rem;
  }

  .content .card table th,
  .content .doc-folder-contents table th {
    font-size: 0.72rem;
  }

  .content .card table td.actions,
  .content .doc-folder-contents table td.actions {
    container-type: inline-size;
    width: auto;
    min-width: 0;
    max-width: none;
    overflow: visible;
    white-space: normal;
    vertical-align: top;
  }

  .content .card table .actions .btn-link,
  .content .card table .actions button,
  .content .card table .actions .inline-form,
  .content .card table .actions a.btn:not(.tgf-btn-fit-line),
  .content .doc-folder-contents table .actions .btn-link,
  .content .doc-folder-contents table .actions button,
  .content .doc-folder-contents table .actions .inline-form,
  .content .doc-folder-contents table .actions a.btn:not(.tgf-btn-fit-line) {
    display: block;
    width: 100%;
    max-width: none;
    padding: 0.15rem 0;
    text-align: left;
    white-space: normal;
    line-height: 1.25;
  }

  .content .card table td.tgf-cell-fit-name,
  .content .doc-folder-contents table td.tgf-cell-fit-name {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    word-break: normal;
    hyphens: manual;
  }

  .content .card table .actions a.btn.tgf-btn-fit-line,
  .content .doc-folder-contents table .actions a.btn.tgf-btn-fit-line {
    display: block;
    width: 100%;
    max-width: 100%;
    padding: 0.4rem 0.45rem;
    text-align: center;
    white-space: nowrap;
    line-height: 1.15;
    overflow: hidden;
  }

  .content .card table .sort-order-input {
    width: 100%;
    max-width: 4.5rem;
    padding: 0.35rem 0.25rem;
  }
}
