/* ============================================================
   MBS Todos — Design System
   Light mode default, dark mode via [data-theme="dark"]
   ============================================================ */

/* --- Custom Properties ------------------------------------ */
:root {
    /* Brand */
    --color-base:    #1a2642;
    --color-primary: #ef7e07;

    /* Surfaces */
    --color-bg:      #f4f5f7;
    --color-surface: #ffffff;
    --color-surface-2: #f0f2f5;

    /* Text */
    --color-text:       #1a2642;
    --color-text-muted: #6b7280;
    --color-text-on-base: #ffffff;

    /* Border */
    --color-border: #e2e5ea;

    /* Status */
    --color-open:        #3b82f6;
    --color-in-progress: #ef7e07;
    --color-done:        #2d8a4e;
    --color-overdue:     #c0392b;
    --color-cancelled:   #9ca3af;

    /* Sidebar */
    --sidebar-width: 240px;

    /* Spacing scale */
    --s-1: 4px;
    --s-2: 8px;
    --s-3: 12px;
    --s-4: 16px;
    --s-5: 24px;
    --s-6: 32px;
    --s-7: 48px;

    /* Typography */
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', Consolas, monospace;
    --radius: 8px;
    --radius-sm: 4px;

    /* Shadow */
    --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
    --shadow:    0 4px 12px rgba(0,0,0,.08);

    /* Transition */
    --transition: 150ms ease;
}

[data-theme="dark"] {
    --color-bg:        #0f1623;
    --color-surface:   #1a2642;
    --color-surface-2: #212f4d;
    --color-text:      #e8ecf0;
    --color-text-muted:#9ca3af;
    --color-text-on-base: #e8ecf0;
    --color-border:    #2d3a52;

    --shadow-sm: 0 1px 3px rgba(0,0,0,.3);
    --shadow:    0 4px 12px rgba(0,0,0,.4);

    color-scheme: dark;
}

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

html { font-size: 15px; }

body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.55;
    transition: background var(--transition), color var(--transition);
    min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img, svg { display: block; max-width: 100%; }

/* --- Layout ----------------------------------------------- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar ---------------------------------------------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--color-base);
    color: var(--color-text-on-base);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-logo {
    padding: var(--s-5) var(--s-5) var(--s-4);
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-logo svg {
    width: 120px;
    height: auto;
}

/* Invert logo text to white in sidebar */
.sidebar-logo svg .cls-2 { fill: #ffffff !important; }

.sidebar-logo__subtitle {
    margin-top: var(--s-2);
    font-size: .75rem;
    font-weight: 600;
    color: rgba(255,255,255,.5);
    letter-spacing: .04em;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: var(--s-4) 0;
    overflow-y: auto;
}

.nav-section-title {
    font-size: .7rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(255,255,255,.4);
    padding: var(--s-4) var(--s-5) var(--s-2);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-5);
    color: rgba(255,255,255,.75);
    font-size: .9rem;
    transition: background var(--transition), color var(--transition);
    border-radius: 0;
    text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255,255,255,.1);
    color: #ffffff;
    text-decoration: none;
}

.nav-link.active {
    background: rgba(239,126,7,.2);
    color: var(--color-primary);
    border-right: 3px solid var(--color-primary);
}

.nav-link svg { flex-shrink: 0; opacity: .7; }
.nav-link.active svg,
.nav-link:hover svg { opacity: 1; }

.sidebar-footer {
    padding: var(--s-4) var(--s-5);
    border-top: 1px solid rgba(255,255,255,.1);
    font-size: .85rem;
    color: rgba(255,255,255,.6);
}

.sidebar-user {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-2);
}

.sidebar-user__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--s-2);
    text-decoration: none;
    color: rgba(255,255,255,.85);
    padding: var(--s-2);
    border-radius: var(--radius-sm);
    transition: background .15s;
    width: 100%;
    text-align: center;
}

.sidebar-user__link:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
}

.sidebar-user__avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}

.sidebar-user__avatar--initials {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,.15);
    color: #fff;
    font-size: .9rem;
    font-weight: 700;
}

.sidebar-user__name {
    font-size: .85rem;
    font-weight: 600;
    word-break: break-word;
    line-height: 1.3;
}

.sidebar-user__logoutbtn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: var(--s-1) 0;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,.4);
    font-size: .78rem;
    text-decoration: none;
    transition: background .15s, color .15s;
}

