/* DeliveryManager - styles */
:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1a202c;
    --muted: #64748b;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --new: #64748b;
    --progress: #f59e0b;
    --ready: #10b981;
    --missing: #ef4444;
    --delivered: #10b981;
    --overdue: #dc2626;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* Header */
.app-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}
.app-header__inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}
.brand {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary);
    text-decoration: none;
}
.app-nav { display: flex; gap: 1rem; flex: 1; }
.app-nav a { color: var(--text); text-decoration: none; }
.app-nav a:hover { color: var(--primary); }
.user-box { display: flex; align-items: center; gap: 0.5rem; }
.user-box__name { font-weight: 600; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

.app-footer {
    text-align: center;
    color: var(--muted);
    padding: 1rem;
}

/* Links / buttons */
.link-secondary { color: var(--muted); text-decoration: none; font-size: 0.9rem; }
.link-secondary:hover { color: var(--primary); }

.btn {
    display: inline-block;
    padding: 0.45rem 0.85rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
    cursor: pointer;
}
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); }
.btn--secondary { background: #eef2ff; border-color: #c7d2fe; color: var(--primary-dark); }
.btn--ghost { background: transparent; }

/* Flash */
.flash {
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    color: var(--primary-dark);
    padding: 0.6rem 0.85rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}
.flash--error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }

/* Login */
.login-card {
    max-width: 380px;
    margin: 4rem auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 2rem;
}

