:root {
  --ink: #202428;
  --muted: #697178;
  --line: #dfe2e4;
  --surface: #fff;
  --canvas: #f6f6f5;
  --action: #30363b;
  --focus: #4d7c8a;
  --success: #2f6e59;
  --error: #a33641;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: 34px; line-height: 1.15; }
h2 { margin-bottom: 8px; font-size: 23px; }

.eyebrow {
  margin-bottom: 8px;
  color: #596168;
  text-transform: uppercase;
  letter-spacing: .13em;
  font-size: 10px;
  font-weight: 800;
}

.muted { color: var(--muted); }
form { display: grid; gap: 17px; }
label { display: grid; gap: 7px; font-size: 13px; font-weight: 700; }
label small { color: var(--muted); font-weight: 400; }

input {
  min-height: 44px;
  padding: 10px 11px;
  border: 1px solid #cbd0d3;
  border-radius: 7px;
  outline: none;
  font: inherit;
}

input:focus { border-color: var(--focus); box-shadow: 0 0 0 3px rgba(77,124,138,.13); }
input[readonly] { color: var(--muted); background: var(--canvas); cursor: not-allowed; }

button,
.primary-link {
  min-height: 43px;
  padding: 10px 16px;
  border: 0;
  border-radius: 7px;
  color: #fff;
  background: var(--action);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

button:hover,
.primary-link:hover { background: #15191c; }

.primary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.primary-link.compact { min-height: auto; }
.secondary-link { color: var(--muted); font-weight: 700; text-underline-offset: 3px; }

.login-body { display: grid; place-items: center; padding: 24px; }

.login-card {
  width: min(420px, 100%);
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 18px 55px rgba(24,30,34,.07);
}

.login-card form { margin-top: 26px; }
.footnote { margin: 20px 0 0; text-align: center; color: var(--muted); font-size: 12px; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  padding: 0 max(24px, calc((100vw - 1180px) / 2));
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.brand { text-decoration: none; font-weight: 800; letter-spacing: -.02em; }
.topbar-actions, .main-nav { display: flex; align-items: center; }
.topbar-actions { gap: 22px; }
.main-nav { gap: 6px; }

.main-nav a {
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

.main-nav a:hover,
.main-nav a.active { color: var(--ink); background: var(--canvas); }
.topbar form { display: block; }
.link-button { min-height: auto; padding: 8px 10px; color: var(--muted); background: transparent; }

.page { width: min(1180px, calc(100% - 36px)); margin: 42px auto 70px; }

.home-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: start;
  gap: 22px;
}

.app-workspace,
.balance-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.app-workspace { min-height: 590px; padding: 38px; }

.app-placeholder {
  display: grid;
  place-items: center;
  min-height: 390px;
  margin-top: 34px;
  border: 1px dashed #cbd0d3;
  border-radius: 10px;
  color: var(--muted);
  background: #fafafa;
}

.app-placeholder p { margin: 0; }

.balance-card {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  padding: 26px;
}

.balance-card h2 { font-size: 30px; }
.balance-card .primary-link { margin-top: 10px; }
.balance-card .secondary-link { align-self: center; margin-top: 16px; font-size: 13px; }

.subpage { width: min(1080px, calc(100% - 36px)); }
.settings-page { width: min(900px, calc(100% - 36px)); }
.back-link { display: inline-block; margin-bottom: 24px; color: var(--muted); font-weight: 700; text-underline-offset: 3px; }

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

.page-heading p:last-child { margin-bottom: 0; }
.packages { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 15px; }

.package {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 225px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}

.package strong { display: block; font-size: 25px; }
.package p { color: var(--muted); }
.package form { margin-top: 25px; }

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

.settings-card {
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}

.settings-card > p { margin-bottom: 24px; }
.settings-card button { justify-self: start; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
tbody tr:last-child td { border-bottom: 0; }
.number { text-align: right; }
.positive { color: var(--success); font-weight: 750; }
.negative { color: var(--error); font-weight: 750; }

.reference { position: relative; }
.reference summary { color: var(--muted); cursor: pointer; font-size: 12px; font-weight: 700; }
.reference code {
  position: absolute;
  z-index: 2;
  top: calc(100% + 7px);
  left: 0;
  display: block;
  width: max-content;
  max-width: min(360px, 70vw);
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow-wrap: anywhere;
  white-space: normal;
  color: var(--muted);
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(24,30,34,.12);
  font-size: 11px;
}

.empty { padding: 24px; border: 1px dashed #cbd0d3; border-radius: 10px; color: var(--muted); text-align: center; }
.notice, .alert { margin-bottom: 20px; padding: 12px 14px; border-radius: 8px; font-weight: 650; }
.notice { border: 1px solid #b9d9cd; color: var(--success); background: #edf7f3; }
.alert { border: 1px solid #e5bcc1; color: var(--error); background: #fbedef; }

@media (max-width: 800px) {
  .home-layout { grid-template-columns: 1fr; }
  .balance-card { position: static; grid-row: 1; }
  .app-workspace { min-height: 500px; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .login-body { padding: 0; }
  .login-card { min-height: 100vh; padding: 34px 23px; border: 0; border-radius: 0; }
  .topbar { align-items: flex-start; padding: 18px; }
  .topbar-actions { align-items: flex-end; gap: 8px; }
  .main-nav { align-items: flex-end; flex-direction: column; }
  .main-nav a { padding: 4px 8px; }
  .page { margin-top: 25px; }
  .app-workspace { min-height: 430px; padding: 25px; }
  .app-placeholder { min-height: 260px; }
  .page-heading { display: block; }
  .page-heading > a { margin-top: 12px; }
}