.sidebar-user__logoutbtn:hover {
    background: rgba(255,255,255,.08);
    color: rgba(255,255,255,.8);
}

/* --- Main content ----------------------------------------- */
.main {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: var(--s-4) var(--s-6);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-4);
    position: sticky;
    top: 0;
    z-index: 50;
    transition: background var(--transition), border-color var(--transition);
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    min-width: 0;
    flex: 1;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: var(--s-3);
}

.page-content {
    padding: var(--s-6);
    flex: 1;
}

/* --- Cards ------------------------------------------------ */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    transition: background var(--transition), border-color var(--transition);
}

/* --- Task list -------------------------------------------- */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-3);
    margin-bottom: var(--s-5);
}

.tasks-empty {
    text-align: center;
    padding: var(--s-7) var(--s-5);
    color: var(--color-text-muted);
}

.task-table {
    width: 100%;
    border-collapse: collapse;
}

.task-table thead th {
    text-align: left;
    padding: var(--s-3) var(--s-4);
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

.task-table tbody tr {
    border-bottom: 1px solid var(--color-border);
    transition: background var(--transition);
}

.task-table tbody tr:last-child { border-bottom: none; }
.task-table tbody tr:hover { background: var(--color-surface-2); }

.task-table td {
    padding: var(--s-4);
    vertical-align: middle;
    font-size: .9rem;
}

.task-title-link {
    font-weight: 600;
    color: var(--color-text);
}

.task-title-link:hover { color: var(--color-primary); text-decoration: none; }

.task-detail-snippet {
    font-size: .82rem;
    color: var(--color-text-muted);
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* --- Status badge ----------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge--open        { background: rgba(59,130,246,.12);  color: var(--color-open); }
.badge--in-progress { background: rgba(239,126,7,.12);   color: var(--color-in-progress); }
.badge--done        { background: rgba(45,138,78,.12);   color: var(--color-done); }
.badge--overdue     { background: rgba(192,57,43,.12);   color: var(--color-overdue); }
.badge--cancelled   { background: rgba(156,163,175,.12); color: var(--color-cancelled); }
.badge--pool        { background: rgba(107,114,128,.1); color: var(--color-text-muted); border: 1px dashed var(--color-text-muted); font-style: italic; }

.badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

/* --- Due date cell ---------------------------------------- */
.due-date { white-space: nowrap; font-size: .85rem; }
.due-date--overdue  { color: var(--color-overdue);     font-weight: 600; }
.due-date--soon     { color: var(--color-in-progress); font-weight: 600; }
.due-date--ok       { color: var(--color-text-muted); }

/* --- Buttons ---------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    padding: 8px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover { text-decoration: none; }

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

.btn--secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}
.btn--secondary:hover { background: var(--color-surface-2); }

.btn--ghost {
    background: transparent;
    color: var(--color-text-muted);
    border-color: transparent;
    padding-left: var(--s-2);
    padding-right: var(--s-2);
}
.btn--ghost:hover { background: var(--color-surface-2); color: var(--color-text); }

.btn--danger {
    background: var(--color-overdue);
    color: #fff;
    border-color: var(--color-overdue);
}
.btn--danger:hover { background: #a93226; border-color: #a93226; color: #fff; }

.btn--sm {
    padding: 5px 10px;
    font-size: .8rem;
}

.btn--full { width: 100%; justify-content: center; }

.btn--icon {
    padding: 6px;
    border-radius: var(--radius-sm);
}

/* Theme toggle button */
.btn-theme {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: background var(--transition), color var(--transition);
}
.btn-theme:hover { background: var(--color-surface-2); color: var(--color-text); }
.btn-theme .icon-sun  { display: none; }
.btn-theme .icon-moon { display: block; }
[data-theme="dark"] .btn-theme .icon-sun  { display: block; }
[data-theme="dark"] .btn-theme .icon-moon { display: none; }

/* --- Notification Bell ------------------------------------ */
.notif-bell {
    position: relative;
}

.notif-bell__btn {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
}
.notif-bell__btn:hover { background: var(--color-surface-2); color: var(--color-text); }

.notif-bell__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--color-overdue);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 99px;
    padding: 0 4px;
}

.notif-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    max-height: 460px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0,0,0,.25), 0 0 0 1px rgba(0,0,0,.05);
    z-index: 300;
    overflow: hidden;
}
.notif-dropdown.is-open { display: block; }


