:root {
  color-scheme: light dark;
  --bg: #f3f6fb;
  --bg-elevated: #f8fafc;
  --surface: #fdfdff;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #5b6472;
  --border: #dbe2ea;
  --border-strong: #c6d1dc;
  --shadow-soft: 0 18px 42px rgba(15, 23, 42, 0.08);
  --shadow-mid: 0 12px 28px rgba(15, 23, 42, 0.12);
  --shadow-float: 0 22px 54px rgba(15, 23, 42, 0.16);
  --shadow-edge: -18px 0 50px rgba(15, 23, 42, 0.18);
  --glass: linear-gradient(140deg, rgba(255, 255, 255, 0.9), rgba(247, 250, 255, 0.75));
  --glass-border: rgba(255, 255, 255, 0.55);
  --btn: #1d4ed8;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --accent-strong: rgba(37, 99, 235, 0.25);
  --accent-warm: #f97316;
  --accent-warm-soft: rgba(249, 115, 22, 0.18);
  --accent-sky: #06b6d4;
  --accent-sky-soft: rgba(6, 182, 212, 0.18);
  --accent-gold: #f4b740;
  --accent-gold-soft: rgba(244, 183, 64, 0.18);
  --action: #0f766e;
  --action-strong: #0c5f59;
  --action-glow: rgba(15, 118, 110, 0.38);
  --action-ghost: rgba(15, 118, 110, 0.14);
  --overlay: rgba(15, 23, 42, 0.06);
  --overlay-strong: rgba(15, 23, 42, 0.12);
  --accent-glow: rgba(37, 99, 235, 0.45);
  --accent-ghost: rgba(37, 99, 235, 0.06);
  --accent-ghost-strong: rgba(37, 99, 235, 0.14);
  --accent-fade: rgba(37, 99, 235, 0.5);
  --accent-sky-fade: rgba(6, 182, 212, 0.4);
  --accent-warm-fade: rgba(249, 115, 22, 0.45);
  --accent-gold-fade: rgba(244, 183, 64, 0.45);
  --highlight: rgba(255, 255, 255, 0.45);
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 28px;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-elevated: #111c2f;
  --surface: #121c31;
  --card: #18233a;
  --text: #e5e7eb;
  --muted: #9aa4b2;
  --border: #2a3750;
  --border-strong: #33425d;
  --shadow-soft: 0 18px 42px rgba(0, 0, 0, 0.35);
  --shadow-mid: 0 12px 28px rgba(0, 0, 0, 0.45);
  --shadow-float: 0 22px 54px rgba(0, 0, 0, 0.55);
  --shadow-edge: -18px 0 50px rgba(0, 0, 0, 0.6);
  --glass: linear-gradient(140deg, rgba(24, 35, 58, 0.84), rgba(18, 27, 45, 0.7));
  --glass-border: rgba(148, 163, 184, 0.18);
  --btn: #3b82f6;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.16);
  --accent-strong: rgba(96, 165, 250, 0.32);
  --accent-warm: #fb923c;
  --accent-warm-soft: rgba(251, 146, 60, 0.24);
  --accent-sky: #22d3ee;
  --accent-sky-soft: rgba(34, 211, 238, 0.22);
  --accent-gold: #f6c453;
  --accent-gold-soft: rgba(246, 196, 83, 0.26);
  --action: #22c1a8;
  --action-strong: #16a592;
  --action-glow: rgba(34, 193, 168, 0.4);
  --action-ghost: rgba(34, 193, 168, 0.18);
  --overlay: rgba(148, 163, 184, 0.08);
  --overlay-strong: rgba(148, 163, 184, 0.16);
  --accent-glow: rgba(96, 165, 250, 0.45);
  --accent-ghost: rgba(96, 165, 250, 0.08);
  --accent-ghost-strong: rgba(96, 165, 250, 0.18);
  --accent-fade: rgba(96, 165, 250, 0.5);
  --accent-sky-fade: rgba(34, 211, 238, 0.4);
  --accent-warm-fade: rgba(251, 146, 60, 0.45);
  --accent-gold-fade: rgba(246, 196, 83, 0.45);
  --highlight: rgba(255, 255, 255, 0.16);
}

