:root {
  --bg: #eef5ff;
  --bg-deep: #dbeaff;
  --primary: #1f5f9e;
  --primary-dark: #174b7e;
  --primary-soft: #4b86c5;
  --ink: #102235;
  --muted: #5e728a;
  --line: rgba(31, 95, 158, 0.18);
  --card: rgba(255, 255, 255, 0.9);
  --card-solid: #ffffff;
  --danger: #b42318;
  --success: #177245;
  --warning: #9a6700;
  --shadow: 0 22px 60px rgba(18, 54, 92, 0.16);
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(76, 139, 203, 0.35), transparent 34rem),
    linear-gradient(180deg, var(--bg) 0%, #f8fbff 42%, #edf6ff 100%);
  color: var(--ink);
  font-family: var(--font);
}

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

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 18px;
}

.hero__text {
  padding: 34px;
  background: linear-gradient(135deg, rgba(31, 95, 158, 0.97), rgba(39, 109, 178, 0.92));
  border-radius: var(--radius-lg);
  color: white;
  box-shadow: var(--shadow);
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-size: 0.75rem;
  opacity: 0.84;
  font-weight: 700;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 8px;
  font-size: clamp(2.4rem, 8vw, 5rem);
  line-height: 0.95;
  letter-spacing: -0.07em;
}

.hero__subtitle {
  margin: 0;
  max-width: 660px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 1.08rem;
}

.bank-card {
  min-height: 220px;
  border-radius: var(--radius-lg);
  padding: 24px;
  color: white;
  box-shadow: var(--shadow);
  background:
    radial-gradient(circle at 15% 10%, rgba(255, 255, 255, 0.18), transparent 14rem),
    linear-gradient(145deg, #2a70b2, #163d66 72%);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.bank-card::after {
  content: "";
  position: absolute;
  width: 190px;
  height: 190px;
  right: -66px;
  bottom: -80px;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 50%;
}

.bank-card__top, .bank-card__bottom {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.78);
}

.bank-card__top span:first-child {
  font-size: 1.3rem;
  font-weight: 800;
  color: white;
  letter-spacing: -0.03em;
}

.bank-card__chip {
  width: 56px;
  height: 42px;
  border-radius: 10px;
  background: linear-gradient(135deg, #e4d39c, #fff0bd 48%, #ba9c42);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15);
}

.bank-card__number {
  font-size: 1.7rem;
  letter-spacing: 0.03em;
  font-weight: 700;
}

.tabs {
  position: sticky;
  top: 8px;
  z-index: 5;
  display: flex;
  gap: 8px;
  padding: 8px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,0.78);
  backdrop-filter: blur(18px);
  box-shadow: 0 14px 40px rgba(18, 54, 92, 0.08);
  overflow-x: auto;
}

.tab {
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  color: var(--primary-dark);
  background: transparent;
  font-weight: 700;
  white-space: nowrap;
}

.tab.is-active {
  background: var(--primary);
  color: white;
}

.main { min-height: 420px; }

.panel-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}

.stat-card, .section, .card-row, .empty-state {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: 0 14px 38px rgba(18, 54, 92, 0.07);
}