.notif-dropdown__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--color-border);
    font-size: .85rem;
}
.notif-dropdown__mark-read {
    font-size: .75rem;
    color: var(--color-primary);
}

.notif-dropdown__list {
    overflow-y: auto;
    max-height: 400px;
}

.notif-dropdown__empty {
    padding: var(--s-6) var(--s-4);
    text-align: center;
    color: var(--color-text-muted);
    font-size: .85rem;
}

.notif-item {
    display: flex;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--color-border);
    text-decoration: none;
    color: var(--color-text);
    transition: background .15s;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--color-surface-2); }
.notif-item:not(.notif-item--read) { background: rgba(59,130,246,.04); border-left: 3px solid var(--color-open); }
.notif-item:not(.notif-item--read) .notif-item__title { color: var(--color-text); }
.notif-item--read { border-left: 3px solid transparent; }
.notif-item--read .notif-item__title { color: var(--color-text-muted); font-weight: 500; }

.notif-item__icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: rgba(59,130,246,.1);
    color: var(--color-open);
}
.notif-item__icon--new_task  { background: rgba(59,130,246,.1); color: var(--color-open); }
.notif-item__icon--pool_task { background: rgba(239,126,7,.1); color: var(--color-primary); }
.notif-item__icon--claimed   { background: rgba(45,138,78,.1); color: var(--color-done); }
.notif-item__icon--returned  { background: rgba(239,126,7,.1); color: var(--color-primary); }
.notif-item__icon--comment   { background: rgba(26,38,66,.08); color: var(--color-base); }
.notif-item__icon--status    { background: rgba(156,163,175,.1); color: var(--color-text-muted); }

.notif-item__content { flex: 1; min-width: 0; }
.notif-item__title { font-size: .8rem; font-weight: 600; line-height: 1.3; position: relative; }
.notif-item__body  { font-size: .75rem; color: var(--color-text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notif-item__time  { font-size: .7rem; color: var(--color-text-muted); margin-top: 3px; }

/* --- Forms ------------------------------------------------ */
.field {
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    margin-bottom: var(--s-4);
}

.label {
    font-size: .85rem;
    font-weight: 600;
    color: var(--color-text);
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 9px 12px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: .9rem;
    color: var(--color-text);
    transition: border-color var(--transition), background var(--transition);
    appearance: none;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(239,126,7,.15);
}

.textarea { resize: vertical; min-height: 100px; }

.select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--s-4);
}

.form-actions {
    display: flex;
    gap: var(--s-3);
    padding-top: var(--s-4);
    border-top: 1px solid var(--color-border);
    margin-top: var(--s-5);
}

/* --- Alerts ----------------------------------------------- */
.alert {
    padding: var(--s-3) var(--s-4);
    border-radius: var(--radius-sm);
    font-size: .875rem;
    margin-bottom: var(--s-4);
    border-left: 3px solid;
}

.alert--error   { background: rgba(192,57,43,.08);  border-color: var(--color-overdue);  color: var(--color-overdue); }
.alert--success { background: rgba(45,138,78,.08);  border-color: var(--color-done);     color: var(--color-done); }
.alert--info    { background: rgba(59,130,246,.08); border-color: var(--color-open);     color: var(--color-open); }

/* --- Login page ------------------------------------------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-bg);
}

.login-wrap {
    width: 100%;
    max-width: 400px;
    padding: var(--s-4);
}

.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--s-7) var(--s-6);
}

.login-logo {
    display: flex;
    justify-content: center;
    margin-bottom: var(--s-6);
}

.login-logo svg {
    width: 160px;
    height: auto;
}

.login-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: var(--s-5);
    text-align: center;
}

/* --- Page header ------------------------------------------ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--s-5);
    gap: var(--s-4);
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-text);
}

/* --- Stats row -------------------------------------------- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--s-4);
    margin-bottom: var(--s-5);
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--s-4) var(--s-5);
    transition: background var(--transition), border-color var(--transition);
}

.stat-card__value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1;
    color: var(--color-text);
}

.stat-card__label {
    font-size: .78rem;
    color: var(--color-text-muted);
    margin-top: var(--s-1);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stat-card--overdue .stat-card__value { color: var(--color-overdue); }
.stat-card--soon    .stat-card__value { color: var(--color-in-progress); }
.stat-card--pool    .stat-card__value { color: var(--color-text-muted); }
.stat-card--backlog .stat-card__value { color: var(--color-primary); }
.stat-card--backlog { border-left: 3px solid var(--color-primary); }

a.stat-card {
    text-decoration: none;
    cursor: pointer;
}

a.stat-card:hover {
    border-color: var(--color-primary);
}

.stat-card--active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
}

/* --- Comments --------------------------------------------- */
/* --- Timeline (comments + activity) ----------------------- */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-top: 1px solid var(--color-border);
    padding-top: var(--s-4);
}

