:root {
  --accent: #0b7a75;
  --accent-strong: #095b57;
  --accent-soft: rgba(11, 122, 117, 0.12);
  --danger: #c62828;
  --danger-soft: rgba(198, 40, 40, 0.14);
  --text: #13181d;
  --muted: #59636e;
  --line: rgba(19, 24, 29, 0.12);
  --surface: rgba(255, 255, 255, 0.86);
  --surface-strong: rgba(255, 255, 255, 0.96);
  --shadow: 0 16px 42px rgba(16, 26, 34, 0.16);
  --radius-xl: 22px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 10px;
  --sidebar-width: 304px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  width: 100%;
  margin: 0;
}

body {
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 10%, #cde7e5 0%, transparent 38%),
    radial-gradient(circle at 92% 86%, #d8e4ef 0%, transparent 40%),
    #eef3f6;
  overflow: hidden;
}

#wrapper {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  gap: 14px;
  height: 100%;
  width: 100%;
  padding: 14px;
}

#sidebar {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  backdrop-filter: blur(12px) saturate(130%);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  padding: 14px;
  overflow: hidden;
  transition: width 180ms ease, padding 180ms ease;
}

#sidebar::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.58),
      rgba(255, 255, 255, 0.18)
    );
  pointer-events: none;
}

#sidebar > * {
  position: relative;
  z-index: 1;
}

#sidebar.collapsed {
  width: 86px;
  padding-inline: 10px;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 92px;
  margin-bottom: 8px;
}

#wappen {
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 16px;
  background:
    radial-gradient(circle at 30% 20%, #1ca199, #0b7a75 60%, #075652 100%);
  color: #effaf9;
  font-family: "Sora", "Manrope", sans-serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(11, 122, 117, 0.28);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

#wappen:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 24px rgba(11, 122, 117, 0.34);
}

#wappen:focus-visible {
  outline: 3px solid rgba(11, 122, 117, 0.26);
  outline-offset: 2px;
}

#userData {
  min-width: 0;
}

#userName {
  font-family: "Sora", "Manrope", sans-serif;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.2;
}

#userUnit,
#userRole {
  margin-top: 2px;
  font-size: 0.88rem;
  color: var(--muted);
}

#menu {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 4px;
  overflow: auto;
  padding-right: 2px;
}

#menu ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 11px 12px;
  color: #1f2a34;
  text-decoration: none;
  font-weight: 600;
  transition: background 160ms ease, transform 160ms ease, border-color 160ms ease;
}

#menu a .icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  flex: 0 0 auto;
}

#menu a .label {
  white-space: nowrap;
}

#menu a:hover {
  transform: translateX(2px);
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(19, 24, 29, 0.08);
}

#menu a.active {
  background: linear-gradient(
    90deg,
    rgba(11, 122, 117, 0.2),
    rgba(11, 122, 117, 0.05)
  );
  border-color: rgba(11, 122, 117, 0.3);
  color: var(--accent-strong);
}

#menu a.active::before {
  content: "";
  width: 4px;
  height: 18px;
  border-radius: 999px;
  background: var(--accent);
  margin-right: 2px;
}

#footer {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: grid;
  gap: 8px;
}

.org-chip {
  border: 1px solid rgba(11, 122, 117, 0.28);
  background: rgba(11, 122, 117, 0.09);
  color: #0e5854;
  border-radius: 999px;
  padding: 6px 12px;
  min-height: 34px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.org-chip:hover {
  background: rgba(11, 122, 117, 0.14);
}

#lastUpdate {
  font-size: 0.82rem;
  color: var(--muted);
}

.sidebar-toggle {
  position: absolute;
  top: 50%;
  right: -12px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  color: #29323b;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(16, 26, 34, 0.18);
}

#sidebar.collapsed #userData,
#sidebar.collapsed #footer,
#sidebar.collapsed #menu .label {
  display: none;
}

#sidebar.collapsed .sidebar-head {
  justify-content: center;
}

#sidebar.collapsed #wappen {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  font-size: 0.78rem;
}

#sidebar.collapsed #menu a {
  justify-content: center;
  padding-inline: 8px;
}

#sidebar.collapsed #menu a.active::before {
  display: none;
}

#mainArea {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

#topbar {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  backdrop-filter: blur(12px) saturate(120%);
  box-shadow: var(--shadow);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.section-indicator {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-family: "Sora", "Manrope", sans-serif;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.72);
  white-space: nowrap;
}

