/* ===== Emerald Network design system ===== */
:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --surface2: #f0f3f8;
  --surface3: #e8edf4;
  --ink: #111827;
  --ink2: #4b5563;
  --ink3: #9ca3af;
  --brand: #0e9f6e;
  --brand-dark: #0b7a55;
  --brand-soft: #e4f7ef;
  --brand2: #1a7a9f;
  --ribbon: #6d28d9;
  --warn: #d97706;
  --danger: #dc2626;
  --ok: #059669;
  --line: #e5e9f0;
  --shadow: 0 10px 30px rgba(17, 24, 39, .08);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", SFMono-Regular, Menlo, monospace;
  --maxw: 1240px;
}
[data-theme="dark"] {
  --bg: #0b0f1a;
  --surface: #131a2a;
  --surface2: #1b2438;
  --surface3: #243046;
  --ink: #e6ecf5;
  --ink2: #aeb9cc;
  --ink3: #6b7689;
  --brand-soft: #103a2d;
  --line: #243046;
  --shadow: 0 10px 30px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { line-height: 1.2; margin: 0 0 .5rem; }
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.muted { color: var(--ink2); }
.small { font-size: .85em; }
.mono { font-family: var(--mono); }

/* ===== topbar ===== */
.topbar {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(12px);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border-bottom: 1px solid var(--line);
}
.topbar .container { display: flex; align-items: center; gap: 16px; height: 60px; }
.brand { font-weight: 800; font-size: 1.12rem; display: flex; align-items: center; gap: 8px; }
.brand .em { width: 26px; height: 26px; border-radius: 8px; background: linear-gradient(135deg, var(--brand), var(--brand2)); display: inline-grid; place-items: center; color: #fff; font-size: 14px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a { color: var(--ink2); padding: 8px 12px; border-radius: 10px; font-weight: 600; font-size: .92rem; white-space: nowrap; }
.nav a:hover { background: var(--surface2); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--brand-soft); color: var(--brand); }
.nav.spacer { flex: 0; }
.top-actions { display: flex; gap: 8px; align-items: center; }

/* ===== buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 12px; padding: 10px 18px; font: 600 .95rem var(--font); cursor: pointer; transition: transform .08s, box-shadow .2s, background .2s; background: var(--surface2); color: var(--ink); }
.btn:hover { transform: translateY(-1px); filter: brightness(1.02); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; box-shadow: 0 8px 20px rgba(14,159,110,.3); }
.btn-dark { background: var(--ink); color: var(--bg); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: .85rem; border-radius: 9px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== cards & layout ===== */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.row { display: flex; align-items: center; gap: 12px; }
.spread { justify-content: space-between; }
.wrap { flex-wrap: wrap; }

.stat { padding: 16px; }
.stat .label { color: var(--ink3); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.7rem; font-weight: 800; margin-top: 4px; }
.stat .sub { color: var(--ink2); font-size: .85rem; margin-top: 4px; }

/* ===== tables ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th { text-align: left; padding: 10px 12px; color: var(--ink3); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:hover td { background: var(--surface2); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.badge-green { background: var(--brand-soft); color: var(--brand-dark); }
.badge-gray { background: var(--surface3); color: var(--ink2); }
.badge-blue { background: #e0edf7; color: var(--brand2); }
.badge-amber { background: #fdf0d8; color: var(--warn); }
.badge-red { background: #fde5e5; color: var(--danger); }
.badge-purple { background: #efe9fc; color: var(--ribbon); }

/* ===== forms ===== */
.field { margin-bottom: 14px; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--surface); color: var(--ink); font: 500 .95rem var(--font);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }

/* ===== toasts ===== */
#toasts { position: fixed; top: 76px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 12px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); min-width: 260px; animation: slidein .25s ease; }
.toast.ok { border-left: 4px solid var(--ok); }
.toast.err { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--brand2); }
@keyframes slidein { from { transform: translateX(30px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ===== timeline / feed ===== */
.feed { display: flex; flex-direction: column; gap: 10px; }
.feed-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.feed-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand); margin-top: 6px; flex: none; }
.feed-dot.pending { background: var(--warn); }
.feed-dot.reversed { background: var(--danger); }
.feed-main { flex: 1; }
.feed-amount { font-weight: 800; }

/* ===== tree ===== */
#tree-wrap { overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.tree-node { fill: var(--brand-soft); stroke: var(--brand); }
.tree-node.muted { fill: var(--surface3); stroke: var(--ink3); }
.tree-label { font-size: 11px; fill: var(--ink); }
.tree-fee { font-size: 10px; fill: var(--ink3); }

/* ===== hero / landing ===== */
.hero { padding: 60px 0 40px; background: radial-gradient(1200px 500px at 70% -10%, color-mix(in srgb, var(--brand) 18%, transparent), transparent); }
.hero h1 { font-size: clamp(1.8rem, 4vw, 3rem); font-weight: 900; }
.hero p { color: var(--ink2); font-size: 1.1rem; max-width: 640px; }
.big-number { font-size: 2rem; font-weight: 900; }

/* ===== modal ===== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8,10,20,.55); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: var(--surface); border-radius: 18px; padding: 24px; width: 100%; max-width: 560px; max-height: 86vh; overflow: auto; box-shadow: var(--shadow); animation: pop .2s ease; }
@keyframes pop { from { transform: scale(.97); opacity: 0 } to { transform: none; opacity: 1 } }

/* ===== misc ===== */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--surface3); color: var(--ink2); font-size: .78rem; font-weight: 600; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.hide { display: none !important; }
.tabbar { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 18px; flex-wrap: wrap; }
.tab { padding: 9px 14px; border-radius: 10px 10px 0 0; cursor: pointer; font-weight: 600; color: var(--ink2); border-bottom: 2px solid transparent; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); background: var(--brand-soft); }
.loader { display: inline-block; width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg) } }
@media (max-width: 720px) {
  .topbar .container { gap: 8px; }
  .nav a { font-size: .8rem; padding: 6px 8px; }
  .hide-m { display: none !important; }
}
