:root {
  --bg: #050505;
  --surface: #0b0b0b;
  --surface-2: #111111;
  --surface-3: #171717;
  --line: rgba(255,255,255,.10);
  --line-strong: rgba(255,255,255,.18);
  --text: #f2f2f2;
  --muted: #8e8e8e;
  --muted-2: #666;
  --accent: #d9d9d9;
  --danger: #a85d56;
  --shadow: 0 14px 34px rgba(0,0,0,.28);
  --sidebar-w: 248px;
  --radius: 4px;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: #000;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(0,0,0,.12) 0%, rgba(0,0,0,.28) 48%, rgba(0,0,0,.78) 100%),
    url("../eft.png") center top / cover fixed no-repeat,
    #050505;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(0,0,0,.52) 0, rgba(0,0,0,.18) 28%, rgba(0,0,0,.04) 58%, rgba(0,0,0,.24) 100%);
}

body.high-contrast {
  --text: #fff;
  --muted: #aaa;
  --line: rgba(255,255,255,.16);
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: .022;
  background-image:
    url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.6'/%3E%3C/svg%3E");
}

.sidebar,
.main {
  position: relative;
  z-index: 2;
}

/* ---------- Sidebar ---------- */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  padding: 24px 16px 18px;
  display: flex;
  flex-direction: column;
  background: rgba(5,5,5,.92);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 22px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  color: #eee;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .08em;
}

.brand strong {
  display: block;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 17px;
  line-height: 1;
  letter-spacing: .08em;
}

.brand small {
  display: block;
  margin-top: 5px;
  color: var(--muted-2);
  font-size: 8px;
  letter-spacing: .18em;
}

nav {
  display: grid;
  gap: 2px;
  margin-top: 18px;
}

.nav-item {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 11px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #8b8b8b;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  transition: color .15s ease, background .15s ease, border-color .15s ease;
}

.nav-item:hover {
  color: #ddd;
  background: rgba(255,255,255,.025);
}

.nav-item.active {
  color: #fff;
  background: rgba(255,255,255,.045);
  border-left-color: #d5d5d5;
}

.nav-glyph {
  width: 22px !important;
  color: #5e5e5e !important;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
  letter-spacing: .04em;
}