.top-user {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.9rem;
  max-width: 260px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

#mobile-nav-toggle {
  display: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.75);
  min-height: 36px;
  padding: 0 11px;
  cursor: pointer;
  font-weight: 700;
}

#content {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  backdrop-filter: blur(12px) saturate(120%);
  box-shadow: var(--shadow);
  padding: 12px;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.app {
  width: 100%;
  height: 100%;
  min-height: 100%;
}

.app-loading,
.app-error {
  min-height: 160px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.66);
}

.app-error {
  color: #6f1f1f;
  border-color: rgba(198, 40, 40, 0.32);
  background: rgba(198, 40, 40, 0.08);
}

.spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(11, 122, 117, 0.2);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  min-height: 38px;
  padding: 0 14px;
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary {
  border-color: transparent;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #eefbfa;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.92);
  color: #25303a;
}

.btn-danger {
  border-color: rgba(198, 40, 40, 0.28);
  background: var(--danger-soft);
  color: #7b1e1e;
}

.employee-add-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), var(--accent-strong));
  color: #f1fbfa;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(11, 122, 117, 0.26);
}

.employee-add-button:hover {
  transform: translateY(-1px);
}

#sidebar-overlay {
  display: none;
}

.dialog-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(18, 25, 32, 0.35);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 170ms ease;
  z-index: 2000;
}

.dialog-modal.active {
  opacity: 1;
  pointer-events: auto;
}

.dialog-panel {
  width: min(500px, 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-strong);
  box-shadow: 0 26px 52px rgba(17, 24, 31, 0.24);
  overflow: hidden;
}

.dialog-header,
.dialog-footer {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dialog-header {
  border-bottom: 1px solid var(--line);
}

.dialog-footer {
  border-top: 1px solid var(--line);
  justify-content: flex-end;
}

.dialog-header h2 {
  margin: 0;
  font-family: "Sora", "Manrope", sans-serif;
  font-size: 1.1rem;
}

.dialog-close {
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.04);
  width: 32px;
  height: 32px;
  cursor: pointer;
}

.dialog-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.dialog-body p {
  margin: 0;
  color: var(--muted);
}

.dialog-body input[type="text"],
.dialog-body input[type="search"] {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  font-family: inherit;
}

.dialog-hint {
  min-height: 20px;
  font-size: 0.84rem;
  color: #7d2323;
}

.user-switcher-panel {
  width: min(680px, 100%);
}

.switcher-list {
  max-height: min(52vh, 420px);
  overflow: auto;
  display: grid;
  gap: 8px;
}

.switcher-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.8);
}

.switcher-item:hover {
  border-color: rgba(11, 122, 117, 0.3);
  background: rgba(11, 122, 117, 0.08);
}

.switcher-item-main {
  min-width: 0;
}

.switcher-item-main h4 {
  margin: 0;
  font-size: 0.97rem;
}

.switcher-item-main p {
  margin: 2px 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.switcher-login-btn {
  white-space: nowrap;
}

.list-empty {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1040px) {
  #wrapper {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }

  #sidebar {
    position: fixed;
    top: 10px;
    left: 10px;
    bottom: 10px;
    width: min(320px, calc(100vw - 40px));
    transform: translateX(-120%);
    transition: transform 180ms ease;
    z-index: 1200;
  }

  body.sidebar-mobile-open #sidebar {
    transform: translateX(0);
  }

  #sidebar.collapsed {
    width: min(320px, calc(100vw - 40px));
    padding-inline: 14px;
  }

  #sidebar.collapsed #userData,
  #sidebar.collapsed #footer,
  #sidebar.collapsed #menu .label {
    display: block;
  }

  #sidebar.collapsed .sidebar-head {
    justify-content: flex-start;
  }

  #sidebar.collapsed #wappen {
    width: 60px;
    height: 60px;
  }

  #sidebar.collapsed #menu a {
    justify-content: flex-start;
  }

  #sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 31, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
    z-index: 1100;
  }

  body.sidebar-mobile-open #sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar-toggle {
    display: none;
  }

  #mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
  }

  #topbar {
    border-radius: 16px;
  }

  #content {
    border-radius: 16px;
  }
}

@media (max-width: 700px) {
  .topbar-right .org-chip {
    display: none;
  }

  .top-user {
    max-width: 170px;
  }

  .section-indicator {
    padding-inline: 11px;
    font-size: 0.9rem;
  }

  #content {
    padding: 10px;
  }
}