/* Forms */
.form { display: grid; gap: 0.85rem; max-width: 480px; }
.form--inline { align-items: end; }
.form label { display: grid; gap: 0.25rem; font-size: 0.9rem; color: var(--muted); }
.form input, .form select, .form textarea {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    background: var(--surface);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    background: var(--border);
    color: var(--text);
}
.badge--role { background: #e0e7ff; color: var(--primary-dark); }
.badge--email { background: #fef3c7; color: #92400e; }
.badge--text { background: #e2e8f0; color: var(--text); }

/* Sections */
.section { margin-bottom: 2.5rem; }
.section__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.section h2 { margin: 0; font-size: 1.25rem; }

.empty { color: var(--muted); font-style: italic; }

/* Project / department grouping */
details.project {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-bottom: 1rem;
    padding: 0 1rem 1rem;
}
summary.project__title {
    padding: 0.85rem 0;
    cursor: pointer;
    font-weight: 600;
    font-size: 1.05rem;
}
.department { margin-top: 0.5rem; }
.department__title {
    font-size: 0.95rem;
    color: var(--muted);
    margin: 0.75rem 0 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.table th, .table td {
    text-align: left;
    padding: 0.55rem 0.6rem;
    border-bottom: 1px solid var(--border);
}
.table th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.table tbody tr:hover { background: #f8fafc; }

/* Status indication on rows */
tr.is-new td:first-child { border-left: 4px solid var(--new); }
tr.is-progress td:first-child { border-left: 4px solid var(--progress); }
tr.is-ready td:first-child { border-left: 4px solid var(--ready); }
tr.is-missing td:first-child { border-left: 4px solid var(--missing); background: #fef2f2; }
tr.is-delivered td:first-child { border-left: 4px solid var(--delivered); }
tr.is-overdue td:first-child { border-left: 4px solid var(--overdue); }

.state-badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--border);
}
.state-badge--lg { font-size: 0.85rem; }

/* Progress bar */
.progress {
    width: 120px;
    height: 8px;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}
.progress__bar {
    height: 100%;
    background: var(--primary);
    transition: width 0.2s;
}

/* Detail page */
.detail-head { display: flex; align-items: center; gap: 1rem; margin: 1rem 0; }
.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}
.meta-grid dt { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; }
.meta-grid dd { margin: 0; font-weight: 500; }

.callout {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1.5rem;
}
.callout--warn { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline__item {
    border-left: 2px solid var(--border);
    padding: 0.5rem 0 0.75rem 1rem;
    margin-bottom: 0.5rem;
}
.timeline__meta { display: flex; gap: 0.75rem; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.25rem; align-items: center; }
.timeline__comment { font-size: 0.9rem; }

.error-page { text-align: center; margin-top: 4rem; }
.error-page h1 { font-size: 4rem; margin: 0; color: var(--muted); }

/* Forms - extra helpers */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
}
.form .grid-2 { margin-bottom: 0.25rem; }
.muted { color: var(--muted); font-size: 0.9rem; }
.hint {
    margin-top: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 1rem;
}
.hint summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; }
.hint pre {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.75rem;
    overflow-x: auto;
    font-size: 0.85rem;
}

/* Dashboard department (Gewerk) filter */
.filter-form { gap: 0; }
.filter-form label { display: grid; gap: 0.2rem; font-size: 0.8rem; }
.filter-form select { width: auto; min-width: 220px; padding: 0.35rem 0.5rem; }

/* Row action cells (Edit / Delete buttons) */
td.actions { display: flex; gap: 0.4rem; align-items: center; }
.form-inline { display: inline; margin: 0; }

/* Danger button variant */
.btn--danger { color: var(--overdue); border-color: #fecaca; }
.btn--danger:hover { background: #fef2f2; }

/* Header actions (Export menu + user box) */
.app-header__actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Dropdown menu (used by the Export entry in the header) */
.menu { position: relative; }
.menu__trigger {
    cursor: pointer;
    list-style: none;
    font-size: 0.9rem;
    color: var(--text);
    padding: 0.3rem 0.2rem;
    user-select: none;
}
.menu__trigger::-webkit-details-marker { display: none; }
.menu__trigger:hover { color: var(--primary); }
.menu[open] .menu__trigger { color: var(--primary); }
.menu__panel {
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 220px;
    margin-top: 0.35rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    padding: 0.3rem;
    z-index: 20;
}
.menu__item {
    display: block;
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.9rem;
}
.menu__item:hover { background: #eef2ff; color: var(--primary-dark); }

/* Due-date highlighting */
.due {
    white-space: nowrap;
    border-radius: 6px;
    padding: 0.1rem 0.35rem;
    display: inline-block;
    font-size: 0.82rem;
    font-weight: 600;
}
.due--soon {
    background: #fef3c7;
    color: #92400e;
}
.due--overdue {
    background: #fee2e2;
    color: #b91c1c;
}

/* Searchable selects */
.combobox { position: relative; }
.combobox__input {
    width: 100%;
    padding: 0.5rem 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    background: var(--surface);
    box-sizing: border-box;
}
.combobox__list {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    max-height: 220px;
    overflow-y: auto;
    margin: 0.25rem 0 0;
    padding: 0;
    list-style: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
    z-index: 20;
}
.combobox__option {
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    font-size: 0.9rem;
}
.combobox__option:hover,
.combobox__option--active { background: #eef2ff; color: var(--primary-dark); }
.combobox__option--empty { color: var(--muted); font-style: italic; }
.combobox__list[hidden] { display: none; }

/* Account menu (avatar + name + caret trigger, identity panel) */
.menu--account { margin-left: 0.25rem; }
.account-trigger {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    list-style: none;
    padding: 0.2rem 0.35rem 0.2rem 0.2rem;
    border-radius: 999px;
    border: 1px solid transparent;
    user-select: none;
}
.account-trigger:hover { border-color: var(--border); background: #f8fafc; }
.account-trigger::-webkit-details-marker { display: none; }
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    line-height: 1;
}
.account-trigger__label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    max-width: 12ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.account-trigger__caret {
    font-size: 0.8rem;
    color: var(--muted);
}
.menu--account[open] .account-trigger { border-color: var(--border); background: #f8fafc; }
.account-panel { min-width: 200px; }
.account-panel__identity {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.25rem;
}
.account-panel__name {
    font-weight: 600;
    font-size: 0.9rem;
    max-width: 11ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
