:root {
  color-scheme: light;
  --bg: #f3f6f8;
  --panel: #ffffff;
  --panel-soft: #f7faf9;
  --text: #142029;
  --muted: #667383;
  --border: #dce4e8;
  --accent: #0e6f5c;
  --accent-dark: #0a5245;
  --accent-soft: #e7f5f1;
  --blue: #2454d6;
  --amber: #b7791f;
  --violet: #7c3aed;
  --ink: #111827;
  --danger-bg: #fff1f0;
  --danger-text: #9f1d1d;
  --focus: #2b7cff;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.62)),
    var(--bg);
}

img,
svg {
  max-width: 100%;
}

.page,
.dashboard-page,
.finance-page,
.page-narrow {
  width: min(100% - 24px, 560px);
  margin: 0 auto;
  padding: 24px 0;
}

.panel,
.visual,
.auth-panel,
.tool-card,
.metric-strip > div,
.metric-grid > div,
.document-preview {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 18px 42px rgba(25, 40, 57, 0.07);
}

.panel {
  padding: 20px;
}

.shell,
.account-layout,
.split-layout,
.form-grid,
.tool-grid,
.upload-grid,
.metric-grid,
.metric-strip,
.line-editor {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.visual {
  display: grid;
  place-items: center;
  min-height: 170px;
  padding: 24px;
  background: #101820;
  order: -1;
}

.qr-mark {
  width: 132px;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.qr-mark span {
  display: block;
  border-radius: 2px;
  background: #ffffff;
}

.qr-mark span:nth-child(3n + 2),
.qr-mark span:nth-child(5n) {
  background: transparent;
}

h1,
h2 {
  line-height: 1.14;
  letter-spacing: 0;
}

h1 {
  margin: 0 0 20px;
  font-size: 1.65rem;
}

h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

label,
.legend {
  font-weight: 700;
  color: #243242;
}

input[type="url"],
input[type="text"],
input[type="password"],
input[type="file"],
input[type="date"],
input[type="color"],
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  color: var(--text);
  background: #ffffff;
}

input[type="file"] {
  min-height: auto;
  padding: 10px;
  font-size: 0.92rem;
}

input[type="color"] {
  padding: 6px;
}

textarea {
  min-height: 108px;
  resize: vertical;
}

select {
  appearance: none;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(43, 124, 255, 0.26);
  outline-offset: 2px;
  border-color: var(--focus);
}

.choice-grid,
.choice-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.choice {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel-soft);
  cursor: pointer;
}

.choice input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.hint {
  color: var(--muted);
  font-size: 0.92rem;
}

.error,
.success,
.notice,
.recovery-code,
.conversion-note {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 6px;
}

.error {
  border: 1px solid #ffd2cf;
  color: var(--danger-text);
  background: var(--danger-bg);
}

.success,
.recovery-code {
  border: 1px solid #bfe6d8;
  color: #0b6148;
  background: #ecfbf5;
}

.notice,
.conversion-note {
  border: 1px solid var(--border);
  color: var(--muted);
  background: #ffffff;
}

.recovery-code {
  display: grid;
  gap: 8px;
}

.recovery-code span {
  font-size: 0.85rem;
  font-weight: 800;
}

.recovery-code code {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
}

.actions {
  margin-top: 22px;
}

button,
.button-link,
.button-secondary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 0;
  border-radius: 6px;
  font: inherit;
  font-weight: 850;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

button,
.button-link {
  color: #ffffff;
  background: var(--accent);
}

button:hover,
.button-link:hover {
  background: var(--accent-dark);
}

.button-link.secondary,
.button-secondary {
  color: var(--text);
  background: #eef2f6;
}

.button-link.secondary:hover,
.button-secondary:hover {
  background: #e0e7ef;
}

.danger-button {
  color: #9f1d1d;
}

.inline-form {
  margin: 0;
}

.auth-screen {
  display: grid;
  place-items: center;
  padding: 18px 12px;
  background:
    linear-gradient(135deg, rgba(14, 111, 92, 0.12), rgba(36, 84, 214, 0.08)),
    var(--bg);
}

.auth-wrap {
  width: min(100%, 430px);
}

.auth-panel {
  padding: 24px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 22px 70px rgba(17, 24, 39, 0.13);
}

.auth-brand {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 22px;
  color: var(--accent);
  font-weight: 900;
}

.auth-footer {
  margin-top: 18px;
  text-align: center;
}

.brand-mark,
.tool-icon {
  display: grid;
  place-items: center;
  border-radius: 8px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  color: #ffffff;
  background: var(--accent);
}

.brand-mark svg,
.tool-icon svg {
  width: 24px;
  height: 24px;
}

.brand-mark path,
.tool-icon path,
.tool-icon circle {
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 18px;
  color: var(--muted);
  font-size: 0.95rem;
}

.brand-link {
  color: var(--ink);
  font-weight: 900;
  text-decoration: none;
}

