:root {
  --ink: #18312c;
  --muted: #6d7d78;
  --line: #e1e9e5;
  --bg: #f4f8f6;
  --card: #ffffff;
  --green: #087f5b;
  --green-dark: #075f47;
  --mint: #dff6ec;
  --orange: #f2a93b;
  --orange-soft: #fff3dc;
  --red: #dc5555;
  --blue: #4079d8;
  --shadow: 0 12px 36px rgba(25, 68, 54, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body:not(.is-authenticated) #app-shell {
  display: none !important;
}

body.is-authenticated #login-screen {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 5%, rgba(244, 193, 85, 0.18), transparent 24rem),
    var(--bg);
  font-family: "Noto Sans TC", sans-serif;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  grid-template-columns: minmax(360px, 0.85fr) minmax(480px, 1.15fr);
  background: white;
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: min(100%, 520px);
  padding: 56px clamp(32px, 7vw, 88px);
  justify-self: center;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 64px;
}

.login-logo {
  display: grid;
  width: 50px;
  height: 50px;
  padding: 3px;
  place-items: center;
  border: 1px solid #e7e1f2;
  border-radius: 16px;
  box-shadow: 0 9px 24px rgba(103, 78, 161, 0.14);
}

.login-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-brand strong,
.login-brand small {
  display: block;
}

.login-brand strong {
  font-size: 20px;
  letter-spacing: 0.06em;
}

.login-brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.login-copy h1 {
  margin: 7px 0 10px;
  font-size: clamp(32px, 4vw, 46px);
  letter-spacing: -0.04em;
}

.login-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
}

.login-form {
  display: grid;
  gap: 16px;
  margin-top: 34px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: #40564f;
  font-size: 12px;
  font-weight: 800;
}

.login-form input {
  width: 100%;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  background: #fbfdfc;
}

.login-form input:focus {
  border-color: #85bca8;
  box-shadow: 0 0 0 4px var(--mint);
}

.login-error {
  min-height: 18px;
  margin: -5px 0 -3px;
  color: var(--red);
  font-size: 11px;
  font-weight: 700;
}

.test-accounts {
  margin-top: 22px;
  color: var(--muted);
  font-size: 11px;
}

.test-accounts summary {
  cursor: pointer;
  font-weight: 700;
  text-align: center;
}

.test-accounts > div {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.test-accounts button {
  padding: 10px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfdfc;
  text-align: left;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.test-accounts button:hover {
  border-color: #9bcbb9;
  background: var(--mint);
}

.test-accounts small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.login-visual {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 78% 22%, rgba(242, 169, 59, 0.3), transparent 18rem),
    linear-gradient(145deg, #064e3b, #087f5b 56%, #14a676);
}

.login-visual::before {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.16) 1px, transparent 1px);
  background-size: 24px 24px;
  content: "";
  mask-image: linear-gradient(to bottom right, transparent, black);
}

.visual-orbit {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
}

.orbit-one {
  top: 12%;
  right: -12%;
  width: 620px;
  height: 620px;
}

.orbit-two {
  right: 18%;
  bottom: -20%;
  width: 440px;
  height: 440px;
}

.visual-card {
  position: absolute;
  z-index: 1;
  padding: 24px;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 70px rgba(1, 42, 30, 0.2);
  backdrop-filter: blur(14px);
}

.visual-card span,
.visual-card strong,
.visual-card small {
  display: block;
}

.visual-card span {
  color: #c9f1e3;
  font-size: 11px;
  font-weight: 800;
}

.visual-card strong {
  margin-top: 8px;
  font-size: clamp(28px, 4vw, 50px);
}

.visual-card small {
  margin-top: 10px;
  color: #d4eae2;
}

.visual-card-main {
  top: 30%;
  left: 14%;
  width: min(64%, 520px);
}

.visual-card-small {
  right: 9%;
  bottom: 19%;
  width: min(42%, 300px);
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 78px;
  padding: 0 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(18px);
}