/* Comment item */
.timeline-item--comment {
    display: flex;
    gap: var(--s-3);
    padding: var(--s-3) 0;
}

.timeline-item__avatar {
    flex-shrink: 0;
    padding-top: 2px;
}

.timeline-item__content {
    flex: 1;
    min-width: 0;
    background: var(--color-surface-2);
    border-radius: var(--radius);
    padding: var(--s-3) var(--s-4);
}

.timeline-item__meta {
    font-size: .78rem;
    color: var(--color-text-muted);
    margin-bottom: var(--s-1);
}
.timeline-item__meta strong { color: var(--color-text); }

.timeline-item__body {
    font-size: .875rem;
    line-height: 1.55;
}

/* Activity item (dezent) */
.timeline-item--activity {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-2) 0;
    padding-left: 12px;
}

.timeline-item__dot {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-border);
}

.timeline-item__text {
    font-size: .78rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.activity-change {
    background: var(--color-surface-2);
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    font-size: .75rem;
    white-space: nowrap;
}

/* --- Admin table ------------------------------------------ */
.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th {
    text-align: left;
    padding: var(--s-3) var(--s-4);
    font-size: .78rem;
    font-weight: 600;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    border-bottom: 2px solid var(--color-border);
}

.admin-table td {
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--color-border);
    font-size: .875rem;
    vertical-align: middle;
}

.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--color-surface-2); }

/* --- Tabs ------------------------------------------------- */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: var(--s-5);
}