.nav-item.active .nav-glyph { color: #bcbcbc !important; }

.sidebar-bottom {
  margin-top: auto;
  display: grid;
  gap: 7px;
  padding-top: 20px;
}

.sync-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 11px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.sync-card strong {
  display: block;
  font-size: 10px;
  font-weight: 600;
}

.sync-card small {
  display: block;
  margin-top: 2px;
  color: var(--muted-2);
  font-size: 8px;
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #888;
}

.sync-dot.online { background: #d0d0d0; }
.sync-dot.offline { background: #875b56; }

.ghost-btn,
.danger-link {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(255,255,255,.015);
  color: #777;
  text-align: center;
  font-size: 9px;
}

.ghost-btn:hover {
  color: #ccc;
  border-color: var(--line-strong);
  background: rgba(255,255,255,.025);
}

.file-btn input { display: none; }

.danger-link {
  border: 0;
  background: transparent;
  color: #75514e;
}

.danger-link:hover { color: #a66b66; }

/* ---------- Main ---------- */

.main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  padding: 30px 34px 64px;
  max-width: 1680px;
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: #777;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1, h2, h3 {
  margin: 0;
  font-family: "Barlow Condensed", sans-serif;
  color: #f3f3f3;
  font-weight: 600;
}

h1 {
  font-size: 31px;
  line-height: 1;
  letter-spacing: .02em;
}

h2 {
  font-size: 29px;
  line-height: 1.05;
}

h3 {
  font-size: 18px;
  letter-spacing: .015em;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.search-wrap {
  width: min(380px, 36vw);
  height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(7,7,7,.76);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.search-wrap > span {
  color: #666;
  font-size: 15px;
}

.search-wrap input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ddd;
  font-size: 11px;
  outline: 0;
}

.search-wrap input::placeholder { color: #5f5f5f; }

kbd {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: #666;
  background: #0a0a0a;
  font-size: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(7,7,7,.76);
  color: #777;
  font-size: 10px;
  font-weight: 700;
}

.icon-btn:hover {
  color: #ddd;
  border-color: var(--line-strong);
}

/* ---------- Pages / panels ---------- */

.page { display: none; }

.page.active {
  display: block;
  animation: page-in .16s ease;
}

@keyframes page-in {
  from { opacity: .55; }
  to { opacity: 1; }
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(9,9,9,.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}

.hero {
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 27px 29px;
  background:
    linear-gradient(90deg, rgba(15,15,15,.79), rgba(6,6,6,.72));
}

.hero p:not(.eyebrow) {
  max-width: 650px;
  margin: 10px 0 0;
  color: #8d8d8d;
  font-size: 12px;
  line-height: 1.65;
}

.hero-ring {
  position: relative;
  width: 116px;
  height: 116px;
  display: grid;
  place-items: center;
  margin-right: 8px;
}

.hero-ring svg {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}

.hero-ring circle {
  fill: none;
  stroke-width: 5;
}

.ring-bg { stroke: rgba(255,255,255,.07); }

.ring-value {
  stroke: #d1d1d1;
  stroke-linecap: butt;
  stroke-dasharray: 314;
  stroke-dashoffset: 314;
  transition: .3s ease;
}

.hero-ring div { text-align: center; }

.hero-ring strong {
  display: block;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 24px;
  font-weight: 600;
}

.hero-ring span {
  color: #686868;
  font-size: 7px;
  letter-spacing: .12em;
}

/* ---------- Stats ---------- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin: 9px 0;
}

.stat-card {
  min-height: 92px;
  display: grid;
  grid-template-columns: 31px 1fr;
  align-items: center;
  gap: 11px;
  padding: 15px;
  box-shadow: none;
}

.stat-icon {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: #aaa;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 13px;
  font-weight: 600;
}

.stat-card small {
  color: #666;
  font-size: 8px;
  letter-spacing: .12em;
}

.stat-card strong {
  display: block;
  margin-top: 3px;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 18px;
  font-weight: 600;
}

.mini-progress {
  grid-column: 1 / -1;
  height: 2px;
  overflow: hidden;
  background: rgba(255,255,255,.055);
}

.mini-progress i {
  display: block;
  width: 0;
  height: 100%;
  background: #aaa;
  transition: width .25s ease;
}

/* ---------- Dashboard ---------- */

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.22fr .78fr;
  gap: 9px;
}

.panel-head {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 17px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.012);
}

.text-btn {
  border: 0;
  background: transparent;
  color: #777;
  font-size: 9px;
}

.text-btn:hover { color: #ccc; }

.compact-list {
  padding: 4px 14px 10px;
}

.compact-row {
  min-height: 51px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 4px;
  border-bottom: 1px solid rgba(255,255,255,.055);
}

.compact-row:last-child { border-bottom: 0; }

.compact-row strong {
  font-size: 11px;
  font-weight: 600;
}

.compact-row small {
  display: block;
  margin-top: 3px;
  color: #666;
  font-size: 8px;
}

.tag {
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: #777;
  background: transparent;
  font-size: 7px;
  letter-spacing: .08em;
}

/* ---------- Forms ---------- */

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px;
  padding: 17px;
}

label {
  color: #707070;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: .04em;
}

input,
select {
  width: 100%;
  margin-top: 6px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #090909;
  color: #ddd;
  outline: 0;
  font-size: 10px;
}

input:focus,
select:focus {
  border-color: rgba(255,255,255,.28);
  box-shadow: none;
}

/* ---------- Toolbar ---------- */

.toolbar {
  min-height: 51px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
  padding: 8px 10px;
  box-shadow: none;
}

.filter-group {
  display: flex;
  gap: 6px;
}

.filter-group select {
  min-width: 142px;
  margin: 0;
  padding: 7px 9px;
  font-size: 9px;
}

.toolbar-meta {
  color: #666;
  font-size: 9px;
}

.toolbar-meta strong { color: #aaa; }

/* ---------- Quests ---------- */

.cards-list {
  display: grid;
  gap: 5px;
}

.quest-card {
  display: grid;
  grid-template-columns: 35px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 62px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(8,8,8,.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: border-color .12s ease, background .12s ease;
}

.quest-card:hover {
  border-color: rgba(255,255,255,.18);
  background: rgba(12,12,12,.91);
}

.quest-card.done { opacity: .46; }

.check {
  width: 23px;
  height: 23px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,.23);
  border-radius: 2px;
  background: transparent;
  color: transparent;
  font-size: 11px;
}

.done .check,
.check.checked {
  border-color: #d2d2d2;
  background: #d2d2d2;
  color: #080808;
}

.quest-title {
  font-family: "Barlow Condensed", sans-serif;
  font-size: 16px;
  font-weight: 600;
}

.quest-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 3px;
  color: #646464;
  font-size: 8px;
}

.quest-actions {
  display: flex;
  gap: 5px;
}

.small-btn {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: transparent;
  color: #707070;
  font-size: 8px;
}

.small-btn:hover {
  border-color: rgba(255,255,255,.22);
  color: #bbb;
}

/* ---------- Item cards ---------- */

.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(225px, 1fr));
  gap: 6px;
}

.item-card {
  position: relative;
  min-height: 118px;
  padding: 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(8,8,8,.86);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: border-color .12s ease, background .12s ease;
}

.item-card:hover {
  border-color: rgba(255,255,255,.18);
  background: rgba(12,12,12,.91);
}

.item-card.done { opacity: .48; }

.item-check {
  position: absolute;
  top: 10px;
  right: 10px;
}

.item-card h4 {
  margin: 0 32px 5px 0;
  font-family: "Barlow Condensed", sans-serif;
  font-size: 16px;
  font-weight: 600;
}

.item-card p {
  min-height: 27px;
  margin: 0;
  color: #666;
  font-size: 8px;
  line-height: 1.55;
}

.item-type {
  display: inline-block;
  margin-top: 10px;
  color: #8d8d8d;
  font-size: 7px;
  font-weight: 600;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.item-art {
  position: absolute;
  right: -24px;
  bottom: -28px;
  width: 82px;
  height: 82px;
  border: 1px solid rgba(255,255,255,.035);
  transform: rotate(8deg);
  background: transparent;
}

/* ---------- Allergies ---------- */

.allergy-layout {
  display: grid;
  grid-template-columns: 1fr 285px;
  gap: 9px;
}

.muted {
  margin: 0;
  padding: 15px 17px 0;
  color: #777;
  font-size: 10px;
  line-height: 1.6;
}

.add-row {
  display: grid;
  grid-template-columns: 1fr 120px auto;
  gap: 6px;
  padding: 12px 17px 17px;
}

.add-row input,
.add-row select { margin: 0; }

.primary-btn {
  padding: 0 13px;
  border: 1px solid #ccc;
  border-radius: 2px;
  background: #d0d0d0;
  color: #080808;
  font-size: 9px;
  font-weight: 700;
}

.primary-btn:hover { background: #eee; }

.allergy-list {
  display: grid;
  gap: 5px;
  padding: 0 17px 17px;
}

.allergy-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(255,255,255,.012);
}

.severity {
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: #888;
  font-size: 7px;
  text-transform: uppercase;
}

.severity.high { color: #a96b66; }
.severity.medium { color: #999; }
.severity.low { color: #777; }

.warning-panel {
  position: relative;
  min-height: 240px;
  padding: 19px;
}

.warning-panel p:not(.eyebrow) {
  color: #6f6f6f;
  font-size: 10px;
  line-height: 1.6;
}

.warning-icon {
  position: absolute;
  right: 20px;
  bottom: 13px;
  color: rgba(255,255,255,.035);
  font-family: "Barlow Condensed", sans-serif;
  font-size: 76px;
  font-weight: 700;
}

/* ---------- Modal / toast ---------- */

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 60;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(8,8,8,.95);
  color: #c6c6c6;
  font-size: 9px;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: .15s ease;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0,0,0,.78);
  backdrop-filter: blur(4px);
}

.modal-backdrop.hidden { display: none; }

.modal {
  position: relative;
  width: min(700px, 100%);
  max-height: 80vh;
  overflow: auto;
  padding: 22px;
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  color: #777;
  font-size: 22px;
}

.objectives {
  display: grid;
  gap: 6px;
  margin-top: 17px;
}

.objective {
  padding: 9px 10px;
  border-left: 1px solid #aaa;
  background: rgba(255,255,255,.02);
  color: #aaa;
  font-size: 10px;
}

.empty {
  padding: 32px;
  border: 1px dashed var(--line);
  border-radius: 2px;
  background: rgba(0,0,0,.15);
  color: #666;
  text-align: center;
  font-size: 9px;
}

/* ---------- Scrollbar ---------- */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track { background: #070707; }

::-webkit-scrollbar-thumb {
  background: #333;
  border: 2px solid #070707;
}

::-webkit-scrollbar-thumb:hover { background: #494949; }

/* ---------- Responsive ---------- */

@media (max-width: 1050px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .allergy-layout { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  body {
    background-attachment: scroll;
    background-position: center top;
  }

  .sidebar {
    position: static;
    width: auto;
    padding: 12px;
  }

  .brand { padding-bottom: 12px; }

  nav {
    display: flex;
    gap: 3px;
    overflow-x: auto;
    margin-top: 10px;
  }

  .nav-item {
    width: auto;
    min-width: max-content;
    padding: 0 10px;
    border-left: 0;
    border-bottom: 2px solid transparent;
  }

  .nav-item.active { border-bottom-color: #ccc; }

  .sidebar-bottom { display: none; }

  .main {
    margin-left: 0;
    padding: 17px;
  }

  .topbar {
    flex-direction: column;
    gap: 12px;
  }

  .top-actions { width: 100%; }

  .search-wrap {
    width: auto;
    flex: 1;
  }

  .stats-grid { grid-template-columns: 1fr; }
  .hero { padding: 20px; }
  .hero-ring { display: none; }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .filter-group {
    width: 100%;
    flex-wrap: wrap;
  }

  .filter-group select { flex: 1; }

  .quest-card {
    grid-template-columns: 30px 1fr;
  }

  .quest-actions { grid-column: 2; }

  .profile-grid,
  .add-row {
    grid-template-columns: 1fr;
  }
}
