/* Fiskers Bank — base styles: tokens, type, forms, buttons, panels, tables, dialogs. */

:root {
  --brand: #0f5c6e;
  --brand-dark: #0a4352;
  --brand-light: #e6f1f3;
  --accent: #e8771e;
  --accent-dark: #c9600e;
  --ink: #23292d;
  --text: #3a4246;
  --muted: #6b7479;
  --muted-2: #8d959a;
  --line: #dde1e3;
  --line-2: #c8ced1;
  --bg: #f2f4f5;
  --panel: #ffffff;
  --panel-2: #f7f8f9;
  --link: #0a6bb0;
  --green: #2c7a3f;
  --green-2: #e8f4ea;
  --red: #c0392b;
  --red-2: #fbeceb;
  --amber: #9a6200;
  --amber-2: #fdf4e1;
  --blue: #0a6bb0;
  --blue-2: #e8f1f9;
  --sans: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: Consolas, "Liberation Mono", Menlo, monospace;
  --radius: 4px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
}

body.modal-open { overflow: hidden; }

h1, h2, h3, h4, h5, p { margin: 0; }
h1, h2, h3, h4 { color: var(--ink); font-weight: 600; line-height: 1.25; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
table { border-collapse: collapse; width: 100%; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--link); outline-offset: 1px; }

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: -3px;
}
.icon.xs { width: 13px; height: 13px; }

.mono { font-family: var(--mono); font-size: 0.95em; }
.muted { color: var(--muted); }
.pos { color: var(--green); }
.neg { color: var(--ink); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Layout helpers ---------- */

.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 20px;
}
.stack { display: grid; gap: 20px; align-content: start; }
.cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: start;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }

/* ---------- Page heading ---------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-title { font-size: 26px; font-weight: 400; color: var(--ink); }
.page-sub { margin-top: 4px; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.crumbs { margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.crumbs a { color: var(--link); }

/* ---------- Panels ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2, .panel-head h3 { font-size: 17px; }
.panel-head .sub { margin-top: 2px; font-size: 13px; color: var(--muted); }
.panel-head a, .panel-head .panel-link { font-size: 13px; }
.panel-body { padding: 18px; }
.panel-foot {
  padding: 11px 18px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 13px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.panel.flush .panel-body { padding: 0; }

.side-box h3 { font-size: 15px; }
.side-box p { font-size: 13px; color: var(--muted); }
.link-list li { border-top: 1px solid var(--line); }
.link-list li:first-child { border-top: 0; }
.link-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  font-size: 14px;
}
.link-list a::after { content: "›"; color: var(--muted-2); font-size: 18px; line-height: 1; }

/* ---------- Key/value rows ---------- */

.kv { display: grid; }
.kv-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  font-size: 14px;
}
.kv-row:first-child { border-top: 0; }
.kv-row .k { color: var(--muted); }
.kv-row .v { color: var(--ink); text-align: right; }
.kv-row.total { font-weight: 600; font-size: 16px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 18px;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn .icon { width: 15px; height: 15px; }

.btn-accent { background: var(--accent); border-color: var(--accent); }
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-outline, .btn-secondary {
  background: #fff;
  border-color: var(--line-2);
  color: var(--ink);
}
.btn-outline:hover, .btn-secondary:hover { background: var(--panel-2); border-color: var(--muted-2); }
.btn-danger { background: var(--red); border-color: var(--red); }
.btn-danger:hover { background: #a5301f; border-color: #a5301f; }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-xs { min-height: 26px; padding: 0 9px; font-size: 12px; font-weight: 500; }
.btn-block { width: 100%; }
.btn-loading { opacity: 0.85; }

.link, .link-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--link);
  font-size: inherit;
  cursor: pointer;
}
.link:hover, .link-btn:hover { text-decoration: underline; }
.link:disabled { color: var(--muted-2); text-decoration: none; cursor: default; }

/* ---------- Forms ---------- */

