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

:root {
    --bg: #f5f5f0;
    --surface: #ffffff;
    --border: #e0e0d8;
    --accent: #2c2c2c;
    --accent-hover: #444;
    --text: #222;
    --muted: #777;
    --danger: #c0392b;
    --success: #27ae60;
    --radius: 8px;
    --shadow: 0 1px 6px rgba(0,0,0,0.07);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
       background: var(--bg); color: var(--text); margin: 0; font-size: 15px; line-height: 1.6; }

/* ─── Header ─────────────────────────────────────────────────────────────── */
header { background: var(--surface); border-bottom: 1px solid var(--border);
         padding: 0 1.5rem; display: flex; align-items: center; justify-content: space-between;
         height: 52px; box-shadow: var(--shadow); position: sticky; top: 0; z-index: 10; }

header h1 { margin: 0; font-size: 1.1rem; font-weight: 700; color: var(--accent); letter-spacing: -0.01em; }

header nav { display: flex; align-items: center; gap: 0.3rem; }

.nav-btn { background: none; border: none; padding: 0.35rem 0.75rem; border-radius: 6px;
           cursor: pointer; font-size: 0.9rem; color: var(--muted); font-weight: 500;
           transition: background 0.15s, color 0.15s; }
.nav-btn:hover { background: #f0f0ec; color: var(--accent); }
.nav-btn.active { background: #e8e8e4; color: var(--accent); font-weight: 600; }

.nav-sep { color: var(--border); margin: 0 0.2rem; }
.nav-user { font-size: 0.85rem; color: var(--muted); }
.nav-link { font-size: 0.85rem; color: var(--muted); text-decoration: none; padding: 0.3rem 0.5rem; }
.nav-link:hover { color: var(--accent); }

/* ─── Layout ─────────────────────────────────────────────────────────────── */
.container { max-width: 1000px; margin: 0 auto; padding: 1.5rem 1rem; }

.section { display: none; }
.section.active { display: block; }

/* ─── Toolbar ────────────────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.toolbar h2 { margin: 0; font-size: 1.2rem; }
.toolbar-actions { display: flex; gap: 0.5rem; }

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 0.3rem;
       background: var(--surface); color: var(--accent); border: 1px solid var(--border);
       padding: 0.4rem 0.9rem; border-radius: 6px; font-size: 0.9rem; cursor: pointer;
       text-decoration: none; transition: background 0.15s, border-color 0.15s; }
.btn:hover { background: #f0f0ec; border-color: #ccc; }

.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-sm { background: none; border: none; padding: 0.2rem 0.4rem; cursor: pointer;
           font-size: 1rem; border-radius: 4px; opacity: 0.7; transition: opacity 0.15s; }
.btn-sm:hover { opacity: 1; background: #f0f0ec; }
.btn-sm.danger { color: var(--danger); }

button, input[type=submit] { font-family: inherit; }

/* ─── Inputs ─────────────────────────────────────────────────────────────── */
.input, input[type=email], input[type=password], input[type=text] {
    width: 100%; max-width: 340px; padding: 0.45rem 0.75rem;
    border: 1px solid var(--border); border-radius: 6px; font-size: 0.95rem;
    background: var(--surface); transition: border-color 0.2s; }
.input:focus, input:focus { outline: none; border-color: #888; }

label { font-weight: 500; }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        padding: 1.2rem; box-shadow: var(--shadow); margin-bottom: 1rem; }

/* ─── Dokument-Grid ──────────────────────────────────────────────────────── */
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 0.8rem; }

.doc-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
            padding: 0.8rem; cursor: default; transition: box-shadow 0.15s, border-color 0.15s;
            display: flex; flex-direction: column; align-items: center; text-align: center; position: relative; }
.doc-card:hover { box-shadow: 0 3px 12px rgba(0,0,0,0.1); border-color: #ccc; }

.doc-icon { font-size: 2.5rem; margin-bottom: 0.4rem; }
.doc-name { font-size: 0.82rem; font-weight: 500; word-break: break-word;
            overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
            -webkit-line-clamp: 2; -webkit-box-orient: vertical; max-height: 2.8em; }
.doc-date { font-size: 0.75rem; color: var(--muted); margin-top: 0.3rem; }
.doc-actions { display: none; position: absolute; top: 6px; right: 6px; flex-direction: column; gap: 2px; }
.doc-card:hover .doc-actions { display: flex; }

/* ─── Breadcrumb ─────────────────────────────────────────────────────────── */
.breadcrumb { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.8rem;
              font-size: 0.9rem; }
.crumb { color: var(--accent); cursor: pointer; text-decoration: underline; text-decoration-color: transparent;
         transition: text-decoration-color 0.15s; }
.crumb:hover { text-decoration-color: var(--accent); }
.crumb-sep { color: var(--muted); }

/* ─── Pairing-Code ───────────────────────────────────────────────────────── */
.pairing-code { font-size: 3rem; letter-spacing: 0.35em; font-weight: 700; font-family: monospace;
                text-align: center; padding: 1rem 1.5rem; border: 2px solid var(--border);
                border-radius: var(--radius); display: inline-block; }

/* ─── Tabellen ───────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; background: var(--surface);
        border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); margin-bottom: 1.5rem; }
thead { background: #f0f0ec; }
th, td { padding: 0.6rem 0.9rem; text-align: left; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafaf8; }
code { font-size: 0.8rem; background: #f0f0ec; padding: 0.1rem 0.3rem; border-radius: 3px; }

/* ─── Formulare ──────────────────────────────────────────────────────────── */
form { background: var(--surface); padding: 1.4rem; border-radius: var(--radius);
       box-shadow: var(--shadow); max-width: 420px; margin-bottom: 1.5rem; }

/* ─── Upload-Progress ────────────────────────────────────────────────────── */
.progress-bar { width: 100%; height: 4px; background: #e0e0e0; border-radius: 2px; margin-top: 0.5rem; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px;
                 width: 0; transition: width 0.3s; animation: progress-anim 1.5s infinite; }
@keyframes progress-anim { 0%{width:0} 50%{width:70%} 100%{width:100%} }

/* ─── Messages ───────────────────────────────────────────────────────────── */
.error   { color: var(--danger);  font-weight: 500; padding: 0.4rem 0; }
.success { color: var(--success); font-weight: 500; padding: 0.4rem 0; }
.empty   { color: var(--muted); padding: 1rem 0; }

/* ─── Modal ──────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); display: flex;
         align-items: center; justify-content: center; z-index: 100; }
.modal-content { background: var(--surface); border-radius: var(--radius);
                 padding: 1.5rem; max-width: 480px; width: 90%; box-shadow: 0 8px 32px rgba(0,0,0,0.2); }

/* ─── Login/Register-Form ────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
              background: var(--bg); }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
              padding: 2rem; width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.login-card h1 { margin-top: 0; font-size: 1.4rem; }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .doc-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
    header nav { gap: 0.1rem; }
    .nav-btn { padding: 0.3rem 0.5rem; font-size: 0.8rem; }
}