.tab-link {
    padding: var(--s-3) var(--s-5);
    font-size: .9rem;
    font-weight: 500;
    color: var(--color-text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    text-decoration: none;
    transition: color var(--transition), border-color var(--transition);
}

.tab-link:hover { color: var(--color-text); text-decoration: none; }
.tab-link.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* --- Utility ---------------------------------------------- */
.text-muted   { color: var(--color-text-muted); }
.text-sm      { font-size: .85rem; }
.text-center  { text-align: center; }
.mt-4  { margin-top: var(--s-4); }
.mt-5  { margin-top: var(--s-5); }
.mb-4  { margin-bottom: var(--s-4); }
.mb-5  { margin-bottom: var(--s-5); }
.gap-3 { gap: var(--s-3); }
.flex  { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.tag {
    display: inline-block;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 2px 10px;
    font-size: .75rem;
    color: var(--color-text-muted);
}

/* --- Developer credit ------------------------------------- */
.login-credit {
    text-align: center;
    margin-top: var(--s-4);
    font-size: .78rem;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.login-credit a {
    color: var(--color-text-muted);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
}

.login-credit a:hover { opacity: .7; text-decoration: none; }

[data-theme="dark"] .login-credit__logo {
    /* Swap to dark-bg variant via filter or hide/show */
    filter: brightness(0) invert(1);
}

.app-credit {
    text-align: center;
    padding: var(--s-4) var(--s-5);
    border-top: 1px solid rgba(255,255,255,.1);
    margin-top: auto;
}

.app-credit a {
    display: inline-block;
    opacity: .55;
    transition: opacity .2s;
}
.app-credit a:hover { opacity: .9; }

.app-credit__text {
    display: block;
    font-size: .68rem;
    color: rgba(255,255,255,.4);
    margin-bottom: var(--s-2);
    letter-spacing: .02em;
}

.app-credit__logo {
    height: 40px;
    width: auto;
}

/* Sidebar = dark background → show dark-bg variant */
.app-credit__logo--dark  { display: inline; }
.app-credit__logo--light { display: none; }

/* Login credit logo */
.login-credit__logo {
    height: 32px;
    width: auto;
    vertical-align: middle;
    margin-left: 4px;
}

/* --- Dashboard -------------------------------------------- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--s-5);
}

@media (max-width: 900px) {
    .dashboard-grid { grid-template-columns: 1fr; }
}

.dashboard-card { overflow: hidden; }

.dashboard-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--s-4) var(--s-5);
    border-bottom: 1px solid var(--color-border);
}

.dashboard-card__title {
    font-size: .9rem;
    font-weight: 700;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: var(--s-2);
}

.dash-task-list {
    list-style: none;
}

.dash-task-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-5);
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
}

.dash-task-item:last-child { border-bottom: none; }

.dash-task-main {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    flex-wrap: wrap;
    min-width: 0;
    flex: 1;
}

.dash-task-title {
    font-size: .875rem;
    font-weight: 500;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 240px;
}

.dash-task-title:hover { color: var(--color-primary); text-decoration: none; }

.dash-task-meta {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    flex-shrink: 0;
}

/* --- Calendar --------------------------------------------- */
.cal-nav {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    margin-bottom: var(--s-4);
}

.cal-nav__title {
    font-size: 1.1rem;
    font-weight: 700;
    min-width: 200px;
    text-align: center;
}

.cal-card {
    overflow: hidden;
}

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.cal-header {
    padding: var(--s-2) var(--s-3);
    text-align: center;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    background: var(--color-surface-2);
    border-bottom: 1px solid var(--color-border);
}

.cal-cell {
    min-height: 100px;
    padding: var(--s-2) var(--s-2) var(--s-2);
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    vertical-align: top;
    position: relative;
}

.cal-cell:nth-child(7n) { border-right: none; }

.cal-cell--empty {
    background: var(--color-surface-2);
    opacity: .5;
}

.cal-cell--today {
    background: rgba(239,126,7,.04);
}

.cal-day-num {
    display: inline-block;
    font-size: .8rem;
    color: var(--color-text-muted);
    margin-bottom: var(--s-1);
    font-weight: 500;
    text-decoration: none;
    width: 22px;
    height: 22px;
    line-height: 22px;
    text-align: center;
    border-radius: 50%;
    transition: background .15s, color .15s;
}

.cal-day-num:hover {
    background: var(--color-surface-2);
    color: var(--color-text);
}

.cal-day-num--today {
    background: var(--color-primary);
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.cal-day-num--today:hover {
    background: var(--color-primary);
    filter: brightness(1.1);
    color: #fff;
}

/* Drag & Drop */
.cal-cell.drag-over {
    background: rgba(59,130,246,.08);
    outline: 2px dashed var(--color-open);
    outline-offset: -2px;
}

.cal-task[draggable="true"] {
    cursor: grab;
}

.cal-task[draggable="true"]:active {
    cursor: grabbing;
}

.cal-task.dragging {
    opacity: .4;
}

.cal-task {
    display: block;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: .72rem;
    font-weight: 500;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
    cursor: pointer;
}

.cal-task:hover { opacity: .85; text-decoration: none; filter: brightness(.95); }

.cal-task--open      { background: rgba(59,130,246,.15);  color: var(--color-open); }
.cal-task--soon      { background: rgba(239,126,7,.18);   color: var(--color-in-progress); }
.cal-task--overdue   { background: rgba(192,57,43,.15);   color: var(--color-overdue); }
.cal-task--done      { background: rgba(45,138,78,.12);   color: var(--color-done); text-decoration: line-through; opacity:.7; }
.cal-task--cancelled { background: var(--color-surface-2); color: var(--color-cancelled); }

/* --- User avatar (global) --------------------------------- */
.user-avatar {
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}

.user-avatar--initials {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-base);
    color: #fff;
    font-weight: 700;
}

/* --- Profile / Avatar crop -------------------------------- */
.profile-avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.profile-avatar-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--color-base);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 700;
}

.crop-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--s-4);
}

.crop-modal__content {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: var(--s-5);
    max-width: 340px;
    width: 100%;
    box-shadow: var(--shadow);
}

.crop-container {
    position: relative;
    width: 240px;
    height: 240px;
    margin: 0 auto;
    border-radius: 50%;
    overflow: hidden;
    cursor: grab;
    border: 3px solid var(--color-border);
}

.crop-container:active { cursor: grabbing; }

#cropCanvas {
    display: block;
}

/* --- Bottom toolbar (mobile only) ------------------------- */
.bottom-bar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding: var(--s-2) 0;
    padding-bottom: max(var(--s-2), env(safe-area-inset-bottom));
    align-items: flex-end;
}