body {
  background:
    repeating-linear-gradient(
      135deg,
      rgba(15, 23, 42, 0.05) 0,
      rgba(15, 23, 42, 0.05) 1px,
      transparent 1px,
      transparent 4px
    ),
    var(--bg);
  color: var(--text);
  font-family: "Sora", "Segoe UI", "Segoe UI Web", "Segoe UI Variable", Arial, sans-serif;
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-with-icon i {
  font-size: 1rem;
  line-height: 0;
}

h1,
h2,
h3 {
  font-family: "Fraunces", "Sora", "Segoe UI", "Segoe UI Web", Arial, sans-serif;
  letter-spacing: -0.01em;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0;
}

.app-shell::before {
  content: "";
  position: fixed;
  inset: -30% 0 auto 0;
  height: 60vh;
  background: none;
  z-index: -1;
  pointer-events: none;
}

[data-theme="dark"] body {
  background:
    repeating-linear-gradient(
      135deg,
      rgba(148, 163, 184, 0.06) 0,
      rgba(148, 163, 184, 0.06) 1px,
      transparent 1px,
      transparent 6px
    ),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-elevated) 100%);
}

[data-theme="dark"] .app-shell::before {
  background: none;
}

.app-drawer,
.app-drawer-right {
  background:
    repeating-linear-gradient(
      135deg,
      rgba(15, 23, 42, 0.04) 0,
      rgba(15, 23, 42, 0.04) 1px,
      transparent 1px,
      transparent 6px
    ),
    var(--card);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  box-shadow: var(--shadow-soft);
}

.app-drawer-right {
  border-right: none;
  border-left: 1px solid var(--border);
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(1400px, 78vw);
  transform: translateX(100%);
  opacity: 0;
  transition: transform 240ms ease, opacity 200ms ease;
  z-index: 30;
  box-shadow: var(--shadow-edge);
  overflow-y: auto;
}

[data-theme="dark"] .app-drawer,
[data-theme="dark"] .app-drawer-right {
  background:
    repeating-linear-gradient(
      135deg,
      rgba(148, 163, 184, 0.06) 0,
      rgba(148, 163, 184, 0.06) 1px,
      transparent 1px,
      transparent 7px
    ),
    var(--card);
}

.app-shell.drawer-right-open .app-drawer-right {
  transform: translateX(0);
  opacity: 1;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay-strong);
  backdrop-filter: blur(6px);
  z-index: 20;
}

.drawer {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: relative;
}

.drawer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
}

.drawer-brand:hover {
  color: inherit;
  text-decoration: none;
}

.drawer-brand-logo {
  display: block;
  height: 28px;
  width: auto;
  object-fit: contain;
}

.drawer-brand-logo-full {
  height: 24px;
  max-width: 160px;
}

.drawer-brand-logo-mark {
  height: 28px;
  width: 28px;
}

