:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --brand-green: #53a650;
  --radius: 10px;
  --font: system-ui, "Segoe UI", Roboto, sans-serif;
  --sidebar-bg: #151c28;
  --nav-active-bg: rgba(88, 166, 255, 0.15);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.ui-frame { display: flex; min-height: 100vh; }
.ui-main-column { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  padding: 1rem 0.65rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  z-index: 40;
  overflow: visible;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: inherit;
  text-decoration: none;
}

.site-brand-mark {
  width: 2.35rem;
  height: 2.35rem;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 0.18rem;
}

.site-brand-archiv { color: var(--brand-green); }
.sidebar-nav { display: flex; flex-direction: column; gap: 1rem; }
.nav-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0.25rem 0.35rem 0.15rem;
}

a.nav-item {
  display: block;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  text-decoration: none;
}

.nav-tip {
  position: relative;
  display: block;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: default;
}
.nav-tip:hover,
.nav-tip:focus-visible { background: var(--nav-active-bg); outline: none; }
.nav-tip p {
  position: absolute;
  left: calc(100% + 0.7rem);
  top: 0;
  z-index: 30;
  width: 18.5rem;
  margin: 0;
  padding: 0.85rem 0.95rem;
  text-align: left;
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--muted);
  background: #1c2128;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
}
.nav-tip:hover p,
.nav-tip:focus-visible p { opacity: 1; visibility: visible; }

a.nav-item:hover,
a.nav-item.active { background: var(--nav-active-bg); }
a.nav-item.active { color: var(--accent); font-weight: 600; }

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 1.25rem;
  background: var(--surface);
  align-items: center;
}

.header-primary-title { margin: 0; font-size: 1.1rem; letter-spacing: -0.02em; }
.app-header-actions { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); font-size: 0.85rem; }

.content { padding: 1.25rem; max-width: 920px; }
body.guest .app-header { display: none; }
body.guest .content { max-width: none; flex: 1; display: flex; }
.hero { margin: auto; text-align: center; max-width: 42rem; }
.hero-logo { width: min(15.5rem, 70vw); height: auto; background: #fff; border-radius: 16px; padding: 1rem 1.15rem 0.85rem; }
.hero-actions { display: flex; gap: 0.65rem; justify-content: center; margin-top: 1.25rem; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.panel + .panel { margin-top: 0.8rem; }
.muted { color: var(--muted); }
button, input, select {
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.45rem 0.7rem;
}
button { background: var(--accent); color: #0d1117; border: none; cursor: pointer; font-weight: 600; }
form.stack, fieldset { display: flex; flex-direction: column; gap: 0.55rem; align-items: stretch; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 0.7rem; margin: 0; }
label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; color: var(--muted); }
table { width: 100%; border-collapse: collapse; margin-top: 0.8rem; }
td, th { border-bottom: 1px solid var(--border); text-align: left; padding: 0.35rem 0.4rem; font-size: 0.9rem; }
ul { padding-left: 1.1rem; }

dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0;
  background: #1c2128;
  color: var(--text);
  max-width: 22rem;
  width: calc(100% - 2rem);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.72); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); font-weight: 600; }
.dlg-close { background: none; border: none; color: var(--muted); font-size: 1.25rem; cursor: pointer; }
.dlg-body { padding: 0 0 1rem; }
.field { margin: 0 1rem 0.85rem; text-align: left; }
.field label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 0.25rem; }
.field input, .dlg-body select { width: 100%; }
.hint, .lp-forgot, .dlg-msg { margin: 0 1rem 0.75rem; font-size: 0.82rem; color: var(--muted); }
.lp-forgot button { color: var(--accent); background: none; border: none; padding: 0; text-decoration: underline; cursor: pointer; }
.btn-row { display: flex; justify-content: flex-end; gap: 0.5rem; margin: 0 1rem; }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.dlg-msg.err { color: #ffa198; }
.dlg-msg.ok { color: #7ee787; }

.sheet-tools { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: end; margin: 0.5rem 0 1rem; }
.sheet-tools label { display: grid; gap: 0.25rem; font-size: 0.78rem; color: var(--muted); }
.sheet-tools select, .sheet-tools input { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 0.4rem 0.5rem; }
.tabs { display: flex; gap: 0.35rem; margin-bottom: 0.75rem; }
.tabs button { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.tabs button.active { color: var(--text); border-color: var(--accent); }
.sheet-wrap { overflow: auto; max-height: 70vh; }
.sheet { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
.sheet th, .sheet td { border-bottom: 1px solid var(--border); padding: 0.35rem 0.5rem; text-align: left; vertical-align: top; white-space: nowrap; }
.sheet th { position: sticky; top: 0; background: #006699; color: #fff; }
.tip { display: inline-block; margin-left: 0.35rem; width: 1rem; height: 1rem; border-radius: 50%; background: var(--accent); color: #0d1117; text-align: center; font-size: 0.7rem; line-height: 1rem; cursor: help; }

@media (max-width: 760px) {
  .ui-frame { flex-direction: column; }
  .sidebar { width: auto; }
}
