:root {
  --primary-color: #4f7cff;
  --primary-hover: #111111;
  --sidebar-width: 320px;
  --surface-dark: #ededed;
  --surface-dark-2: #e2e2e2;
  --border-color: rgba(17, 17, 17, 0.08);
  --text-main: #111111;
  --text-muted: #6b7280;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255,255,255,0.8), transparent 24%),
    linear-gradient(180deg, var(--surface-dark) 0%, var(--surface-dark-2) 100%);
  color: var(--text-main);
}

a { color: #1d4ed8; }

h1, h2, p { margin-top: 0; }

h1, h2 {
  color: var(--text-main);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.lede, .muted { color: var(--text-muted); max-width: 100%; }

.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: #fff;
  padding: 8px 12px;
  z-index: 20;
}

.skip:focus { top: 12px; }

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-main);
  text-decoration: none;
  font-weight: 800;
  font-size: 1.22rem;
  min-width: 0;
}

.brand i,
.brand-link i {
  font-size: 1.8rem;
  min-width: 36px;
  text-align: center;
  color: var(--primary-color);
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }

.brand-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-subtitle {
  font-size: 0.72rem;
  font-weight: 800;
  color: #9aa4b4;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar {
  width: var(--sidebar-width);
  position: fixed;
  top: 18px;
  left: 18px;
  bottom: 18px;
  background: linear-gradient(180deg, #fbfbfb 0%, #f0f0f0 100%);
  border: 1px solid rgba(17,17,17,0.05);
  border-radius: 28px;
  padding: 20px 18px;
  z-index: 1050;
  overflow: auto;
  box-shadow: 0 10px 28px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
}

.sidebar-header { margin-bottom: 18px; }

.sidebar-section-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.menu-group {
  border-radius: 22px;
  background: rgba(255,255,255,0.42);
  border: 1px solid rgba(17,17,17,0.04);
  padding: 8px;
}

.menu-group.is-current {
  background: linear-gradient(180deg, rgba(255,255,255,0.92) 0%, rgba(245,248,255,0.92) 100%);
}

.menu-group-main {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-main);
  padding: 12px 14px;
  border-radius: 16px;
  text-decoration: none;
  font-weight: 700;
}

.menu-group-main i {
  font-size: 1.2rem;
  min-width: 28px;
  text-align: center;
}

.menu-group-main:hover { background: rgba(79, 124, 255, 0.08); color: var(--text-main); }

.menu-group-main.is-active {
  background: linear-gradient(180deg, var(--primary-color) 0%, #3b67ee 100%);
  color: #ffffff;
  box-shadow: 0 10px 20px rgba(79,124,255,0.24);
}

.menu-group-main.is-active i { color: #ffffff; }

.menu-group-main.is-waiting {
  color: #94a3b8;
  cursor: default;
}

.menu-group-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(17,17,17,0.08);
}

.logout-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  color: #334155;
  padding: 9px 12px;
  border-radius: 14px;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  text-align: left;
}

.logout-link:hover { background: rgba(79, 124, 255, 0.08); }

.main-content {
  margin-left: calc(var(--sidebar-width) + 36px);
  padding: 18px 18px 28px 0;
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 12px;
  margin-bottom: 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.97) 0%, rgba(248,249,251,0.96) 100%);
  border: 1px solid rgba(17,17,17,0.06);
  box-shadow: 0 4px 14px rgba(0,0,0,0.05);
}

.topbar-title {
  font-size: 0.95rem;
  min-width: 0;
}

.topbar-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 8px 3px 3px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  max-width: 220px;
}

.topbar-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #4f7cff 0%, #3b67ee 100%);
  color: #fff;
  font-weight: 800;
  font-size: 0.68rem;
}

.topbar-user-name {
  display: block;
  font-weight: 800;
  font-size: 0.78rem;
  color: #0f172a;
}

.topbar-user-role {
  display: block;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #94a3b8;
}

.topbar-user-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

.page-stage {
  min-height: calc(100vh - 110px);
  background: linear-gradient(180deg, rgba(246,246,246,0.88) 0%, rgba(237,237,237,0.82) 100%);
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 30px;
  padding: 22px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.08);
}

.card,
.lede,
p,
h1,
h2,
.main-content,
.page-stage {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.card {
  border: 1px solid rgba(17,17,17,0.05);
  border-radius: 24px;
  background: linear-gradient(180deg, #fbfbfb 0%, #f1f1f1 100%);
  box-shadow: 0 10px 24px rgba(0,0,0,0.08);
  padding: 22px;
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 6px;
}

input[type="email"],
input[type="password"],
input[type="text"],
input[type="date"],
select,
textarea {
  width: 100%;
  border: 1px solid rgba(17, 17, 17, 0.12);
  background: #fff;
  border-radius: 16px;
  padding: 12px 14px;
  min-height: 48px;
  font: inherit;
  margin-bottom: 14px;
}

input:focus, select:focus, textarea:focus {
  outline: 3px solid rgba(79, 124, 255, 0.25);
  border-color: var(--primary-color);
}

button, .button {
  appearance: none;
  border: 1px solid #345ce0;
  background: linear-gradient(180deg, var(--primary-color) 0%, #345ce0 100%);
  color: white;
  border-radius: 14px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button:hover, .button:hover {
  background: #111111;
  border-color: #111111;
  color: #ffffff;
}

button.secondary, .button.secondary {
  background: transparent;
  color: var(--text-main);
  border: 1px solid rgba(17, 17, 17, 0.16);
}

.actions, .links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-start;
  max-width: 100%;
}

.links a, .actions a {
  overflow-wrap: anywhere;
}

.note, .error, .errorlist {
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 14px;
}

.note { background: #eef3ff; color: #1d4ed8; }
.error, .errorlist { background: #fdecec; color: #8d2f2f; list-style: none; }

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.pill {
  display: inline-block;
  background: rgba(79, 124, 255, 0.12);
  color: #1d4ed8;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 700;
}

.identity, .topbar-user-meta { min-width: 0; }

.doc-list, .day-list { list-style: none; padding: 0; margin: 0; }
.doc h2, .day h2 { font-size: 1.15rem; }
.summary { font-size: 1.35rem; font-weight: 800; color: #1d4ed8; }
.preview iframe, .preview img { width: 100%; min-height: 70vh; border: 0; background: white; border-radius: 16px; }

.auth-wrap {
  width: min(560px, calc(100% - 28px));
  margin: 28px auto 48px;
}

.auth-brand { margin-bottom: 18px; }

.mobile-header, .overlay { display: none; }

.mobile-header {
  background: rgba(248,248,248,0.96);
  padding: 6px 10px;
  min-height: 44px;
  border-bottom: 1px solid rgba(17,17,17,0.08);
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1040;
}

.brand-link {
  color: var(--text-main);
  text-decoration: none;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.menu-button {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid rgba(17,17,17,0.08);
  background: #ffffff;
  color: var(--text-main);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1045;
}

.overlay.show { display: block; }

@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .sidebar {
    transform: translateX(-110%);
    top: 8px;
    left: 8px;
    bottom: 8px;
    width: min(88vw, var(--sidebar-width));
  }
  .sidebar.show { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 8px 8px 32px; }
  .app-topbar { flex-direction: column; align-items: stretch; border-radius: 14px; }
  .page-stage { border-radius: 18px; padding: 14px; }
  .topbar-user { max-width: none; }
  .links, .actions { flex-direction: column; align-items: flex-start; }
}

@media (min-width: 800px) {
  .grid { grid-template-columns: 1fr 1fr; }
  .grid .wide { grid-column: 1 / -1; }
}
