:root {
    --bg: #0e0f12;
    --bg-soft: #161820;
    --panel: #1b1e28;
    --panel-2: #20242f;
    --line: #2a2f3d;
    --text: #e8eaf0;
    --muted: #8a91a3;
    --accent: #ff7a1a;
    --accent-2: #ffb066;
    --danger: #ff4d4d;
    --warn: #f5b840;
    --ok: #34d39a;
    --master: #b388ff;     /* lila — auffaellig, einmalig */
    --trading: #34d39a;    /* gruen — operativ */
    --fee: #5cb8ff;        /* hellblau — fees */
    --shadow: 0 8px 30px rgba(0, 0, 0, 0.45);
    --radius: 10px;
    --radius-lg: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: radial-gradient(1200px 800px at 20% -10%, rgba(255, 122, 26, 0.08), transparent 60%), var(--bg);
    color: var(--text);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}
button, input, textarea, select {
    font: inherit;
    color: inherit;
}

a { color: var(--accent-2); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; }
.warn { color: var(--warn); margin: 0 0 8px; }

/* ── Topbar ── */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 22px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent);
    position: sticky;
    top: 0;
    z-index: 5;
    backdrop-filter: blur(8px);
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    letter-spacing: 0.4px;
}
.brand .dot, .login-brand .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}
.brand strong, .login-brand strong { color: var(--accent); }
.topbar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Container ── */
.container {
    max-width: 1320px;
    margin: 18px auto;
    padding: 0 22px 80px;
}

/* ── Summary ── */
.summary-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}
.summary-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px 14px;
}
.summary-label {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 2px;
}
.summary-value {
    font-size: 20px;
    font-weight: 600;
}

/* ── Category Sections ── */
.cat-section {
    margin-bottom: 22px;
}
.cat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 4px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--line);
}
.cat-title {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.3px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.cat-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
}
.cat-count {
    color: var(--muted);
}
.cat-count::before { content: ''; }
.cat-count::after { content: ' Wallets'; color: var(--muted); }
.cat-total {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 600;
}

/* Category Badges */
.cat-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 10px;
    letter-spacing: 1.2px;
    font-weight: 700;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--bg-soft);
}
.cat-master  { color: var(--master);  border-color: rgba(179, 136, 255, 0.5); }
.cat-trading { color: var(--trading); border-color: rgba(52, 211, 154, 0.4); }
.cat-fee     { color: var(--fee);     border-color: rgba(92, 184, 255, 0.4); }

.cat-empty {
    color: var(--muted);
    font-size: 13px;
    padding: 10px 12px;
    border: 1px dashed var(--line);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.02);
}

/* ── Wallet Rows (compact) ── */
.cat-rows {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.wrow {
    display: grid;
    grid-template-columns: minmax(140px, 220px) 1fr 130px auto;
    align-items: center;
    gap: 12px;
    padding: 7px 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    transition: border-color .12s, background .12s;
}
.wrow:hover {
    border-color: rgba(255, 122, 26, 0.4);
    background: var(--panel-2);
}
.wrow-label {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wrow-pub {
    color: var(--muted);
    font-size: 12px;
    cursor: copy;
    padding: 4px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bg-soft);
    transition: border-color .12s, color .12s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: 0.2px;
}
.wrow-pub:hover {
    border-color: var(--accent);
    color: var(--text);
}
.wrow-bal {
    text-align: right;
    font-weight: 600;
    font-size: 14px;
}
.wrow-bal .unit {
    font-size: 11px;
    color: var(--muted);
    margin-left: 4px;
    font-weight: 500;
}
.wrow-actions {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}

/* enges layout fuer schmale screens */
@media (max-width: 900px) {
    .wrow {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "label bal"
            "pub   pub"
            "actions actions";
        gap: 6px;
    }
    .wrow-label { grid-area: label; }
    .wrow-bal { grid-area: bal; }
    .wrow-pub { grid-area: pub; }
    .wrow-actions { grid-area: actions; justify-content: flex-start; }
}

/* ── Buttons ── */
.btn {
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 7px 12px;
    cursor: pointer;
    font-weight: 500;
    transition: background .15s, border-color .15s, color .15s, transform .05s;
    line-height: 1.2;
    white-space: nowrap;
    font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn.primary {
    background: var(--accent);
    color: #1a0f00;
    border-color: var(--accent);
    font-weight: 600;
}
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost {
    background: transparent;
    border-color: var(--line);
}
.btn.danger {
    color: var(--danger);
    border-color: rgba(255, 77, 77, 0.4);
}
.btn.danger:hover { background: rgba(255, 77, 77, 0.1); border-color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; }

.icon-btn {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--panel-2);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    transition: border-color .12s, color .12s, background .12s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-btn.danger { color: var(--danger); border-color: rgba(255, 77, 77, 0.35); }
.icon-btn.danger:hover { background: rgba(255, 77, 77, 0.1); border-color: var(--danger); color: var(--danger); }

/* ── Modals ── */
.modal {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 0;
    box-shadow: var(--shadow);
    max-width: 500px;
    width: 92vw;
}
.modal::backdrop {
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(2px);
}
.modal-form {
    padding: 22px 22px 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
}
.modal-form h2 {
    margin: 0 0 4px;
    font-size: 18px;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 6px;
}

/* Form fields */
.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.field .label {
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}
.field input,
.field textarea,
.field select {
    background: var(--bg-soft);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 8px;
    padding: 10px 12px;
    width: 100%;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14px;
}
.field select {
    font-family: inherit;
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                      linear-gradient(135deg, var(--muted) 50%, transparent 50%);
    background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    cursor: pointer;
}
.field textarea {
    resize: vertical;
    min-height: 64px;
    line-height: 1.4;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(255, 122, 26, 0.15);
}

.kv {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 8px;
    align-items: start;
    padding: 6px 0;
    border-bottom: 1px solid var(--line);
}
.kv:last-of-type { border-bottom: 0; }
.kv-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.6px; }
.kv-value { word-break: break-all; }

.error {
    color: var(--danger);
    background: rgba(255, 77, 77, 0.08);
    border: 1px solid rgba(255, 77, 77, 0.35);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
}
.status {
    background: rgba(52, 211, 154, 0.08);
    border: 1px solid rgba(52, 211, 154, 0.35);
    color: var(--ok);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    word-break: break-all;
}
.status.error {
    background: rgba(255, 77, 77, 0.08);
    border-color: rgba(255, 77, 77, 0.35);
    color: var(--danger);
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--panel-2);
    border: 1px solid var(--accent);
    color: var(--text);
    padding: 10px 16px;
    border-radius: 999px;
    box-shadow: var(--shadow);
    z-index: 100;
    font-size: 14px;
}
.toast.error { border-color: var(--danger); color: var(--danger); }

/* Login page */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 22px;
}
.login-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 28px 28px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow);
}
.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    margin-bottom: 6px;
}
.login-card form {
    margin-top: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
