:root {
    --bg: #f6f8f7;
    --panel: #fff;
    --ink: #17201b;
    --muted: #647067;
    --line: #dbe4df;
    --leaf: #1f7a53;
    --danger: #c2410c;
    --danger-soft: #fff7ed;
    --warn: #b7791f;
    --green: #166534;
    --shadow: 0 14px 36px rgba(23, 32, 27, .08);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
}
a { color: inherit; text-decoration: none; }
input, textarea, select, button {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    font: inherit;
}
button { cursor: pointer; }
button:disabled { opacity: .55; cursor: not-allowed; }
fieldset {
    min-width: 0;
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}
legend { padding: 0 7px; font-weight: 800; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, .97);
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 18px;
}
.brand { font-weight: 800; }
.desktop-nav { display: none; gap: 8px; font-size: 14px; }
.desktop-nav a, .admin-nav a, .mobile-nav a {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 9px 12px;
}
.mobile-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 0 16px 12px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.mobile-nav::-webkit-scrollbar { display: none; }
.mobile-nav a {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 14px;
    font-weight: 800;
    white-space: nowrap;
}
.mobile-nav a.active {
    border-color: #b9d8ca;
    background: #eff8f3;
    color: var(--leaf);
}

.app-main {
    width: min(1120px, 100%);
    margin: 0 auto;
    padding: 20px 16px 40px;
}
.auth-main {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
}
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 16px;
}
.auth-panel, .narrow { width: min(520px, 100%); margin-inline: auto; }
.installer-panel { width: min(760px, 100%); margin-inline: auto; }
.installer-main { place-items: start center; }
.page-heading {
    position: relative;
    margin-bottom: 18px;
}
.page-heading p { margin: 0 0 4px; color: var(--leaf); font-weight: 700; font-size: 14px; }
h1 { margin: 0; font-size: clamp(28px, 5vw, 38px); line-height: 1.05; }
h2 { margin: 0 0 12px; font-size: 18px; }
h3 { margin: 14px 0 8px; color: var(--muted); font-size: 14px; }
p { line-height: 1.5; }
.muted { color: var(--muted); font-size: 14px; }
.top-gap { margin-top: 12px; }
.full { width: 100%; }
.hidden { display: none !important; }
.break-link { overflow-wrap: anywhere; color: var(--leaf); font-weight: 700; }

.form-stack { display: grid; gap: 14px; }
.form-stack label, .label { display: grid; gap: 7px; font-weight: 700; font-size: 14px; color: #334039; }
.form-grid, .admin-grid { display: grid; gap: 14px; }
.conditional-field[hidden] { display: none; }
.checkbox-line {
    display: flex !important;
    align-items: center;
    gap: 10px !important;
}
.checkbox-line input {
    width: auto;
    min-height: auto;
}
.inline-form { display: grid; gap: 10px; }
.split-links {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 18px;
    color: var(--leaf);
    font-weight: 700;
    font-size: 14px;
}
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border-radius: 6px;
    padding: 10px 14px;
    font-weight: 800;
    font-size: 14px;
}
.button.primary { border-color: var(--leaf); background: var(--leaf); color: #fff; }
.button.secondary { border-color: var(--line); background: #fff; color: var(--ink); }
.button.danger {
    border-color: #f3b08e;
    background: #fff;
    color: var(--danger);
}
.button.danger:hover,
.button.danger:focus-visible {
    border-color: var(--danger);
    background: var(--danger-soft);
}
.compact-button {
    width: auto;
    min-height: 36px;
    padding: 7px 10px;
    font-size: 12px;
}
.square-button {
    position: absolute;
    right: 0;
    top: 4px;
    width: 48px;
    font-size: 26px;
}

.alert {
    margin: 0 0 16px;
    border-radius: 6px;
    padding: 12px;
    font-weight: 700;
    font-size: 14px;
}
.alert-danger { background: #fff1ed; color: var(--danger); }
.alert-success, .success-panel { background: #ecfdf3; color: var(--green); }

.task-section, .task-list, .admin-list { display: grid; gap: 12px; margin: 18px 0; }
.danger-section h2 { color: var(--danger); }
.task-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 14px;
    align-items: start;
    min-height: 96px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 15px;
}
.task-card__main { display: grid; gap: 8px; }
.task-card small, .task-card__date { color: var(--muted); font-size: 13px; }
.badges, .chips, .filters, .admin-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.filters { overflow-x: auto; flex-wrap: nowrap; margin-bottom: 10px; }
.filters .button { width: auto; white-space: nowrap; }
.badge, .chips span, .chip-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 800;
}
.chip-form {
    width: auto;
    border: 0;
    background: #eef3f1;
    color: #334039;
}
.chip-form input { display: none; }
.chip-form button {
    width: auto;
    min-height: 0;
    border: 0;
    background: transparent;
    padding: 0;
    color: #9a5a3d;
    font-weight: 900;
}
.chip-form button:hover,
.chip-form button:focus-visible { color: var(--danger); }
.chips span { background: #eef3f1; color: #334039; }
.status-completed { background: #dcfce7; color: var(--green); }
.status-open, .status-planned { background: #eef3f1; color: #334039; }
.status-overdue { background: #fee2e2; color: #991b1b; }
.status-cancelled { background: #e5e7eb; color: #4b5563; }
.priority-high { background: #fef3c7; color: #92400e; }
.priority-normal { background: #eef3f1; color: #334039; }
.priority-low { background: #dcfce7; color: var(--green); }
.empty {
    border: 1px dashed #b9c7c0;
    border-radius: 8px;
    background: rgba(255, 255, 255, .7);
    padding: 14px;
    color: var(--muted);
    font-size: 14px;
}
summary { cursor: pointer; font-weight: 800; }
.details { margin: 0; }
.details div {
    display: grid;
    gap: 4px;
    padding: 11px 0;
    border-bottom: 1px solid #eef3f1;
}
.details dt { color: var(--muted); font-size: 14px; font-weight: 700; }
.details dd { margin: 0; font-weight: 800; }
.detail-heading { display: grid; gap: 12px; }
.row-between { display: grid; gap: 12px; }
.action-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.metrics { display: grid; gap: 12px; }
.metrics article span { color: var(--muted); font-size: 14px; }
.metrics article strong {
    display: block;
    margin-top: 8px;
    font-size: 34px;
}
.danger-metric strong { color: var(--danger); }
.checkbox-grid { display: grid; gap: 8px; }
.checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    padding: 10px;
    font-size: 14px;
}
.checkbox-grid input { width: auto; min-height: auto; }

@media (min-width: 720px) {
    .desktop-nav { display: flex; }
    .mobile-nav { display: none; }
    .inline-form { grid-template-columns: 1fr auto; align-items: end; }
    .form-grid, .admin-grid, .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .details div, .row-between { grid-template-columns: 1fr auto; align-items: center; }
    .action-stack { justify-content: flex-end; }
}

@media (min-width: 1020px) {
    .metrics { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
