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

:root {
    --blue:    #2563eb;
    --blue-dk: #1d4ed8;
    --green:   #16a34a;
    --red:     #dc2626;
    --amber:   #d97706;
    --bg:      #f1f5f9;
    --card:    #ffffff;
    --border:  rgba(100,116,139,.18);
    --text:    #1e293b;
    --muted:   #64748b;
    --input-bg:#f8fafc;
    --radius:  12px;
    --safe-b:  env(safe-area-inset-bottom, 0px);
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 16px; line-height: 1.5; -webkit-text-size-adjust: 100%; }

/* ── Topbar ── */
.topbar { position: sticky; top: 0; z-index: 100; background: var(--blue); color: #fff; display: flex; align-items: center; padding: 0 16px; height: 56px; gap: 12px; }
.topbar__logo { font-weight: 800; font-size: 18px; letter-spacing: -.5px; flex: 1; }
.topbar__tenant { font-size: 11px; font-weight: 700; background: rgba(255,255,255,.2); padding: 3px 9px; border-radius: 20px; text-transform: uppercase; letter-spacing: .05em; }
.topbar__btn { background: none; border: none; color: #fff; cursor: pointer; padding: 8px; border-radius: 8px; font-size: 13px; display: flex; align-items: center; gap: 4px; }
.topbar__btn:active { background: rgba(255,255,255,.15); }

/* ── Content ── */
.content { padding: 16px 16px calc(16px + var(--safe-b)); max-width: 600px; margin: 0 auto; }

/* ── Cards ── */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-bottom: 12px; }
.card__title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 16px; }

/* ── Form fields ── */
.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
    width: 100%; padding: 12px 14px; border: 1.5px solid var(--border);
    border-radius: 10px; font-size: 16px; background: var(--input-bg);
    color: var(--text); font-family: inherit; appearance: none;
    transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--blue); background: #fff;
}
.field textarea { resize: vertical; min-height: 80px; }
.field .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Email status ── */
.email-wrap { position: relative; }
.email-spinner { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--blue); border-radius: 50%; display: none; }
.email-spinner.active { display: block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }

/* ── Duplicate panel ── */
.dup-panel { display: none; background: rgba(220,38,38,.05); border: 1.5px solid rgba(220,38,38,.25); border-radius: 10px; padding: 16px; margin-top: 8px; }
.dup-panel.visible { display: block; }
.dup-head { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--red); margin-bottom: 10px; }
.dup-name { font-size: 18px; font-weight: 700; margin-bottom: 2px; }
.dup-firma { font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.dup-badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 2px 9px; border-radius: 20px; margin-bottom: 12px; }
.dup-badge.lead { background: rgba(37,99,235,.1); color: var(--blue); }
.dup-badge.kunde { background: rgba(22,163,74,.1); color: var(--green); }
.dup-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 13px 20px; border-radius: 10px; font-size: 15px; font-weight: 700; cursor: pointer; border: none; font-family: inherit; text-decoration: none; transition: opacity .15s; }
.btn:active { opacity: .8; }
.btn-primary { background: var(--blue); color: #fff; width: 100%; }
.btn-secondary { background: var(--card); color: var(--text); border: 1.5px solid var(--border); }
.btn-danger-outline { background: transparent; color: var(--red); border: 1.5px solid rgba(220,38,38,.3); }
.btn-sm { padding: 9px 14px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ── Quick action tiles on index ── */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.tile { background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius); padding: 20px 16px; text-decoration: none; color: var(--text); display: flex; flex-direction: column; align-items: flex-start; gap: 8px; transition: border-color .15s; }
.tile:active { border-color: var(--blue); background: rgba(37,99,235,.04); }
.tile__icon { font-size: 28px; line-height: 1; }
.tile__label { font-size: 13px; font-weight: 700; }
.tile__desc { font-size: 11px; color: var(--muted); }
.tile.accent { border-color: var(--blue); background: rgba(37,99,235,.04); }
.tile.accent .tile__label { color: var(--blue); }

/* ── Toast ── */
.toast { position: fixed; bottom: calc(20px + var(--safe-b)); left: 50%; transform: translateX(-50%); background: var(--text); color: #fff; padding: 12px 20px; border-radius: 10px; font-size: 14px; font-weight: 600; white-space: nowrap; z-index: 999; box-shadow: 0 4px 16px rgba(0,0,0,.2); animation: toastin .25s ease; }
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }
@keyframes toastin { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* ── Alert / error box ── */
.alert { border-radius: 10px; padding: 12px 16px; margin-bottom: 16px; font-size: 14px; font-weight: 600; }
.alert.error { background: rgba(220,38,38,.08); color: var(--red); border: 1px solid rgba(220,38,38,.2); }
.alert.success { background: rgba(22,163,74,.08); color: var(--green); border: 1px solid rgba(22,163,74,.2); }

/* ── Success state ── */
.success-view { text-align: center; padding: 40px 20px; }
.success-view__icon { font-size: 64px; margin-bottom: 16px; }
.success-view__title { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.success-view__sub { font-size: 15px; color: var(--muted); margin-bottom: 32px; }
.success-view .actions { display: flex; flex-direction: column; gap: 10px; }

/* ── Login page ── */
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.login-logo { font-size: 32px; font-weight: 900; color: var(--blue); letter-spacing: -1px; margin-bottom: 8px; }
.login-sub { font-size: 13px; color: var(--muted); margin-bottom: 32px; text-align: center; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 24px; width: 100%; max-width: 380px; }
.login-card .field { margin-bottom: 14px; }
.login-title { font-size: 18px; font-weight: 800; margin-bottom: 20px; }
.login-footer { text-align: center; margin-top: 20px; font-size: 13px; color: var(--muted); }
.login-reason { background: rgba(220,38,38,.07); border: 1px solid rgba(220,38,38,.2); border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 13px; color: var(--red); font-weight: 600; }
