:root {
  --portal-bg: #eef0f1;
  --portal-surface: #ffffff;
  --portal-surface-soft: #f7f7f6;
  --portal-text: #272420;
  --portal-muted: #77736e;
  --portal-border: #e2e0dc;
  --portal-gold: #b48348;
  --portal-gold-soft: #e2c99b;
  --portal-gold-pale: #f6eddd;
  --portal-good: #63894d;
  --portal-warn: #b77b2e;
  --portal-danger: #b8554e;
  --portal-shadow: 0 18px 50px rgba(48, 41, 32, .08);
  --portal-radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--portal-bg); }
body.portal-page {
  min-height: 100vh;
  margin: 0;
  color: var(--portal-text);
  background: var(--portal-bg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input { font: inherit; }
button { color: inherit; }
.portal-shell { min-height: 100vh; }
.portal-topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 12px clamp(20px, 4vw, 64px);
  border-bottom: 1px solid rgba(255,255,255,.08);
  color: #fff;
  background: #24201c;
}
.portal-brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: #fff;
  text-decoration: none;
  font-weight: 750;
  letter-spacing: -.02em;
}
.portal-brand__mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #2b241d;
  background: var(--portal-gold-soft);
  font-size: 20px;
  font-weight: 850;
}
.portal-topbar__links {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-left: auto;
}
.portal-link,
.portal-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  text-decoration: none;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, border-color .16s ease;
}
.portal-link:hover, .portal-button:hover { transform: translateY(-1px); }
.portal-link--quiet { color: rgba(255,255,255,.72); background: transparent; }
.portal-link--quiet:hover { color: #fff; background: rgba(255,255,255,.08); }
.portal-topbar button.portal-link--quiet { border-color: rgba(255,255,255,.2); }
.portal-topbar button.portal-link--quiet:disabled { opacity: .55; cursor: wait; transform: none; }
.portal-button { color: #26211c; background: var(--portal-gold-soft); font-weight: 720; }
.portal-button:disabled { opacity: .6; cursor: wait; transform: none; }
.portal-button--secondary { border-color: var(--portal-border); background: #fff; font-weight: 650; }
.portal-button--danger { color: var(--portal-danger); border-color: #ecd5d3; background: #fff; }

.auth-layout {
  min-height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(420px, .92fr);
}
.auth-story {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(56px, 8vw, 120px);
  color: #fff;
  background: linear-gradient(145deg, #2a2520 0%, #4a3727 60%, #7b5634 100%);
}
.auth-story::before,
.auth-story::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.auth-story::before {
  width: 480px;
  height: 480px;
  right: -180px;
  top: -170px;
  border: 80px solid rgba(225, 199, 151, .12);
}
.auth-story::after {
  width: 260px;
  height: 260px;
  left: -130px;
  bottom: -100px;
  background: rgba(225, 199, 151, .09);
}
.auth-story__content { position: relative; z-index: 1; max-width: 680px; }
.portal-eyebrow {
  margin: 0 0 16px;
  color: var(--portal-gold-soft);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.auth-story h1 {
  max-width: 650px;
  margin: 0 0 22px;
  font-size: clamp(42px, 5.5vw, 78px);
  line-height: .98;
  letter-spacing: -.055em;
}
.auth-story__lead {
  max-width: 580px;
  margin: 0;
  color: rgba(255,255,255,.72);
  font-size: clamp(18px, 2vw, 23px);
  line-height: 1.55;
}
.auth-benefits {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 42px;
}
.auth-benefit {
  min-height: 110px;
  padding: 18px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  background: rgba(255,255,255,.055);
  backdrop-filter: blur(8px);
}
.auth-benefit strong { display: block; margin-bottom: 7px; color: #fff; }
.auth-benefit span { color: rgba(255,255,255,.6); font-size: 14px; line-height: 1.4; }
.auth-panel {
  display: grid;
  place-items: center;
  padding: clamp(32px, 6vw, 90px);
  background: #f4f4f2;
}
.auth-card { width: min(470px, 100%); }
.auth-card h2 { margin: 0 0 10px; font-size: clamp(30px, 4vw, 44px); letter-spacing: -.045em; }
.auth-card__intro { margin: 0 0 32px; color: var(--portal-muted); font-size: 17px; line-height: 1.6; }
.auth-form { padding: 28px; border: 1px solid var(--portal-border); border-radius: var(--portal-radius); background: #fff; box-shadow: var(--portal-shadow); }
.portal-field { display: block; }
.portal-field__label { display: block; margin-bottom: 9px; font-size: 14px; font-weight: 750; }
.portal-input {
  width: 100%;
  height: 58px;
  padding: 0 17px;
  border: 1px solid #cbc7c1;
  border-radius: 12px;
  outline: none;
  color: var(--portal-text);
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 22px;
  font-weight: 750;
  letter-spacing: .12em;
}
.portal-input:focus { border-color: var(--portal-gold); box-shadow: 0 0 0 4px rgba(180,131,72,.13); }
.portal-field__hint { display: block; margin-top: 9px; color: var(--portal-muted); font-size: 13px; line-height: 1.5; }
.auth-form .portal-button { width: 100%; margin-top: 20px; border-radius: 12px; }
.auth-message { display: none; margin: 14px 0 0; padding: 12px 14px; border-radius: 10px; font-size: 14px; line-height: 1.5; }
.auth-message.is-visible { display: block; }
.auth-message.is-error { color: #873c37; background: #f9e9e7; }
.auth-message.is-info { color: #685331; background: var(--portal-gold-pale); }
.auth-register { margin-top: 26px; padding: 22px 24px; border-left: 3px solid var(--portal-gold); background: #ececea; }
.auth-register strong { display: block; margin-bottom: 7px; }
.auth-register p { margin: 0 0 13px; color: var(--portal-muted); line-height: 1.5; }
.auth-register a { color: #875d2e; font-weight: 750; }

.cabinet-layout {
  width: min(1680px, calc(100% - 48px));
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 32px;
  margin: 0 auto;
  padding: 36px 0 64px;
}
.cabinet-sidebar { align-self: start; position: sticky; top: 24px; display: grid; gap: 16px; }
.cabinet-profile,
.cabinet-nav,
.cabinet-card {
  border: 1px solid var(--portal-border);
  border-radius: var(--portal-radius);
  background: var(--portal-surface);
}
.cabinet-profile { padding: 28px 22px; text-align: center; }
.cabinet-avatar {
  width: 82px;
  height: 82px;
  display: grid;
  place-items: center;
  margin: 0 auto 15px;
  overflow: hidden;
  border-radius: 50%;
  color: #fff;
  background: #4a4845;
  font-size: 30px;
  font-weight: 800;
}
.cabinet-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cabinet-profile h2 { margin: 0 0 7px; font-size: 20px; }
.cabinet-profile p { margin: 0; color: var(--portal-muted); font-size: 14px; }
.cabinet-nav { padding: 12px; }
.cabinet-nav__title { margin: 17px 14px 8px; color: #a29c94; font-size: 12px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.cabinet-nav button {
  width: 100%;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.cabinet-nav button:hover { background: var(--portal-surface-soft); }
.cabinet-nav button.is-active { background: var(--portal-gold-pale); font-weight: 720; }
.cabinet-nav__icon { width: 27px; color: var(--portal-gold); font-size: 18px; text-align: center; }
.cabinet-main { min-width: 0; }
.cabinet-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin: 4px 0 26px; }
.cabinet-heading h1 { margin: 0 0 8px; font-size: clamp(34px, 4vw, 54px); letter-spacing: -.052em; }
.cabinet-heading p { margin: 0; color: var(--portal-muted); font-size: 17px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 9px 13px; border-radius: 999px; background: #e9f1e4; color: #4d713a; font-size: 13px; font-weight: 750; white-space: nowrap; }
.status-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-pill.is-warning { color: #96621d; background: #f7ead6; }
.status-pill.is-danger { color: #9b433e; background: #f6e3e1; }
.cabinet-alert { display: none; margin-bottom: 24px; padding: 18px 20px; border-left: 4px solid var(--portal-gold); border-radius: 10px; background: #fff; box-shadow: 0 8px 24px rgba(48,41,32,.05); }
.cabinet-alert.is-visible { display: block; }
.cabinet-alert p { margin: 0; color: var(--portal-muted); line-height: 1.55; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 30px; }
.stat-card { min-height: 155px; padding: 24px; border: 1px solid var(--portal-border); border-radius: var(--portal-radius); background: #fff; }
.stat-card__label { color: var(--portal-muted); font-size: 14px; }
.stat-card__value { display: block; margin: 19px 0 5px; font-size: 35px; font-weight: 770; letter-spacing: -.05em; }
.stat-card__meta { color: #aaa49c; font-size: 13px; }
.cabinet-section { margin-top: 30px; }
.cabinet-section__head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.cabinet-section h2 { margin: 0; font-size: 25px; letter-spacing: -.035em; }
.cabinet-section__head a { color: #895e2e; font-weight: 700; text-decoration: none; }
.cabinet-card { padding: 24px; }
.quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.quick-card { min-height: 145px; display: flex; flex-direction: column; padding: 20px; border: 1px solid var(--portal-border); border-radius: 14px; background: var(--portal-surface-soft); text-decoration: none; }
.quick-card:hover { border-color: #cdb48f; background: var(--portal-gold-pale); }
.quick-card__icon { margin-bottom: 22px; color: var(--portal-gold); font-size: 23px; }
.quick-card strong { display: block; margin-bottom: 6px; }
.quick-card span { color: var(--portal-muted); font-size: 13px; line-height: 1.4; }
.device-list { display: grid; gap: 10px; }
.device-row { display: flex; align-items: center; gap: 14px; padding: 15px 16px; border: 1px solid var(--portal-border); border-radius: 12px; }
.device-row__icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--portal-gold-pale); }
.device-row strong { display: block; }
.device-row span { color: var(--portal-muted); font-size: 13px; }
.empty-state { padding: 34px; color: var(--portal-muted); text-align: center; border: 1px dashed #ccc6be; border-radius: 13px; }
.cabinet-panel { display: none; }
.cabinet-panel.is-active { display: block; }
.coming-card { min-height: 340px; display: grid; place-items: center; padding: 40px; text-align: center; }
.coming-card__mark { width: 62px; height: 62px; display: grid; place-items: center; margin: 0 auto 18px; border-radius: 50%; color: #72502d; background: var(--portal-gold-pale); font-size: 25px; }
.coming-card h2 { margin: 0 0 10px; font-size: 30px; }
.coming-card p { max-width: 560px; margin: 0; color: var(--portal-muted); line-height: 1.6; }
.portal-loading { min-height: calc(100vh - 72px); display: grid; place-items: center; color: var(--portal-muted); }

@media (max-width: 1050px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-story { min-height: auto; padding: 64px 34px; }
  .auth-benefits { grid-template-columns: 1fr; }
  .auth-benefit { min-height: 0; }
  .auth-panel { padding: 54px 24px 70px; }
  .cabinet-layout { grid-template-columns: 1fr; }
  .cabinet-sidebar { position: static; grid-template-columns: 260px 1fr; }
  .cabinet-nav { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); align-content: start; }
  .cabinet-nav__title { grid-column: 1/-1; }
}

@media (max-width: 720px) {
  .portal-topbar { min-height: 64px; padding: 10px 16px; }
  .portal-brand span:last-child { display: none; }
  .portal-topbar__links .portal-link--quiet { display: none; }
  .portal-link, .portal-button { min-height: 42px; padding: 0 14px; }
  .auth-story { padding: 48px 22px; }
  .auth-story h1 { font-size: 43px; }
  .auth-benefits { display: none; }
  .auth-panel { padding: 42px 16px 60px; }
  .auth-form { padding: 21px; }
  .cabinet-layout { width: min(100% - 24px, 1680px); padding-top: 18px; }
  .cabinet-sidebar { grid-template-columns: 1fr; }
  .cabinet-profile { display: none; }
  .cabinet-nav { display: flex; overflow-x: auto; gap: 5px; padding: 8px; }
  .cabinet-nav__title { display: none; }
  .cabinet-nav button { width: auto; flex: 0 0 auto; padding: 0 13px; }
  .cabinet-nav__icon { width: auto; }
  .cabinet-heading { align-items: start; flex-direction: column; }
  .stats-grid, .quick-grid { grid-template-columns: 1fr; }
  .stat-card { min-height: 130px; }
}
