:root {
  --bg: #111116;
  --surface: #19191d;
  --surface-2: #222226;
  --surface-3: #2c2c31;
  --ink: #f4f2f8;
  --muted: #a19da8;
  --line: rgba(255, 255, 255, 0.08);
  --purple: #7116ed;
  --purple-2: #8f3cff;
  --green: #58c96b;
  --red: #ff525d;
  --yellow: #ffc327;
  --cyan: #27b7c7;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 50% -10%, rgba(113, 22, 237, 0.18), transparent 34%), var(--bg);
  color: var(--ink);
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", Arial, sans-serif;
  padding-bottom: 108px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.import-label {
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--purple), var(--purple-2));
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(113, 22, 237, 0.28);
}

button.ghost {
  background: var(--surface-3);
  color: var(--ink);
  box-shadow: none;
}

button.danger {
  background: rgba(255, 82, 93, 0.14);
  color: var(--red);
  box-shadow: none;
}

.import-label input {
  display: none;
}

.topbar {
  align-items: center;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  padding: max(18px, env(safe-area-inset-top)) 20px 10px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(17, 17, 22, 0.9);
  backdrop-filter: blur(18px);
}

.avatar-wrap {
  position: relative;
}

.avatar-mark {
  align-items: center;
  background: linear-gradient(135deg, #dfe4ff, #56b6e8);
  border-radius: 50%;
  color: #14314f;
  display: inline-flex;
  font-weight: 900;
  height: 48px;
  justify-content: center;
  width: 48px;
}

.crown-dot {
  align-items: center;
  background: var(--yellow);
  border-radius: 50%;
  color: #6b3c00;
  display: inline-flex;
  font-size: 11px;
  height: 19px;
  justify-content: center;
  position: absolute;
  right: -5px;
  top: -4px;
  width: 19px;
}

.topbar-center {
  min-width: 0;
  text-align: center;
}

.topbar h1 {
  color: var(--muted);
  font-size: clamp(22px, 5vw, 28px);
  line-height: 1.1;
  margin: 0;
}

.topbar-center p {
  color: #77737d;
  font-size: 12px;
  margin: 4px 0 0;
}

.topbar-actions {
  align-items: center;
  display: flex;
  gap: 8px;
}

.topbar-actions > button:not(#logoutBtn),
.topbar-actions .import-label {
  display: none;
}

.user-badge {
  display: none;
}

#logoutBtn {
  min-height: 38px;
  padding: 0 12px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.layout {
  margin: 0 auto;
  max-width: 1100px;
  padding: 12px 18px 32px;
}

.app-screen {
  display: none;
}

.app-screen.active {
  display: block;
}

.panel,
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

.settings-panel {
  margin-top: 8px;
}

.section-title {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-title h2 {
  color: var(--muted);
  font-size: 22px;
  margin: 0;
}

.section-title p {
  color: var(--muted);
  margin: 0;
  text-align: right;
}

.summary-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 8px 0 20px;
}

.metric {
  min-height: 148px;
  padding: 18px;
}

.metric:first-child {
  align-items: center;
  display: grid;
  grid-column: 1 / -1;
  justify-items: center;
  min-height: 260px;
  position: relative;
  text-align: center;
}

.metric:first-child::after {
  color: var(--muted);
  content: "◎";
  font-size: 32px;
}

.metric span,
.metric small {
  color: var(--muted);
  display: block;
}

.metric strong {
  color: var(--ink);
  display: block;
  font-size: clamp(24px, 7vw, 58px);
  letter-spacing: 0.01em;
  margin: 12px 0 8px;
}

.metric:not(:first-child) strong {
  font-size: clamp(22px, 4vw, 28px);
}

.metric.positive strong {
  color: var(--green);
}

.metric.warning strong,
.metric:nth-child(2) strong {
  color: var(--red);
}

.quick-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 0 20px;
}

.quick-actions button {
  background: var(--surface-2);
  border-radius: 22px;
  box-shadow: none;
  color: var(--ink);
  min-height: 58px;
}

.quick-actions button:first-child,
.quick-actions button:nth-child(2) {
  background: linear-gradient(135deg, var(--purple), var(--purple-2));
}

.tab-bar {
  background: var(--surface-2);
  border-radius: 999px;
  display: flex;
  gap: 6px;
  margin: 4px 0 18px;
  overflow-x: auto;
  padding: 6px;
  scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar {
  display: none;
}

.tab-bar button {
  background: transparent;
  box-shadow: none;
  color: var(--muted);
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0 18px;
  white-space: nowrap;
}

.tab-bar button.active {
  background: #f4f2f8;
  color: var(--purple);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.dashboard {
  display: grid;
  gap: 18px;
  grid-template-columns: 1.1fr 0.9fr;
  margin-bottom: 18px;
}

.bar-chart {
  display: grid;
  gap: 16px;
}

.bar-row {
  display: grid;
  gap: 8px;
}

.bar-row > div:first-child,
.mini-table div {
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.bar-row span,
.mini-table span {
  color: var(--muted);
}

.bar-track {
  background: var(--surface-3);
  border-radius: 999px;
  height: 12px;
  overflow: hidden;
}

.bar-track span {
  background: linear-gradient(90deg, var(--purple), var(--cyan));
  display: block;
  height: 100%;
}

.mini-table {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
}

.grid-form,
.stack-form {
  display: grid;
  gap: 12px;
}

.grid-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-row {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 800;
  gap: 7px;
}

input,
select,
textarea {
  background: #101014;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  min-height: 46px;
  padding: 10px 12px;
  width: 100%;
}

textarea {
  resize: vertical;
}

.checkbox {
  align-items: center;
  color: var(--ink);
  font-weight: 500;
  grid-template-columns: 18px 1fr;
}

.checkbox input {
  min-height: auto;
}

.timeline {
  display: grid;
  gap: 10px;
}

.timeline-item {
  align-items: center;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 14px;
  grid-template-columns: 110px 1fr auto;
  padding: 14px 0;
}

.timeline-item:first-child {
  border-top: 0;
}

.timeline-item strong {
  color: var(--ink);
}

.timeline-item > strong:first-child {
  color: var(--muted);
}

.timeline-item p {
  color: var(--muted);
  margin: 4px 0 0;
}

.workspace.wide {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
  margin-top: 18px;
}

.list {
  display: grid;
  gap: 0;
  margin-top: 16px;
}

.list-item {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 16px 0;
}

.list-item strong {
  display: block;
  margin-bottom: 5px;
}

.list-item p,
.empty {
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
}

.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.item-actions button {
  box-shadow: none;
  min-height: 34px;
  padding: 0 11px;
}

.auth-view {
  display: grid;
  min-height: calc(100vh - 92px);
  padding: 24px;
  place-items: center;
}

.auth-panel {
  max-width: 430px;
  width: 100%;
}

.auth-panel h2 {
  font-size: 30px;
  margin: 0 0 8px;
}

.auth-panel p,
.message {
  color: var(--muted);
  line-height: 1.45;
}

.message {
  color: var(--red);
  font-weight: 800;
  min-height: 22px;
}

.bottom-nav {
  align-items: center;
  background: rgba(25, 25, 29, 0.96);
  border-top: 1px solid var(--line);
  bottom: 0;
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(5, 1fr);
  left: 0;
  padding: 10px 14px max(10px, env(safe-area-inset-bottom));
  position: fixed;
  right: 0;
  z-index: 30;
}

.bottom-nav button {
  background: transparent;
  border-radius: 28px;
  box-shadow: none;
  color: var(--ink);
  display: grid;
  font-size: 12px;
  gap: 3px;
  min-height: 62px;
  padding: 6px;
}

.bottom-nav button.active {
  background: var(--surface-3);
  color: var(--purple-2);
}

.bottom-nav button span {
  font-size: 24px;
  line-height: 1;
}

.bottom-nav .fab-nav {
  align-self: start;
  background: linear-gradient(135deg, var(--purple), var(--purple-2));
  border-radius: 50%;
  box-shadow: 0 18px 36px rgba(113, 22, 237, 0.45);
  height: 72px;
  margin-top: -30px;
  min-height: 72px;
  width: 72px;
}

.bottom-nav .fab-nav span {
  font-size: 46px;
  font-weight: 300;
}

.menu-panel {
  margin-top: 8px;
}

.menu-list {
  display: grid;
}

.menu-list button,
.menu-import {
  align-items: center;
  background: transparent;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
  color: var(--ink);
  display: flex;
  font-size: 20px;
  font-weight: 700;
  justify-content: flex-start;
  min-height: 70px;
  padding: 0 8px;
}

.menu-list button::before,
.menu-import::before {
  color: var(--muted);
  content: "▣";
  display: inline-block;
  font-size: 22px;
  margin-right: 16px;
  width: 24px;
}

.menu-import input {
  display: none;
}

@media (max-width: 980px) {
  .grid-form,
  .dashboard,
  .workspace.wide {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  body {
    padding-bottom: 96px;
  }

  .layout {
    padding: 10px 18px 26px;
  }

  .topbar-actions #logoutBtn {
    font-size: 0;
    min-width: 42px;
    padding: 0;
  }

  .topbar-actions #logoutBtn::before {
    content: "⚙";
    font-size: 20px;
  }

  .summary-grid,
  .quick-actions,
  .form-row,
  .timeline-item {
    grid-template-columns: 1fr;
  }

  .metric {
    min-height: 138px;
  }

  .metric:first-child {
    min-height: 250px;
  }

  .panel,
  .metric {
    border-radius: 26px;
  }

  .list-item,
  .section-title {
    align-items: start;
    display: grid;
  }

  .section-title p {
    text-align: left;
  }
}