.topbar-actions {
  display: flex;
  gap: 10px 14px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.text-link {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.text-link:hover {
  color: var(--accent-dark);
  text-decoration: underline;
}

.dashboard-head {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: stretch;
  margin: 20px 0;
}

.eyebrow {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.dashboard-head h1 {
  margin-bottom: 0;
}

.metric-strip > div,
.metric-grid > div {
  padding: 16px;
}

.metric-grid > div {
  min-height: 98px;
}

.metric-value,
.metric-grid strong {
  display: block;
  color: var(--ink);
  font-weight: 900;
  line-height: 1;
}

.metric-value {
  font-size: 1.65rem;
}

.metric-grid strong {
  margin-top: 12px;
  font-size: 1.15rem;
  line-height: 1.16;
}

.metric-label {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.tool-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  min-height: 138px;
  padding: 18px;
  color: var(--text);
  text-decoration: none;
}

.tool-card:hover {
  border-color: rgba(14, 111, 92, 0.42);
}

.tool-card strong {
  display: block;
  margin-bottom: 7px;
  color: var(--ink);
  font-size: 1.15rem;
}

.tool-card small {
  color: var(--muted);
  font-size: 0.95rem;
}

.tool-icon {
  width: 56px;
  height: 56px;
}

.qr-icon {
  color: var(--accent);
  background: var(--accent-soft);
}

.qr-icon path {
  fill: currentColor;
  stroke: none;
}

.image-icon {
  color: var(--blue);
  background: #edf2ff;
}

.finance-icon {
  color: var(--violet);
  background: #f1edff;
}

.folder-icon {
  color: var(--amber);
  background: #fff7e8;
}

.finance-nav {
  display: flex;
  gap: 6px;
  align-items: center;
  overflow-x: auto;
  margin: 0 0 20px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  -webkit-overflow-scrolling: touch;
}

.finance-nav a {
  flex: 0 0 auto;
  padding: 9px 12px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
}

.finance-nav a:hover,
.finance-nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.finance-actions,
.compact-actions,
.document-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: center;
}

.finance-tools {
  margin-top: 20px;
}

.settings-panel,
.converter-panel {
  width: 100%;
  margin: 0 auto;
}

.line-head {
  display: none;
}

.line-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: center;
}

.line-row input,
.line-row select {
  min-height: 44px;
}

.payment-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.document-actions {
  margin: 18px 0;
}

.document-preview {
  overflow-x: auto;
  background: #ffffff;
}

.upload-card {
  display: grid;
  gap: 14px;
  align-content: start;
  min-height: 176px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-soft);
  cursor: pointer;
}

.upload-card strong {
  display: block;
  margin-bottom: 5px;
}

.upload-card small {
  color: var(--muted);
  font-size: 0.9rem;
}

.account-layout .panel:first-child {
  grid-row: auto;
}

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

@media (min-width: 560px) {
  .page,
  .dashboard-page,
  .finance-page {
    width: min(100% - 32px, 720px);
    padding: 32px 0;
  }

  .choice-row,
  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .finance-actions,
  .compact-actions,
  .document-actions {
    display: flex;
    flex-wrap: wrap;
  }

  .button-link,
  .button-secondary,
  .document-actions button,
  .inline-form button {
    width: auto;
  }
}

@media (min-width: 760px) {
  .page {
    width: min(100% - 40px, 980px);
    padding: 42px 0;
  }

  .dashboard-page {
    width: min(100% - 40px, 1060px);
  }

  .finance-page {
    width: min(100% - 40px, 1180px);
  }

  .panel {
    padding: 28px;
  }

  h1 {
    font-size: 2rem;
  }

  .shell {
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 28px;
    align-items: stretch;
  }

  .visual {
    min-height: auto;
    order: initial;
  }

  .qr-mark {
    width: 196px;
    gap: 8px;
  }

  .topbar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .topbar-actions {
    justify-content: flex-end;
  }

  .dashboard-head {
    flex-direction: row;
    justify-content: space-between;
    align-items: end;
    gap: 24px;
    margin: 24px 0;
  }

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

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

  .tool-card {
    min-height: 170px;
    padding: 22px;
  }

  .line-head,
  .line-row {
    display: grid;
    grid-template-columns: minmax(130px, 0.9fr) minmax(220px, 1.6fr) minmax(70px, 0.45fr) minmax(90px, 0.55fr) minmax(70px, 0.45fr);
    gap: 8px;
  }

  .line-head {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 900;
    text-transform: uppercase;
  }

  .payment-row {
    grid-template-columns: 140px 120px 1fr 1fr 120px;
  }
}

@media (min-width: 980px) {
  .account-layout {
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
    gap: 20px;
  }

  .account-layout .panel:first-child {
    grid-row: span 2;
  }

  .split-layout {
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
    gap: 20px;
    align-items: start;
  }

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

  .converter-panel {
    width: min(100%, 780px);
  }

  .settings-panel {
    width: min(100%, 900px);
  }

  .tool-card:hover {
    transform: translateY(-1px);
  }
}