.brand,
.profile-button,
.role-switch {
  display: flex;
  align-items: center;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.brand {
  gap: 12px;
  padding: 0;
  text-align: left;
}

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  padding: 3px;
  place-items: center;
  overflow: hidden;
  border: 1px solid #e4e0f2;
  border-radius: 15px;
  background: white;
  box-shadow: 0 8px 20px rgba(103, 78, 161, 0.16);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand strong,
.brand small,
.profile-button strong,
.profile-button small {
  display: block;
}

.brand strong {
  font-size: 18px;
  letter-spacing: 0.04em;
}

.brand small,
.profile-button small {
  color: var(--muted);
  font-size: 11px;
}

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

.market-status {
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.market-status i {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: #22bb79;
  box-shadow: 0 0 0 4px #dff6ec;
}

.icon-button {
  position: relative;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  cursor: pointer;
}

.icon-button b {
  position: absolute;
  top: -5px;
  right: -5px;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  color: white;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--red);
  font-size: 9px;
}

.logout-text-button {
  padding: 9px 14px;
  color: #8a4a4a;
  border: 1px solid #ead5d5;
  border-radius: 10px;
  background: #fffafa;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.logout-text-button:hover {
  color: white;
  border-color: #a95656;
  background: #a95656;
}

.profile-button {
  gap: 10px;
  padding: 5px 7px;
  text-align: left;
  cursor: default;
}

.avatar {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: var(--green-dark);
  border-radius: 13px;
  background: var(--mint);
  font-weight: 800;
}

.layout {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 78px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 78px);
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

nav {
  display: grid;
  gap: 7px;
}

.nav-button {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: #526660;
  border: 0;
  border-radius: 12px;
  background: transparent;
  text-align: left;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.nav-button:hover,
.nav-button.active {
  color: var(--green-dark);
  background: var(--mint);
}

.nav-button .nav-icon {
  width: 23px;
  font-size: 17px;
  text-align: center;
}

.sidebar-card {
  margin-top: auto;
  padding: 16px;
  border: 1px solid #f1dfb6;
  border-radius: 16px;
  background: var(--orange-soft);
}

.sidebar-card strong {
  margin-left: 4px;
  font-size: 13px;
}

.sidebar-card p {
  margin: 8px 0 0;
  color: #806838;
  font-size: 11px;
  line-height: 1.7;
}

.role-switch {
  gap: 10px;
  width: 100%;
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed #bbcbc5;
  border-radius: 12px;
  text-align: left;
}

.role-switch strong,
.role-switch small {
  display: block;
  font-size: 11px;
}

.role-switch small {
  color: var(--muted);
}

.main-content {
  width: 100%;
  max-width: 1440px;
  min-height: calc(100vh - 78px);
  margin: 0 auto;
  padding: 34px 38px 60px;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.page-heading h1 {
  margin: 4px 0 6px;
  font-size: clamp(26px, 3vw, 38px);
  line-height: 1.2;
}

.page-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.eyebrow {
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.primary-button,
.secondary-button,
.small-button {
  border: 0;
  border-radius: 11px;
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  padding: 12px 18px;
  color: white;
  background: var(--green);
  box-shadow: 0 8px 18px rgba(8, 127, 91, 0.16);
}

.primary-button:hover {
  background: var(--green-dark);
}

.secondary-button {
  padding: 11px 16px;
  color: var(--green-dark);
  border: 1px solid #b8d8cc;
  background: white;
}

.small-button {
  padding: 8px 12px;
  color: var(--green-dark);
  background: var(--mint);
  font-size: 12px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 20px;
}

.card {
  min-width: 0;
  padding: 22px;
  border: 1px solid rgba(218, 230, 225, 0.9);
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.hero-card {
  position: relative;
  grid-column: span 8;
  min-height: 235px;
  overflow: hidden;
  color: white;
  border: 0;
  background:
    linear-gradient(105deg, rgba(3, 95, 67, 0.96), rgba(16, 139, 100, 0.91)),
    radial-gradient(circle, white 1px, transparent 1px);
}

.hero-card::after {
  position: absolute;
  right: -30px;
  bottom: -110px;
  width: 330px;
  height: 330px;
  content: "";
  border: 55px solid rgba(255, 255, 255, 0.07);
  border-radius: 50%;
}

.hero-card p {
  margin: 8px 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.hero-total {
  margin: 18px 0 2px;
  font-size: clamp(34px, 5vw, 52px);
  font-weight: 900;
  letter-spacing: -0.04em;
}

.hero-total small {
  margin-left: 6px;
  font-size: 16px;
}

.gain-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 12px;
  font-weight: 700;
}

.hero-profit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.hero-profit-percent {
  display: inline-flex;
  align-items: center;
  padding: 8px 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.hero-profit-percent.up {
  color: #b42318;
}

.hero-profit-percent.down {
  color: #087f5b;
}

.hero-stats {
  position: absolute;
  z-index: 1;
  right: 30px;
  bottom: 30px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.hero-stat {
  min-width: 120px;
  padding: 13px 15px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(6px);
}

.hero-stat span,
.hero-stat strong {
  display: block;
}

.hero-stat span {
  color: rgba(255, 255, 255, 0.68);
  font-size: 10px;
}

.hero-stat strong {
  margin-top: 3px;
  font-size: 17px;
}

.mission-card {
  grid-column: span 4;
  background: linear-gradient(150deg, #fff, #fff9ed);
}

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

.card-title h2 {
  margin: 0;
  font-size: 17px;
}

.card-title a {
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.mission-icon {
  display: grid;
  width: 54px;
  height: 54px;
  margin: 6px 0 16px;
  place-items: center;
  border-radius: 17px;
  background: var(--orange-soft);
  font-size: 26px;
}

.mission-card h3 {
  margin: 0 0 7px;
  font-size: 16px;
}

.mission-card p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 20px;
  background: #edf1ef;
}

.progress i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--orange);
}

.progress-label {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
}

.market-card {
  grid-column: span 8;
}

.ranking-card {
  grid-column: span 4;
}

.stock-list,
.ranking-list,
.activity-list {
  display: grid;
  gap: 7px;
}

.stock-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 90px 90px 80px;
  align-items: center;
  gap: 12px;
  padding: 11px 10px;
  border-radius: 12px;
}

.stock-row.with-quantity {
  grid-template-columns: minmax(140px, 1fr) 90px 90px 72px 70px;
}

.market-quantity {
  width: 100%;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  text-align: center;
  outline: 0;
}

.market-quantity:focus {
  border-color: #8dc4b0;
  box-shadow: 0 0 0 3px var(--mint);
}

.stock-row:hover {
  background: #f7faf8;
}

.stock-name {
  display: flex;
  align-items: center;
  gap: 11px;
}

button.stock-name {
  width: fit-content;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

button.stock-name:hover strong {
  color: var(--green);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.stock-logo {
  display: grid;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  place-items: center;
  color: white;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 900;
}

.stock-name strong,
.stock-name small {
  display: block;
}

.stock-name strong {
  font-size: 13px;
}

.stock-name small {
  color: var(--muted);
  font-size: 10px;
}

.stock-price {
  font-size: 14px;
  font-weight: 800;
  text-align: right;
}

.change {
  font-size: 12px;
  font-weight: 800;
  text-align: right;
}

.up {
  color: var(--red);
}

.down {
  color: var(--green);
}

.ranking-row {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 10px 6px;
  border-bottom: 1px solid #edf1ef;
}

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

.rank {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
}

.rank.top {
  color: var(--orange);
  font-size: 18px;
}

.ranking-person {
  display: flex;
  align-items: center;
  gap: 9px;
}

.mini-avatar {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 10px;
  background: #e7f2ee;
  font-size: 11px;
  font-weight: 800;
}

.ranking-person strong,
.ranking-person small {
  display: block;
}

.ranking-person strong {
  font-size: 12px;
}

.ranking-person small {
  color: var(--muted);
  font-size: 9px;
}

.rank-value {
  font-size: 12px;
  font-weight: 800;
}

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

.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stat-icon {
  display: grid;
  width: 45px;
  height: 45px;
  place-items: center;
  border-radius: 14px;
  background: var(--mint);
  font-size: 20px;
}

.stat-card span,
.stat-card strong {
  display: block;
}

.stat-card span {
  color: var(--muted);
  font-size: 11px;
}

.stat-card strong {
  margin-top: 3px;
  font-size: 20px;
}

.table-card {
  overflow-x: auto;
}

.school-ranking-layout {
  display: grid;
  gap: 18px;
}

.ranking-table-card {
  padding: 24px;
}

.ranking-table-card .card-title {
  margin-bottom: 14px;
}

.ranking-table-card table {
  min-width: 680px;
}

.ranking-table-card th:first-child,
.ranking-table-card td:first-child {
  width: 64px;
  text-align: center;
}

.ranking-table-card td:first-child strong {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 12px;
  background: var(--mint);
  color: var(--green-dark);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

td {
  font-size: 13px;
}

tr:last-child td {
  border-bottom: 0;
}

.student-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.student-number {
  display: inline-flex;
  min-width: 54px;
  justify-content: center;
  border-radius: 999px;
  background: #e7f2ee;
  color: var(--green);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  padding: 8px 10px;
  white-space: nowrap;
}

.table-actions {
  display: flex;
  gap: 6px;
}

.points-button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 9px;
  background: var(--mint);
  color: var(--green);
  font-weight: 900;
  cursor: pointer;
}

.points-button.minus {
  color: var(--red);
  background: #fff0f0;
}

.permission-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 150px;
  padding: 7px 9px;
  color: var(--red);
  border: 1px solid #f0d1d1;
  border-radius: 12px;
  background: #fff7f7;
  text-align: left;
  cursor: pointer;
}

.permission-toggle.active {
  color: var(--green-dark);
  border-color: #b8d8cc;
  background: #f3fbf7;
}

.permission-toggle strong,
.permission-toggle small {
  display: block;
}

.permission-toggle strong {
  font-size: 11px;
}

.permission-toggle small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.toggle-track {
  position: relative;
  width: 38px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 30px;
  background: #d9dfdc;
  transition: 0.2s ease;
}

.toggle-track i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 5px rgba(20, 46, 38, 0.2);
  transition: 0.2s ease;
}

.permission-toggle.active .toggle-track {
  background: var(--green);
}

.permission-toggle.active .toggle-track i {
  transform: translateX(16px);
}

.toolbar {
  display: flex;
  gap: 10px;
}

.search-input {
  min-width: 230px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  background: white;
}

.search-input:focus {
  border-color: #8dc4b0;
  box-shadow: 0 0 0 3px var(--mint);
}

.market-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  color: #526660;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: white;
  font-weight: 800;
  cursor: pointer;
}

.filter-chip small {
  color: var(--muted);
}

.filter-chip.active {
  color: var(--green-dark);
  border-color: #9dcebc;
  background: var(--mint);
}

.market-info-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0 14px;
}

.market-info-panel div {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid #d9eee7;
  border-radius: 16px;
  background: linear-gradient(135deg, #f4fbf8, #ffffff);
}

.market-info-panel span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.market-info-panel strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.market-result-meta {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.market-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
}

.market-pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.dividend-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #786019;
  background: #fff8dd;
  font-size: 11px;
}

.dividend-preview > div {
  min-width: 0;
}

.dividend-preview > div:last-child {
  text-align: right;
}

.dividend-preview strong,
.dividend-preview small {
  display: block;
}

.dividend-preview small {
  margin-top: 4px;
  color: #8c742e;
  font-size: 10px;
}

.dividend-grid {
  align-items: start;
}

.dividend-page {
  display: grid;
  gap: 18px;
}

.dividend-section-card {
  overflow: hidden;
}

.dividend-table {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.dividend-table-head,
.dividend-record {
  display: grid;
  grid-template-columns: minmax(180px, 1.3fr) minmax(120px, 0.9fr) minmax(95px, 0.7fr) minmax(110px, 0.8fr) minmax(150px, 1fr);
  align-items: center;
  gap: 14px;
}

.dividend-table-head {
  padding: 0 14px 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.dividend-record {
  padding: 15px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdfc;
  font-size: 13px;
}

.dividend-record strong,
.dividend-record small {
  display: block;
}

.dividend-record small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.dividend-stock-cell strong {
  font-size: 15px;
}

.dividend-amount {
  text-align: right;
}

.dividend-amount strong {
  font-size: 16px;
}

.mobile-label {
  display: none;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.holding-card {
  padding: 20px;
}

.holding-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.holding-value {
  margin: 20px 0 4px;
  font-size: 25px;
  font-weight: 900;
}

.holding-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 60px 20px;
  text-align: center;
}

.empty-state span {
  font-size: 42px;
}

.empty-state h2 {
  margin: 12px 0 6px;
}

.empty-state p {
  color: var(--muted);
}

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

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

.activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 5px var(--mint);
}

.activity-row div:nth-child(2) {
  flex: 1;
}

.activity-row strong,
.activity-row small {
  display: block;
}

.activity-row strong {
  font-size: 12px;
}

.activity-row small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.activity-points {
  font-size: 12px;
  font-weight: 800;
}

.api-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 24px;
  margin-top: 20px;
  color: white;
  border: 0;
  background: #183f35;
}

.api-card p {
  max-width: 730px;
  margin: 7px 0 0;
  color: #bcd0ca;
  font-size: 12px;
  line-height: 1.7;
}

.api-status {
  display: flex;
  gap: 8px;
}

.api-status span {
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9px;
  color: #cce1da;
  font-size: 10px;
}

.reward-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.reward-grid .empty-state {
  grid-column: 1 / -1;
}

.reward-card {
  display: grid;
  grid-template-rows: 220px 1fr;
  gap: 14px;
  overflow: hidden;
  min-height: 430px;
}

.reward-image,
.image-preview,
.redeem-summary-image {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  overflow: hidden;
  border-radius: 16px;
  background: linear-gradient(135deg, #e6f6ef, #fff5cf);
  color: var(--green-dark);
  font-weight: 900;
}

.reward-image {
  font-size: 44px;
  aspect-ratio: auto;
  height: 220px;
  min-height: 0;
}

.natural-image,
.redeem-summary-image {
  height: 180px;
}

.reward-image img,
.image-preview img,
.redeem-summary-image img {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
  padding: 10px;
  transform: none !important;
}

.image-fit-hint {
  align-self: end;
  padding: 0 10px 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.clickable-image {
  cursor: zoom-in;
}

.reward-category-bar {
  flex-wrap: wrap;
}

.static-chip {
  cursor: default;
  pointer-events: none;
}

.reward-upload-preview {
  height: min(360px, 52vh);
  min-height: 220px;
  border: 2px dashed rgba(0, 105, 77, 0.22);
}

.reward-body {
  display: grid;
  grid-template-rows: auto auto minmax(44px, 1fr) auto;
  gap: 8px;
  min-height: 0;
}

.reward-body h2,
.redeem-summary h3 {
  margin: 0;
  font-size: 20px;
}

.reward-body h2 {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.reward-body p,
.redeem-summary p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.reward-body p {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.reward-body > strong {
  align-self: end;
  font-size: 22px;
}

.reward-body .full-button {
  align-self: end;
}

.reward-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-self: end;
}

.reward-card.is-inactive {
  opacity: 0.72;
}

.reward-card.is-inactive .reward-image {
  filter: grayscale(0.35);
}

.secondary-button.danger-action {
  color: var(--red);
  border-color: rgba(220, 85, 85, 0.35);
  background: #fff7f7;
}

.reward-record-card,
.reward-history-card {
  margin-top: 18px;
}

.image-preview {
  width: min(100%, 360px);
  height: 220px;
  max-width: 360px;
  margin-top: 14px;
  border: 1px dashed #acd6c7;
  color: var(--muted);
  font-size: 12px;
}

.image-preview img {
  height: calc(100% - 34px);
}

.redeem-summary {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
}

.redeem-summary-image {
  width: 96px;
  height: 96px;
  font-size: 32px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--mint);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.sent {
  color: #5b4a12;
  background: #fff0b8;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.modal {
  width: min(440px, calc(100% - 32px));
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(12, 47, 37, 0.25);
  overflow: hidden;
}

.modal::backdrop {
  background: rgba(13, 42, 34, 0.55);
  backdrop-filter: blur(4px);
}

.image-viewer-dialog {
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 28px);
  padding: 48px 14px 14px;
  border: 0;
  border-radius: 18px;
  background: white;
  box-shadow: 0 30px 80px rgba(12, 47, 37, 0.25);
}

.image-viewer-dialog::backdrop {
  background: rgba(13, 42, 34, 0.72);
  backdrop-filter: blur(4px);
}

.image-viewer-dialog img {
  display: block;
  width: auto;
  max-width: calc(100vw - 56px);
  height: auto;
  max-height: calc(100vh - 96px);
  object-fit: contain;
  border-radius: 12px;
}

.stock-detail-dialog {
  width: min(980px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 22px;
  box-shadow: 0 24px 80px rgba(22, 48, 39, 0.24);
}

.stock-detail-dialog::backdrop {
  background: rgba(20, 42, 34, 0.52);
  backdrop-filter: blur(4px);
}

.stock-detail-content {
  padding: 28px;
}

.stock-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-right: 34px;
}

.stock-detail-header h2 {
  margin: 4px 0 5px;
  font-size: 25px;
}

.stock-detail-price {
  text-align: right;
}

.stock-detail-price strong {
  display: block;
  font-size: 28px;
}

.stock-detail-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0;
}

.stock-detail-stat {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfdfc;
}

.stock-detail-stat span,
.stock-detail-stat strong {
  display: block;
}

.stock-detail-stat span {
  color: var(--muted);
  font-size: 10px;
}

.stock-detail-stat strong {
  margin-top: 5px;
  font-size: 13px;
}

.stock-chart-panel {
  padding: 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
}

.stock-chart-panel svg {
  display: block;
  width: 100%;
  min-width: 680px;
  height: auto;
}

.stock-chart-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 11px;
}

.stock-chart-legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 4px;
  border-radius: 2px;
}

.stock-detail-note {
  margin: 12px 2px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.stock-news-section {
  margin-top: 22px;
}

.stock-news-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.stock-news-heading h3 {
  margin: 3px 0 0;
  font-size: 18px;
}

.stock-news-heading a {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.stock-news-list {
  display: grid;
  gap: 8px;
}

.stock-news-item {
  display: block;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: inherit;
  text-decoration: none;
  transition: border-color .2s ease, background .2s ease;
}

.stock-news-item:hover {
  border-color: #9bcbb9;
  background: #f7fbf9;
}

.stock-news-item strong,
.stock-news-item span {
  display: block;
}

.stock-news-item strong {
  font-size: 13px;
  line-height: 1.55;
}

.stock-news-item span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
}

.stock-detail-loading {
  display: grid;
  min-height: 320px;
  place-items: center;
  color: var(--muted);
}

.modal form {
  position: relative;
  display: grid;
  gap: 16px;
  padding: 30px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-sizing: border-box;
}

.school-modal {
  width: min(720px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
}

.school-modal form {
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.form-section {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdfc;
}

.form-section h3 {
  margin: 0 0 14px;
  font-size: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.class-management-grid {
  display: grid;
  gap: 18px;
}

.class-card {
  overflow-x: auto;
}

.compact-table {
  width: 100%;
  border-collapse: collapse;
}

.compact-table th,
.compact-table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}

.small-button.danger {
  color: var(--red);
  border-color: rgba(220, 85, 85, 0.35);
  background: #fff7f7;
}

.small-button.danger:disabled {
  color: var(--muted);
  border-color: var(--line);
  background: #f7faf8;
  cursor: not-allowed;
}

.class-transfer-control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 180px;
}

.class-transfer-control select {
  min-width: 100px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
}

.wide-field {
  grid-column: 1 / -1;
}

.form-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.dialog-actions button {
  min-width: 140px;
}

.field-error {
  min-height: 14px;
  margin-top: -2px;
  color: var(--red);
  font-size: 10px;
  font-weight: 800;
  line-height: 1.4;
}

input.field-invalid,
select.field-invalid,
textarea.field-invalid {
  border-color: var(--red) !important;
  box-shadow: 0 0 0 4px rgba(220, 85, 85, 0.12) !important;
}

.modal h2 {
  margin: -8px 0 0;
  font-size: 25px;
}

.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 10px;
  background: var(--bg);
  font-size: 20px;
  cursor: pointer;
}

.modal label {
  display: grid;
  gap: 8px;
  color: #4c615b;
  font-size: 12px;
  font-weight: 700;
}

.modal input,
.modal select,
.modal textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  background: white;
  resize: vertical;
}

.modal input:focus,
.modal select:focus,
.modal textarea:focus {
  border-color: #8dc4b0;
  box-shadow: 0 0 0 3px var(--mint);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.checkbox-option,
.inline-check {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 9px !important;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

.checkbox-option input,
.inline-check input {
  width: auto;
  margin: 0;
}

.answer-list {
  display: grid;
  gap: 10px;
}

.answer-item {
  display: grid;
  grid-template-columns: minmax(100px, 0.7fr) 2fr auto;
  align-items: center;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdfc;
}

.answer-copy {
  min-width: 0;
  overflow-wrap: anywhere;
}

.task-image-preview,
.task-image-display {
  margin: 12px 0;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: #fbfdfc;
}

.task-image-preview {
  min-height: 140px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.task-image-display img,
.task-image-preview img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  border-radius: 10px;
}

.answer-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.small-button.approve {
  color: var(--green-dark);
  border-color: #a9d9c5;
  background: var(--mint);
}

.small-button.reject {
  color: var(--red);
  border-color: #efc5c5;
  background: #fff4f4;
}

.muted-pill {
  color: var(--muted) !important;
  background: var(--bg) !important;
}

.student-task-list {
  display: grid;
  gap: 16px;
}

.student-task-card h2 {
  margin: 16px 0 8px;
  font-size: 20px;
}

.student-task-card > p,
.muted-copy {
  color: var(--muted);
  line-height: 1.7;
}

.student-task-form {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.student-task-form textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  resize: vertical;
}

.task-choice-list {
  display: grid;
  gap: 9px;
}

.task-choice-list label {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  cursor: pointer;
}

.task-choice-list input {
  width: auto;
}

.task-result,
.submitted-answer {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 11px;
}

.task-result.success {
  color: var(--green-dark);
  background: var(--mint);
}

.task-result.error {
  color: var(--red);
  background: #fff1f1;
}

.task-result.pending {
  color: #786019;
  background: #fff8dd;
}

.submitted-answer {
  background: var(--bg);
}

.answer-item strong,
.answer-item small {
  display: block;
}

.answer-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.filter-bar select {
  min-width: 180px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

.account-toolbar {
  flex-wrap: wrap;
}

.account-toolbar .search-input {
  min-width: 260px;
  flex: 1;
}

.credential-value {
  display: inline-block;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg);
  color: var(--green-dark);
  font-family: Consolas, monospace;
  font-size: 12px;
  user-select: all;
}

.password-value {
  color: #8a4c16;
  background: #fff8e9;
}

.table-subtext {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
}

.account-status {
  display: inline-flex;
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--mint);
  font-size: 10px;
  font-weight: 800;
}

.account-status.suspended {
  color: var(--red);
  background: #fff1f1;
}

.trade-stock {
  padding: 14px;
  border-radius: 14px;
  background: var(--bg);
  min-width: 0;
  overflow: hidden;
}

.stepper {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  min-width: 0;
}

.stepper input {
  border-radius: 0;
  text-align: center;
}

.stepper button {
  border: 1px solid var(--line);
  background: white;
  font-size: 18px;
  cursor: pointer;
}

.stepper button:first-child {
  border-radius: 10px 0 0 10px;
}

.stepper button:last-child {
  border-radius: 0 10px 10px 0;
}

.trade-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 15px;
  border-radius: 12px;
  background: var(--mint);
}

.trade-total strong {
  color: var(--green-dark);
  font-size: 20px;
  min-width: 0;
  overflow-wrap: anywhere;
  text-align: right;
}

.trade-hint {
  min-height: 18px;
  margin: -6px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.full-button {
  width: 100%;
}

.toast {
  position: fixed;
  z-index: 2147483000;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 13px 18px;
  color: white;
  border-radius: 12px;
  background: #163f34;
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(15px);
  transition: 0.25s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.toast-alert {
  background: #9f1d2f;
  box-shadow: 0 18px 42px rgba(159, 29, 47, 0.32);
}

.notice-dialog {
  width: min(520px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: transparent;
}

.notice-dialog::backdrop {
  background: rgba(13, 42, 34, 0.28);
  backdrop-filter: blur(2px);
}

.notice-card {
  position: relative;
  display: grid;
  grid-template-columns: 54px 1fr 42px;
  gap: 14px;
  align-items: start;
  padding: 22px;
  border: 3px solid rgba(207, 60, 66, 0.34);
  border-radius: 24px;
  background: #fff8f1;
  box-shadow: 0 28px 80px rgba(77, 24, 24, 0.28);
  color: var(--green-dark);
}

.notice-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 999px;
  background: #cf3c42;
  color: white;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.notice-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 20px;
  font-weight: 900;
}

.notice-card p {
  margin: 0;
  color: #79333b;
  font-size: 15px;
  font-weight: 800;
  line-height: 1.55;
}

.notice-close {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 14px;
  background: rgba(207, 60, 66, 0.1);
  color: #7b2932;
  cursor: pointer;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.inline-empty,
.table-empty {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.logout-button {
  color: #8a4a4a;
}

@media (max-width: 1050px) {
  .hero-card,
  .market-card {
    grid-column: span 7;
  }

  .mission-card,
  .ranking-card {
    grid-column: span 5;
  }

  .stats-grid,
  .portfolio-grid,
  .reward-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .market-info-panel {
    grid-template-columns: 1fr;
  }

  .dividend-table-head,
  .dividend-record {
    grid-template-columns: minmax(160px, 1.2fr) minmax(110px, 0.9fr) minmax(88px, 0.7fr) minmax(100px, 0.8fr) minmax(130px, 1fr);
    gap: 10px;
  }
}

@media (max-width: 900px) {
  .stock-row {
    grid-template-columns: minmax(130px, 1fr) 72px 68px;
  }

  .stock-row.with-quantity {
    grid-template-columns: minmax(120px, 1fr) 70px 70px;
    gap: 7px;
  }

  .stock-row.with-quantity .market-quantity {
    grid-row: 2;
    grid-column: 2;
  }

  .stock-row.with-quantity .small-button {
    grid-row: 2;
    grid-column: 3;
  }
}

@media (max-width: 800px) {
  .stock-detail-content {
    padding: 22px 16px;
  }

  .stock-detail-header {
    display: block;
  }

  .stock-detail-price {
    margin-top: 14px;
    text-align: left;
  }

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

  .login-screen {
    display: block;
  }

  .login-panel {
    min-height: 100vh;
    padding: 36px 24px;
  }

  .login-brand {
    margin-bottom: 48px;
  }

  .login-visual {
    display: none;
  }

  .topbar {
    height: 68px;
    padding: 0 16px;
  }

  .brand small,
  .market-status,
  .profile-button > span:nth-child(2),
  .profile-button > span:last-child {
    display: none;
  }

  .layout {
    display: block;
  }

  .sidebar {
    position: fixed;
    z-index: 9;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    display: block;
    width: 100%;
    height: auto;
    padding: 8px 10px;
    border-top: 1px solid var(--line);
    border-right: 0;
    background: white;
  }

  nav {
    display: flex;
    justify-content: flex-start;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  nav::-webkit-scrollbar {
    display: none;
  }

  .nav-button {
    flex: 0 0 60px;
    flex-direction: column;
    gap: 2px;
    min-width: 60px;
    padding: 7px 5px;
    font-size: 9px;
  }

  .nav-button .nav-icon {
    font-size: 18px;
  }

  .sidebar-card,
  .role-switch {
    display: none;
  }

  .main-content {
    min-height: calc(100vh - 68px);
    padding: 25px 16px 100px;
  }

  .hero-card,
  .mission-card,
  .market-card,
  .ranking-card {
    grid-column: 1 / -1;
  }

  .hero-stats {
    position: relative;
    right: auto;
    bottom: auto;
    margin-top: 24px;
  }

  .page-heading {
    align-items: flex-start;
  }

  .toolbar {
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .search-input {
    width: 100%;
    min-width: 0;
  }

  .stock-row {
    grid-template-columns: minmax(130px, 1fr) 72px 68px;
  }

  .stock-row.with-quantity {
    grid-template-columns: minmax(120px, 1fr) 70px 70px;
    gap: 7px;
  }

  .stock-row.with-quantity .market-quantity {
    grid-row: 2;
    grid-column: 2;
  }

  .stock-row.with-quantity .small-button {
    grid-row: 2;
    grid-column: 3;
  }

  .trade-stock .stock-row {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .api-card {
    grid-template-columns: 1fr;
  }

  .dividend-preview,
  .redeem-summary {
    grid-template-columns: 1fr;
  }

  .dividend-preview > div:last-child {
    text-align: left;
  }

  .dividend-table-head {
    display: none;
  }

  .dividend-record {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .dividend-stock-cell,
  .dividend-amount {
    grid-column: 1 / -1;
  }

  .dividend-amount {
    padding-top: 10px;
    border-top: 1px solid var(--line);
    text-align: left;
  }

  .mobile-label {
    display: block;
    margin-bottom: 3px;
  }
}

@media (max-width: 520px) {
  .stats-grid,
  .portfolio-grid,
  .reward-grid {
    grid-template-columns: 1fr;
  }

  .page-heading {
    display: grid;
  }

  .hero-card {
    padding: 22px;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: auto;
  }

  .dialog-actions {
    flex-direction: column;
  }

  .dialog-actions button {
    width: 100%;
  }

  .modal {
    width: min(100% - 18px, 440px);
    max-width: calc(100vw - 18px);
    border-radius: 18px;
  }

  .modal form {
    padding: 24px 18px;
  }

  .modal h2 {
    padding-right: 42px;
    font-size: 22px;
  }

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

  .trade-total strong {
    width: 100%;
    text-align: left;
  }

  .dividend-record {
    grid-template-columns: 1fr;
  }

  .image-preview {
    max-width: none;
  }
}
