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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #F5F5F3;
  color: #1a1a1a;
  min-height: 100vh;
}

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #E0E0DC;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 10;
  transition: width 0.2s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 10px 10px 12px;
  border-bottom: 1px solid #E0E0DC;
  min-height: 57px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  font-size: 15px;
  font-weight: 700;
  color: #1a1a1a;
  text-decoration: none;
  border-radius: 7px;
}
.sidebar-brand:hover { background: #F5F5F3; }

.sidebar-toggle {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #888;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.sidebar-toggle:hover { background: #F5F5F3; color: #333; }
.brand-mark {
  display: none;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #1a1a1a;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sidebar-nav { padding: 10px 10px; flex: 1; }
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.7px;
  text-transform: uppercase;
  color: #bbb;
  padding: 14px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  transition: background 0.1s;
  text-decoration: none;
}
.nav-item:hover { background: #F5F5F3; color: #1a1a1a; }
.nav-item.active { background: #F0F0EC; color: #1a1a1a; font-weight: 500; }
.nav-icon { width: 18px; display: flex; align-items: center; justify-content: center; }
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 600;
  background: #E8E8E4;
  color: #666;
  padding: 2px 6px;
  border-radius: 10px;
}
.nav-badge.alert { background: #FDECEA; color: #c0392b; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid #E0E0DC;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sign-out-collapsed {
  display: none;
  width: 100%;
  align-items: center;
  justify-content: center;
  padding: 7px 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #555;
  cursor: pointer;
}
.sign-out-collapsed:hover { background: #F5F5F3; color: #1a1a1a; }
.user-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.user-row:hover { background: #F5F5F3; }
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #E0E0DC;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #666;
  flex-shrink: 0;
}
.user-name { font-size: 13px; font-weight: 500; color: #333; }
.user-role { font-size: 11px; color: #aaa; }

.user-menu { position: relative; }
.user-menu .user-row {
  width: 100%;
  border: none;
  background: transparent;
  text-align: left;
  font: inherit;
}
.user-dropdown {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 6px);
  background: #fff;
  border: 1px solid #E0E0DC;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  padding: 6px;
  z-index: 20;
}
.user-menu.open .user-dropdown { display: block; }
.user-dropdown-header { padding: 8px 10px 6px; }
.user-dropdown-name { font-size: 13px; font-weight: 600; color: #1a1a1a; }
.user-dropdown-email { font-size: 11px; color: #888; margin-top: 2px; word-break: break-all; }
.user-dropdown-divider { height: 1px; background: #E0E0DC; margin: 4px 0; }
.user-dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  border: none;
  background: transparent;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
  text-align: left;
}
.user-dropdown-item:hover { background: #F5F5F3; }
.user-dropdown-item:disabled { opacity: 0.6; cursor: not-allowed; }

.content { margin-left: 220px; flex: 1; min-width: 0; transition: margin-left 0.2s ease; }

/* ── Collapsed sidebar (icon-only) ── */
.layout.sidebar-collapsed .sidebar {
  width: 52px;
  overflow: hidden;
}
.layout.sidebar-collapsed .content { margin-left: 52px; }
.layout.sidebar-collapsed .sidebar-header {
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
}
.layout.sidebar-collapsed .sidebar-brand {
  justify-content: center;
  padding: 8px 0;
  width: 100%;
  flex: none;
  overflow: hidden;
}
.layout.sidebar-collapsed .brand-text { display: none; }
.layout.sidebar-collapsed .brand-mark { display: flex; }
.layout.sidebar-collapsed .sidebar-toggle { margin: 0; }
.layout.sidebar-collapsed .sidebar-nav { padding: 10px 6px; }
.layout.sidebar-collapsed .nav-section-label { display: none; }
.layout.sidebar-collapsed .nav-label,
.layout.sidebar-collapsed .nav-badge,
.layout.sidebar-collapsed .user-info,
.layout.sidebar-collapsed .user-name,
.layout.sidebar-collapsed .user-role,
.layout.sidebar-collapsed .user-dropdown-header,
.layout.sidebar-collapsed .user-dropdown-divider,
.layout.sidebar-collapsed .sign-out-text { display: none; }
.layout.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 8px 0;
  gap: 0;
}
.layout.sidebar-collapsed .nav-icon { width: auto; }
.layout.sidebar-collapsed .sidebar-footer {
  padding: 12px 6px;
  align-items: center;
}
.layout.sidebar-collapsed .user-menu { width: 100%; }
.layout.sidebar-collapsed .user-row {
  justify-content: center;
  padding: 7px 0;
  width: 100%;
  pointer-events: none;
}
.layout.sidebar-collapsed .user-row .avatar { pointer-events: auto; }
.layout.sidebar-collapsed .user-menu .user-dropdown,
.layout.sidebar-collapsed .user-menu.open .user-dropdown { display: none; }
.layout.sidebar-collapsed .sign-out-collapsed { display: inline-flex; }

.topbar {
  background: #fff;
  border-bottom: 1px solid #E0E0DC;
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 5;
}
.page-title { font-size: 16px; font-weight: 600; color: #1a1a1a; }
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-right { display: flex; gap: 8px; align-items: center; }
.breadcrumb { font-size: 13px; color: #aaa; display: flex; align-items: center; gap: 6px; }
.breadcrumb a { color: #aaa; text-decoration: none; }
.breadcrumb a:hover { color: #555; }
.breadcrumb span { color: #333; font-weight: 500; }

.page-body { padding: 2rem; }

.layout.doc-preview-layout .page-body { padding: 0; }

.btn-ghost {
  border: 1px solid #D0D0CC;
  background: transparent;
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 7px;
  cursor: pointer;
  color: #555;
  display: inline-flex; align-items: center; gap: 5px;
  text-decoration: none;
}
.btn-ghost:hover { background: #f0f0ec; }
.btn-primary {
  background: #1a1a1a;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 16px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none;
}
.btn-primary:hover { background: #333; }
.btn-secondary {
  background: #fff;
  color: #555;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 7px;
  border: 1px solid #D0D0CC;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-secondary:hover { background: #f5f5f3; }

/* Shared empty state panel */
.empty-state-panel {
  text-align: center;
  padding: 3.5rem 2rem;
  background: #fff;
  border: 1px dashed #D0D0CC;
  border-radius: 10px;
  color: #666;
}
.empty-state-panel.compact {
  padding: 2.5rem 1.5rem;
  border-style: solid;
  border-color: #E0E0DC;
}
.empty-state-illustration {
  width: 72px;
  height: 72px;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
  background: #E3F2FD;
  color: #1976D2;
  display: flex;
  align-items: center;
  justify-content: center;
}
.empty-state-panel .empty-state-illustration .icon-xl {
  width: 32px;
  height: 32px;
}
.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 8px;
}
.empty-state-body {
  font-size: 13px;
  color: #888;
  max-width: 360px;
  margin: 0 auto 1.25rem;
  line-height: 1.5;
}
.empty-state-panel .btn-primary,
.empty-state-panel .btn-upload-doc {
  margin-top: 0.25rem;
}

/* Mobile sidebar drawer */
.mobile-topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 1rem;
  background: #fff;
  border-bottom: 1px solid #E0E0DC;
  position: sticky;
  top: 0;
  z-index: 6;
}
.hamburger-btn {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #555;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.hamburger-btn:hover { background: #F5F5F3; }
.mobile-brand { font-size: 14px; font-weight: 600; color: #1a1a1a; }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 9;
}

@media (max-width: 767px) {
  .mobile-topbar { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 40;
  }
  .layout.sidebar-mobile-open .sidebar {
    transform: translateX(0);
  }
  .content { margin-left: 0 !important; }
  .layout.sidebar-collapsed .content { margin-left: 0 !important; }
  .sidebar-toggle { display: none; }
  .topbar { padding: 0 1rem; }
  .page-body { padding: 1rem; }
}

