/* ============================================
   Safunity – Design (Release 0.2.0)
   ============================================ */
:root {
    --primary: #0e7a5f;
    --primary-dark: #0a5c48;
    --primary-light: #e2f4ec;
    --accent: #35c99e;
    --navy: #10222f;
    --navy-2: #143441;
    --bg: #f2f6f5;
    --card: #ffffff;
    --text: #1f2d38;
    --muted: #64737f;
    --border: #e1e8e5;
    --danger: #c0392b;
    --warning-bg: #fdf3d7;
    --warning-text: #7a5d00;
    --success-bg: #e2f4ec;
    --success-text: #0e6b47;
    --error-bg: #fbe4e1;
    --error-text: #9a2c1f;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(16, 34, 47, .07), 0 4px 14px rgba(16, 34, 47, .04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a { color: var(--primary); }

/* ---------- Kopfzeile ---------- */
.topbar {
    background: linear-gradient(120deg, var(--navy) 0%, var(--navy-2) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    min-height: 62px;
    flex-wrap: wrap;
    gap: 8px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .18);
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: .3px;
}
.brand-icon { width: 26px; height: 26px; color: var(--accent); }
.mainnav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.mainnav a {
    color: #cfdde6;
    text-decoration: none;
    padding: 8px 13px;
    border-radius: 8px;
    font-size: .95rem;
    transition: background .15s, color .15s;
}
.mainnav a:hover { background: rgba(255, 255, 255, .12); color: #fff; }
.nav-user { color: #8fd8c2 !important; }

/* ---------- Layout ---------- */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 20px 48px;
    flex: 1;
}
.footer {
    text-align: center;
    color: var(--muted);
    font-size: .85rem;
    padding: 18px;
    border-top: 1px solid var(--border);
    background: #fff;
}
h1 { font-size: 1.6rem; margin: 0 0 10px; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; margin: 0; letter-spacing: -.01em; }
h3 { margin-top: 0; }
.muted { color: var(--muted); font-size: .92rem; }
.center { text-align: center; }

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
}
.page-head p { margin: 0; }

/* ---------- Karten & Grids ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}
.card-narrow { max-width: 520px; margin: 24px auto; }
.feature-grid, .stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}
.stat-grid { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 20px; }
.grid-2 {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 16px;
    align-items: start;
}
@media (max-width: 800px) { .grid-2 { grid-template-columns: 1fr; } }
.stat { text-align: center; }
.stat-num { display: block; font-size: 2rem; font-weight: 700; color: var(--primary); }

/* ---------- Startseite ---------- */
.hero { text-align: center; padding: 52px 12px 34px; }
.hero h1 { font-size: 2.4rem; margin-bottom: 10px; }
.hero-sub { max-width: 620px; margin: 0 auto 24px; color: var(--muted); font-size: 1.05rem; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- Formulare ---------- */
label { display: block; margin-bottom: 14px; font-weight: 600; font-size: .92rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="search"], select {
    display: block;
    width: 100%;
    margin-top: 5px;
    padding: 10px 12px;
    font-size: 1rem;
    font-weight: 400;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(14, 122, 95, .15);
}
input:disabled { background: var(--bg); color: var(--muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.checkbox input { width: auto; margin-top: 3px; }
.form-actions { display: flex; gap: 10px; }
.input-inline { display: inline-block; width: auto; margin-top: 0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    padding: 9px 16px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: #fff;
    color: var(--text);
    font-size: .95rem;
    font-family: inherit;
    text-decoration: none;
    cursor: pointer;
    transition: all .15s;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #0c8f6d 100%);
    border-color: transparent;
    color: #fff;
    font-weight: 600;
    box-shadow: 0 2px 6px rgba(14, 122, 95, .3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(14, 122, 95, .35);
}
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: var(--error-bg); color: var(--danger); }
.btn-block { width: 100%; }
.btn-small { padding: 5px 10px; font-size: .85rem; border-radius: 7px; }
button:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }

/* ---------- Tabellen ---------- */
.table-card { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th {
    background: #f7faf9;
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    position: sticky;
    top: 0;
}
tbody tr { transition: background .1s; }
tbody tr:hover { background: #f7fbf9; }
tr:last-child td { border-bottom: none; }
.actions { white-space: nowrap; }
.inline { display: inline-block; margin: 0; }
.dept-rename { display: flex; align-items: center; gap: 6px; }
.dept-indent { color: var(--muted); }

tr.dragging { opacity: .45; }
.drag-handle { cursor: grab; color: var(--muted); user-select: none; }

/* ---------- Badges & Meldungen ---------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: .8rem;
    font-weight: 600;
    background: var(--bg);
    color: var(--muted);
}
.badge-active { background: var(--success-bg); color: var(--success-text); }
.badge-invited { background: var(--warning-bg); color: var(--warning-text); }
.badge-inactive { background: var(--error-bg); color: var(--error-text); }

.flash {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 14px;
    font-size: .95rem;
}
.flash-success { background: var(--success-bg); color: var(--success-text); }
.flash-error { background: var(--error-bg); color: var(--error-text); }
.flash-warning { background: var(--warning-bg); color: var(--warning-text); }

.searchbar { display: flex; gap: 8px; max-width: 420px; }
.searchbar input { margin-top: 0; }

/* ---------- Unternehmensseite ---------- */
.company-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 18px;
    align-items: start;
}
@media (max-width: 860px) { .company-layout { grid-template-columns: 1fr; } }

.sidebar { padding: 14px; position: sticky; top: 78px; max-height: calc(100vh - 100px); overflow: auto; }
.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: .92rem;
    padding: 4px 6px 12px;
}

.tree, .tree-children { list-style: none; margin: 0; padding: 0; }
.tree-children { padding-left: 20px; }
.tree-node { margin: 1px 0; }
.tree-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 8px;
    border-radius: 9px;
    cursor: pointer;
    font-size: .93rem;
    border: 2px solid transparent;
    transition: background .12s, border-color .12s;
    user-select: none;
}
.tree-item:hover { background: #f0f6f3; }
.tree-item.selected { background: var(--primary-light); font-weight: 600; }
.tree-item.dragging { opacity: .45; }
.tree-item.drop-hover { border-color: var(--primary); background: var(--primary-light); }
.tree-toggle {
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
    width: 16px;
    color: var(--muted);
    font-size: .8rem;
    flex-shrink: 0;
}
.tree-toggle.invisible { visibility: hidden; }
.tree-icon { flex-shrink: 0; font-size: .9rem; }
.tree-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-count {
    background: #edf3f0;
    color: var(--muted);
    border-radius: 20px;
    padding: 1px 8px;
    font-size: .76rem;
    font-weight: 600;
    flex-shrink: 0;
}
.tree-item.selected .tree-count { background: #fff; }
.tree-actions { display: none; gap: 2px; flex-shrink: 0; }
.tree-item:hover .tree-actions { display: inline-flex; }
.tree-actions button {
    border: none;
    background: none;
    cursor: pointer;
    color: var(--muted);
    font-size: .9rem;
    padding: 0 4px;
    border-radius: 5px;
}
.tree-actions button:hover { background: #fff; color: var(--primary); }
.tree-loading { padding: 8px; }

.list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
}
.pag-info { color: var(--muted); font-size: .88rem; margin-right: auto; }

/* ---------- Toasts ---------- */
.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;
    background: var(--navy);
    color: #fff;
    padding: 12px 18px;
    border-radius: 10px;
    font-size: .93rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .25);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity .3s, transform .3s;
    z-index: 200;
    max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--danger); }