.stat-card {
  padding: 18px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.stat-card strong {
  display: block;
  margin-top: 7px;
  font-size: clamp(1.45rem, 4vw, 2.2rem);
  letter-spacing: -0.04em;
}

.section {
  padding: 20px;
  margin-bottom: 18px;
}

.section__head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.section__head h2, .section__head h3 {
  margin-bottom: 4px;
  letter-spacing: -0.04em;
}

.section__head p {
  color: var(--muted);
  margin-bottom: 0;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.button {
  border: 0;
  border-radius: 14px;
  padding: 11px 15px;
  background: var(--primary);
  color: white;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(31, 95, 158, 0.18);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.button:hover { background: var(--primary-dark); }
.button--ghost {
  color: var(--primary-dark);
  background: rgba(31, 95, 158, 0.09);
  box-shadow: none;
}
.button--danger {
  color: white;
  background: var(--danger);
}
.button--small {
  padding: 8px 10px;
  border-radius: 11px;
  font-size: 0.9rem;
}

.input-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}

.input-row input, .input-row select, .field input, .field textarea, .field select {
  width: 100%;
  border: 1px solid rgba(31, 95, 158, 0.24);
  border-radius: 14px;
  background: rgba(255,255,255,0.92);
  padding: 12px 13px;
  color: var(--ink);
  outline: none;
}

.input-row input:focus, .input-row select:focus, .field input:focus, .field textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(31, 95, 158, 0.12);
}

.input-row > * { flex: 1 1 180px; }
.input-row .button { flex: 0 0 auto; }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.card-row {
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-row__top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(31, 95, 158, 0.1);
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 0.78rem;
}

.balance {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.balance.negative { color: var(--danger); }

.card-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.card-actions .button:last-child { grid-column: 1 / -1; }

.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid rgba(31, 95, 158, 0.12);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.amount-plus { color: var(--success); font-weight: 900; }
.amount-minus { color: var(--danger); font-weight: 900; }

.card-detail {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 18px;
}

.detail-card {
  background: linear-gradient(145deg, #2b72b3, #194c80);
  color: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.detail-card .balance { font-size: 2.4rem; }
.detail-card p { color: rgba(255,255,255,0.78); margin-bottom: 0; }
.detail-card .badge { background: rgba(255,255,255,0.16); color: white; }

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

.link-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255,255,255,0.7);
  display: grid;
  gap: 8px;
}

.link-item code {
  color: var(--primary-dark);
  word-break: break-all;
  font-size: 0.82rem;
}

.empty-state {
  padding: 30px;
  text-align: center;
  color: var(--muted);
}

.notice {
  border: 1px solid rgba(154, 103, 0, 0.2);
  background: rgba(255, 245, 215, 0.92);
  color: #684600;
  padding: 13px 14px;
  border-radius: 14px;
  margin-bottom: 16px;
}

.good-notice {
  border-color: rgba(23, 114, 69, 0.18);
  background: rgba(220, 250, 235, 0.85);
  color: #0f5132;
}

.dialog {
  border: 0;
  background: transparent;
  padding: 0;
  width: min(540px, calc(100% - 24px));
}
.dialog::backdrop { background: rgba(16, 34, 53, 0.46); backdrop-filter: blur(5px); }
.dialog__box {
  position: relative;
  background: white;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 22px;
  box-shadow: var(--shadow);
}
.dialog__close {
  position: absolute;
  right: 14px;
  top: 12px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(31, 95, 158, 0.08);
  color: var(--primary-dark);
  font-size: 1.4rem;
}
.field {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
}
.field span { font-weight: 800; color: var(--primary-dark); }
.field small { color: var(--muted); }
.field textarea { min-height: 84px; resize: vertical; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(90px);
  z-index: 20;
  max-width: min(520px, calc(100% - 24px));
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-weight: 750;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: 0.25s ease;
  text-align: center;
}
.toast.is-visible { transform: translateX(-50%) translateY(0); opacity: 1; }

@media (max-width: 980px) {
  .hero, .card-detail { grid-template-columns: 1fr; }
  .cards-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .panel-grid { grid-template-columns: repeat(2, 1fr); }
  .link-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .app-shell { width: min(100% - 18px, 1180px); padding-top: 10px; }
  .hero__text, .bank-card, .section { padding: 18px; }
  .hero { gap: 10px; }
  .tabs { top: 4px; }
  .cards-grid, .panel-grid, .link-grid { grid-template-columns: 1fr; }
  .section__head { flex-direction: column; }
  .input-row .button { flex: 1 1 100%; }
  .card-actions { grid-template-columns: 1fr; }
  .dialog__actions { flex-direction: column-reverse; }
  .dialog__actions .button { width: 100%; }
  .bank-card__number { font-size: 1.35rem; }
}

@media print {
  body { background: white; }
  .hero, .tabs, .section:not(.printable), .toast { display: none !important; }
  .app-shell { width: 100%; padding: 0; }
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.qr-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: rgba(255,255,255,0.75);
  text-align: center;
  display: grid;
  gap: 8px;
  justify-items: center;
}

.qr-card img {
  width: 100%;
  max-width: 135px;
  height: auto;
  border-radius: 10px;
  background: white;
}

.qr-card small { color: var(--muted); font-weight: 800; }

@media (max-width: 980px) {
  .qr-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .qr-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