.drawer-toggle {
  border: 0;
  background: var(--accent-ghost-strong);
  color: var(--text);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.drawer-toggle-pill {
  position: absolute;
  top: 32px;
  right: -31px;
  padding: 4px;
  width: auto;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  z-index: 2;
}

.drawer-toggle-pill .drawer-text {
  display: none;
}

.drawer-toggle-pill:hover {
  background: var(--accent-ghost);
  color: var(--text);
}

.drawer-nav .nav-link {
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 160ms ease, transform 160ms ease;
}

.drawer-nav .nav-link i {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

.drawer-nav .nav-link.active {
  background: var(--accent-ghost-strong);
  color: var(--text);
}

.drawer-nav .nav-link:hover {
  background: var(--accent-ghost);
  transform: translateY(-1px);
}

.drawer-text {
  white-space: nowrap;
}

.drawer-footer {
  position: fixed;
  left: 14px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.drawer-settings-link {
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  width: 100%;
}

.drawer-settings-link i {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

.drawer-settings-link:hover {
  background: var(--accent-ghost);
  transform: translateY(-1px);
}

.drawer-settings-link.active {
  background: var(--accent-ghost-strong);
  color: var(--text);
}

.drawer-collapsed .drawer-footer {
  left: 14px;
}

.drawer-expanded .drawer-footer {
  left: 20px;
}

.profile-button {
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  width: 100%;
  text-align: left;
  color: var(--text);
}

.profile-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-ghost-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  overflow: hidden;
}

.profile-icon i {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}

.profile-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.profile-menu {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: absolute;
  bottom: 48px;
  left: 8px;
  width: 200px;
  box-shadow: var(--shadow-mid);
  backdrop-filter: blur(8px);
}

.profile-menu a,
.profile-menu button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  display: block;
  width: 100%;
}

.profile-menu a:hover,
.profile-menu button:hover {
  background: var(--accent-ghost-strong);
}

.drawer-collapsed {
  width: 76px;
  transition: width 160ms ease;
}

.drawer-expanded {
  width: 260px;
  transition: width 200ms ease;
}

.drawer-collapsed .drawer-text,
.drawer-collapsed .drawer-brand-text,
.drawer-collapsed .profile-name {
  display: none;
}

.drawer-collapsed .drawer-brand {
  justify-content: center;
}

.drawer-collapsed .drawer-brand-logo {
  height: 32px;
  width: 32px;
}

.drawer-expanded .drawer-brand {
  justify-content: center;
}

.drawer-collapsed .drawer-toggle,
.drawer-collapsed .drawer-nav .nav-link,
.drawer-collapsed .profile-button,
.drawer-collapsed .drawer-settings-link {
  justify-content: center;
}

.drawer-collapsed .drawer-toggle {
  padding: 4px;
}

.drawer-collapsed .drawer-nav .nav-link {
  padding: 12px 8px;
}

.drawer-collapsed .profile-button {
  padding: 6px 8px;
}

.drawer-collapsed .drawer-settings-link {
  padding: 12px 8px;
}

.drawer-collapsed .profile-menu {
  left: 62px;
}

.app-main {
  padding: 28px 32px;
}

.app-topbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 12px;
}

.app-topbar-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.app-topbar-spacer {
  flex: 1;
}

.app-lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  box-shadow: var(--shadow-soft);
}

.app-lang-link {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

.app-lang-link.active {
  color: var(--text);
  font-weight: 700;
}

.app-lang-link:hover {
  color: var(--text);
}

.app-lang-divider {
  color: var(--border-strong);
}

.theme-toggle {
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--text);
  padding: 6px 12px 6px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-soft);
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-mid);
  border-color: var(--border-strong);
}

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

.theme-toggle-icon {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--accent-ghost-strong);
  display: grid;
  place-items: center;
  color: var(--accent);
  font-size: 14px;
}

.theme-toggle-text {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.app-toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-float);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: min(460px, 90vw);
  z-index: 60;
  animation: toastIn 180ms ease;
}

.app-toast--info {
  border-color: var(--accent-strong);
  box-shadow: 0 16px 38px rgba(37, 99, 235, 0.18);
}

.app-toast--warning {
  border-color: var(--accent-gold);
  box-shadow: 0 16px 38px rgba(244, 183, 64, 0.2);
}

.app-toast--critical {
  border-color: var(--accent-warm);
  box-shadow: 0 18px 44px rgba(249, 115, 22, 0.22);
}

.app-toast-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text);
  font-size: 14px;
}

.app-toast-body span {
  color: var(--muted);
  font-size: 13px;
}

.toast-undo {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
}

.toast-undo:hover {
  background: var(--accent-ghost);
  border-color: var(--border-strong);
}

.app-toast--critical .toast-undo {
  border-color: rgba(249, 115, 22, 0.4);
  background: rgba(249, 115, 22, 0.08);
}

[data-theme="dark"] .app-toast--critical .toast-undo {
  border-color: rgba(251, 146, 60, 0.5);
  background: rgba(251, 146, 60, 0.12);
}

@keyframes toastIn {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 600px) {
  .app-toast {
    left: 16px;
    right: 16px;
    bottom: 16px;
    flex-direction: column;
    align-items: flex-start;
  }
}

.theme-toggle .icon-moon {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
  display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
  display: inline-flex;
}

.content {
  padding-top: 0;
}

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: auto 1fr;
  }
}

@media (max-width: 768px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .app-drawer {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .drawer-footer {
    position: static;
  }

  .app-drawer-right {
    width: 100vw;
  }
}

@media (max-width: 1200px) {
  .app-drawer-right {
    width: 92vw;
  }
}

.app-drawer,
.app-drawer-right {
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

.drawer-toggle,
.drawer-nav .nav-link,
.profile-button,
.profile-menu {
  border-radius: var(--radius-sm);
}

.profile-icon {
  border-radius: var(--radius-lg);
}