.bottom-bar__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 1;
    padding: var(--s-1) 0;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: .6rem;
    font-weight: 500;
    border: none;
    background: none;
    cursor: pointer;
    transition: color var(--transition);
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

.bottom-bar__item:hover,
.bottom-bar__item:active {
    text-decoration: none;
    color: var(--color-text);
}

.bottom-bar__item--active {
    color: var(--color-primary);
}

.bottom-bar__item--primary {
    background: var(--color-primary);
    color: #fff;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    flex: 0 0 48px;
    padding: 0;
    margin-top: -14px;
    box-shadow: 0 2px 8px rgba(239,126,7,.35);
}

.bottom-bar__item--primary:hover,
.bottom-bar__item--primary:active {
    color: #fff;
    background: #d96e06;
}

.bottom-bar__item--primary span {
    display: none;
}

.bottom-bar__item svg {
    flex-shrink: 0;
}

.bottom-bar.is-hidden {
    display: none !important;
}

.bottom-bar__badge {
    position: absolute;
    top: 0;
    right: 50%;
    transform: translateX(calc(50% + 8px));
    background: var(--color-overdue);
    color: #fff;
    font-size: .55rem;
    font-weight: 700;
    min-width: 14px;
    height: 14px;
    line-height: 14px;
    text-align: center;
    border-radius: 99px;
    padding: 0 3px;
}

/* --- Back button (mobile only) ---------------------------- */
.btn-back {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}

.btn-back:hover {
    background: var(--color-surface-2);
    color: var(--color-text);
    text-decoration: none;
}

/* --- Mobile menu toggle ----------------------------------- */
.hamburger {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--s-2);
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-text);
    border-radius: 2px;
    transition: transform var(--transition);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 99;
}

.sidebar-overlay.is-open { display: block; }

/* --- Responsive ------------------------------------------- */

/* ── Tablet (≤ 900px) ──────────────────────────────────────── */
@media (max-width: 900px) {
    .dashboard-grid { grid-template-columns: 1fr; }

    .dash-task-title { max-width: none; }
}