.field { display: grid; gap: 5px; align-content: start; }
.field > label, .label { font-size: 14px; font-weight: 600; color: var(--ink); }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.label-row a { font-size: 13px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-grid .span-2 { grid-column: 1 / -1; }

.input, .select, textarea.input {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid #b9c1c5;
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font-size: 14px;
}
textarea.input { min-height: 90px; resize: vertical; }
.input:focus, .select:focus { outline: none; border-color: var(--link); box-shadow: 0 0 0 2px rgba(10, 107, 176, 0.18); }
.input.error { border-color: var(--red); }
.input[readonly] { background: var(--panel-2); color: var(--muted); }
.select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%235b6468' stroke-width='1.6' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.input-wrap { position: relative; }
.input-prefix {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.money-input .input { padding-left: 22px; }
.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: none;
  color: var(--link);
  font-size: 13px;
  padding: 4px 6px;
}

.helper { font-size: 13px; color: var(--muted); }
.helper.error { color: var(--red); }
.helper.success { color: var(--green); }

.checkbox, .radio {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}
.checkbox input, .radio input { margin: 3px 0 0; width: 15px; height: 15px; accent-color: var(--brand); flex: none; }

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

/* ---------- Alerts ---------- */

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 14px;
  border: 1px solid #b9d4ea;
  border-left-width: 4px;
  border-radius: var(--radius);
  background: var(--blue-2);
  color: var(--ink);
  font-size: 14px;
}
.alert .icon { margin-top: 2px; color: var(--blue); }
.alert.warn { background: var(--amber-2); border-color: #ecd29b; }
.alert.warn .icon { color: var(--amber); }
.alert.error { background: var(--red-2); border-color: #eab8b2; }
.alert.error .icon { color: var(--red); }
.alert.success { background: var(--green-2); border-color: #b7dbbf; }
.alert.success .icon { color: var(--green); }

/* Error boxes that are hidden until shown by script. */
.form-error { display: none; }
.form-error.show { display: flex; }

/* ---------- Badges ---------- */

.badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  background: #eceff0;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-green { background: var(--green-2); color: var(--green); }
.badge-red { background: var(--red-2); color: var(--red); }
.badge-amber { background: var(--amber-2); color: var(--amber); }
.badge-blue { background: var(--blue-2); color: var(--blue); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; }
.table th {
  padding: 9px 14px;
  border-bottom: 2px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 14px;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table .num, .table th.num { text-align: right; white-space: nowrap; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: #f5f9fb; }
.table .cell-sub { display: block; margin-top: 2px; font-size: 12px; color: var(--muted); }
.table a.cell-main { font-weight: 600; }

.amount { white-space: nowrap; }
.amount.pos { color: var(--green); }

/* ---------- Empty state ---------- */

.empty { padding: 34px 20px; text-align: center; color: var(--muted); }
.empty h4 { font-size: 16px; margin-bottom: 4px; }

/* ---------- Spinner ---------- */

.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner.lg { width: 30px; height: 30px; border-width: 3px; color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Dialogs ---------- */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-y: auto;
}
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); }
.modal {
  position: relative;
  width: 100%;
  max-width: 560px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 6px 30px rgba(0, 0, 0, 0.25);
}
.modal.sm { max-width: 440px; }
.modal.lg { max-width: 760px; }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-title { font-size: 19px; font-weight: 600; }
.modal-sub { margin-top: 2px; font-size: 13px; color: var(--muted); }
.modal-close {
  border: 0;
  background: none;
  padding: 2px;
  color: var(--muted);
}
.modal-close:hover { color: var(--ink); }
.modal-body { padding: 20px; max-height: calc(100vh - 200px); overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 0 0 var(--radius) var(--radius);
}
.modal-foot.spread { justify-content: space-between; }
.modal-body p { line-height: 1.55; }

/* ---------- Toasts ---------- */

.toast-root {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
}
.toast {
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line-2);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
  font-size: 14px;
  cursor: pointer;
}
.toast .icon { margin-top: 1px; color: var(--blue); }
.toast strong { display: block; color: var(--ink); }
.toast.success { border-left-color: var(--green); }
.toast.success .icon { color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.error .icon { color: var(--red); }
.toast.leaving { opacity: 0; transition: opacity 0.2s; }

/* ---------- One-time code field ---------- */

.code-input {
  max-width: 180px;
  font-family: var(--mono);
  font-size: 20px;
  letter-spacing: 0.3em;
}

/* ---------- Motion ---------- */

.shake { animation: shake 0.35s; }
@keyframes shake {
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

@media (max-width: 900px) {
  .cols, .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .container { padding: 0 12px; }
  .field-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .page-title { font-size: 22px; }
  .modal-root { padding: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