/* ── Mobile (≤ 768px) ──────────────────────────────────────── */
@media (max-width: 768px) {
    /* Sidebar: off-canvas */
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
    }

    .hamburger {
        display: flex;
    }

    .btn-back {
        display: flex;
    }

    /* Bottom toolbar visible */
    .bottom-bar {
        display: flex;
    }

    /* Page content needs bottom padding for toolbar */
    .page-content {
        padding-bottom: 72px;
    }

    /* Hide "Neue Aufgabe" from topbar (it's in bottom bar now) */
    .topbar-new-task {
        display: none;
    }

    /* Topbar */
    .topbar {
        padding: var(--s-3) var(--s-4);
    }

    .topbar-title {
        font-size: .85rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }

    .topbar-actions {
        flex-shrink: 0;
    }

    /* Page content */
    .page-content {
        padding: var(--s-4);
    }

    /* Forms: stack all form-rows, prevent iOS zoom on focus */
    .input,
    .select,
    .textarea {
        font-size: 16px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-wrap: wrap;
    }

    /* Filter bar: full-width stacking */
    .filter-bar {
        flex-direction: column;
    }

    .filter-bar .input,
    .filter-bar .select,
    .filter-bar .btn {
        max-width: none !important;
        width: 100%;
    }

    /* ── Task table → Card layout ───────────────────────────── */
    .task-table thead {
        display: none;
    }

    .task-table,
    .task-table tbody {
        display: block;
    }

    .task-table tr {
        display: block;
        padding: var(--s-3) var(--s-4);
        border-bottom: 1px solid var(--color-border);
        position: relative;
    }

    .task-table tbody tr:last-child {
        border-bottom: none;
    }

    .task-table td {
        display: block;
        padding: var(--s-1) 0;
        border: none;
    }

    /* First cell (title) gets more weight */
    .task-table td:first-child {
        padding-bottom: var(--s-2);
    }

    /* Meta items flow inline on mobile */
    .task-table td:not(:first-child) {
        display: inline-block;
        padding-right: var(--s-3);
        font-size: .8rem;
    }

    /* data-label pseudo-labels for task-table */
    .task-table td[data-label]:before {
        content: attr(data-label) ": ";
        font-size: .7rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: var(--color-text-muted);
    }

    /* Hide label for first cell (title is obvious) */
    .task-table td:first-child:before {
        display: none;
    }

    /* ── Admin table → Card layout ──────────────────────────── */
    .admin-table thead {
        display: none;
    }

    .admin-table,
    .admin-table tbody {
        display: block;
    }

    .admin-table tr {
        display: block;
        padding: var(--s-3) var(--s-4);
        border-bottom: 1px solid var(--color-border);
    }

    .admin-table tr:last-child {
        border-bottom: none;
    }

    .admin-table td {
        display: block;
        padding: var(--s-2) 0;
        border: none;
    }

    .admin-table td[data-label]:before {
        content: attr(data-label);
        display: block;
        font-size: .7rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .04em;
        color: var(--color-text-muted);
        margin-bottom: 2px;
    }

    /* ── Calendar: scrollable on mobile ─────────────────────── */
    .cal-card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .cal-grid {
        grid-template-columns: repeat(7, 1fr);
        min-width: 500px;
        font-size: .7rem;
    }

    .cal-cell {
        min-height: 60px;
        padding: 2px;
    }

    .cal-header {
        padding: var(--s-1) 0;
        font-size: .65rem;
    }

    .cal-task {
        font-size: .6rem;
        padding: 1px 3px;
        margin-bottom: 1px;
    }

    .cal-day-num,
    .cal-day-num--today {
        font-size: .7rem;
        width: 18px;
        height: 18px;
        line-height: 18px;
    }

    .cal-nav__title {
        font-size: .95rem;
        min-width: 160px;
    }

    /* ── Dashboard ───────────────────────────────────────────── */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: var(--s-4);
    }

    .stats-row {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--s-2);
    }

    .stat-card {
        padding: var(--s-2) var(--s-3);
    }

    .stat-card__value {
        font-size: 1.2rem;
    }

    .stat-card__label {
        font-size: .65rem;
    }

    .dash-task-item {
        padding: var(--s-3) var(--s-4);
    }

    .dash-task-title {
        max-width: none;
        white-space: normal;
    }

    .dash-task-meta {
        width: 100%;
        margin-top: var(--s-1);
    }

    /* ── Notification dropdown: full-width, above bottom bar ── */
    .notif-bell {
        position: static;
    }

    .notif-dropdown {
        position: fixed;
        bottom: 72px;
        bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        top: auto;
        left: var(--s-3);
        right: var(--s-3);
        width: auto;
        max-height: calc(100vh - 140px);
        max-height: calc(100dvh - 140px);
        border-radius: var(--radius);
        z-index: 301;
    }

    /* ── Tabs: scrollable ────────────────────────────────────── */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab-link {
        white-space: nowrap;
        padding: var(--s-3) var(--s-4);
        font-size: .85rem;
    }

    /* ── Page header ─────────────────────────────────────────── */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--s-3);
    }

    .page-header h1 {
        font-size: 1.15rem;
    }

    /* ── Comments / Timeline ─────────────────────────────────── */
    .timeline-item--comment {
        gap: var(--s-2);
    }

    .timeline-item__content {
        padding: var(--s-2) var(--s-3);
    }

    /* ── Crop modal ──────────────────────────────────────────── */
    .crop-container {
        width: 200px;
        height: 200px;
    }

    .crop-modal__content {
        max-width: calc(100vw - var(--s-6));
    }
}

/* ── Small phones (≤ 480px) ────────────────────────────────── */
@media (max-width: 480px) {
    html { font-size: 14px; }

    .page-content {
        padding: var(--s-3);
    }

    .topbar {
        padding: var(--s-2) var(--s-3);
    }

    /* Stats: 2 columns on very small screens */
    .stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Calendar: even more compact */
    .cal-cell {
        min-height: 48px;
    }

    .cal-task {
        font-size: .55rem;
        padding: 1px 2px;
    }

    .cal-day-num,
    .cal-day-num--today {
        font-size: .65rem;
        width: 16px;
        height: 16px;
        line-height: 16px;
    }

    /* Dashboard card headers */
    .dashboard-card__header {
        padding: var(--s-3) var(--s-4);
        flex-wrap: wrap;
        gap: var(--s-2);
    }

    /* Forms: reduce padding */
    .login-card {
        padding: var(--s-5) var(--s-4);
    }

    /* Sidebar user section compact */
    .sidebar-user__avatar {
        width: 36px;
        height: 36px;
    }
}

