:root {
    color-scheme: light dark;
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #172033;
    --muted: #667085;
    --primary: #2f6fed;
    --primary-dark: #2459c4;
    --danger: #ba1a1a;
    --border: #d0d5dd;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1;
}

h1, h2, h3 {
    margin-top: 0;
}

h1 {
    margin-bottom: 0.15rem;
}

.subtitle {
    margin: 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.app-main {
    width: min(960px, 100%);
    margin: 0 auto;
    padding: 1rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.form-row {
    display: grid;
    gap: 0.35rem;
    margin-bottom: 0.85rem;
}

label {
    font-weight: 600;
}

input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
}

button {
    border: 0;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    background: var(--primary);
    color: white;
}

button:hover {
    background: var(--primary-dark);
}

button.secondary {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
}

button.secondary:hover {
    background: rgba(47, 111, 237, 0.08);
}

.hidden {
    display: none !important;
}

.error {
    color: var(--danger);
    font-weight: 600;
}

.muted {
    color: var(--muted);
}

.list-grid {
    display: grid;
    gap: 0.75rem;
}

.list-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.85rem;
    background: rgba(255, 255, 255, 0.65);
}

.list-card h3 {
    margin-bottom: 0.25rem;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: rgba(47, 111, 237, 0.12);
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 700;
}

.toolbar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #101828;
        --card: #182230;
        --text: #f9fafb;
        --muted: #98a2b3;
        --border: #344054;
    }

    .list-card {
        background: rgba(255, 255, 255, 0.03);
    }
}

.clickable {
    cursor: pointer;
}

.clickable:hover {
    border-color: var(--primary);
}

.item-form {
    display: grid;
    gap: 0.75rem;
}

.item-list {
    display: grid;
    gap: 0.65rem;
}

.item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
}

.item-action-button {
    flex: 0 0 auto;
}

.item-row {
    justify-content: flex-start;
}

.item-main {
    flex: 1 1 auto;
    min-width: 0;
}

.item-check-button,
.item-check-placeholder {
    width: 2rem;
    height: 2rem;
    border: 2px solid var(--border);
    border-radius: 7px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: transparent;
    color: var(--primary);
    font-weight: 900;
    font-size: 1.15rem;
    padding: 0;
}

.item-check-button:hover {
    border-color: var(--primary);
    background: rgba(47, 111, 237, 0.08);
}

.item-check-button.is-completed {
    border-color: var(--primary);
    background: rgba(47, 111, 237, 0.12);
}

.item-check-placeholder {
    border-style: dashed;
    opacity: 0.55;
}

.add-item-row {
    margin-bottom: 0.8rem;
}

.add-item-row input {
    padding: 0.55rem 0.65rem;
}

.add-item-name {
    flex: 1 1 14rem;
}

.add-item-quantity {
    flex: 0 0 6.5rem;
}

.add-item-unit {
    flex: 0 0 6rem;
}

.add-item-button {
    width: 2.4rem;
    height: 2.4rem;
    padding: 0;
    flex: 0 0 auto;
    font-size: 1.3rem;
    line-height: 1;
}

.compact-message {
    margin-top: 0;
    min-height: 1.3rem;
}

@media (max-width: 640px) {
    .add-item-row {
        flex-wrap: wrap;
    }

    .add-item-name {
        flex: 1 1 calc(100% - 3rem);
    }

    .add-item-quantity,
    .add-item-unit {
        flex: 1 1 6rem;
    }
}

.item-delete-button {
    width: 2.2rem;
    height: 2.2rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    margin-left: auto;
    background: transparent;
    color: var(--danger);
    padding: 0;
    font-size: 1.05rem;
}

.item-delete-button:hover {
    border-color: var(--danger);
    background: rgba(186, 26, 26, 0.08);
}

.suggestions {
    display: grid;
    gap: 0.35rem;
    margin: -0.35rem 0 0.8rem 2.5rem;
    max-width: 32rem;
}

.suggestion-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    text-align: left;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card);
    color: var(--text);
    padding: 0.55rem 0.7rem;
    font-weight: 400;
}

.suggestion-item:hover {
    border-color: var(--primary);
    background: rgba(47, 111, 237, 0.08);
}

.suggestion-item strong {
    font-weight: 700;
}

.item-edit-button {
    width: 2.2rem;
    height: 2.2rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: transparent;
    color: var(--primary);
    padding: 0;
    font-size: 1.05rem;
}

.item-edit-button:hover {
    border-color: var(--primary);
    background: rgba(47, 111, 237, 0.08);
}

.item-row.is-editing {
    align-items: center;
}

.item-row.is-editing input {
    padding: 0.55rem 0.65rem;
}

.edit-item-name {
    flex: 1 1 14rem;
}

.edit-item-quantity {
    flex: 0 0 6.5rem;
}

.edit-item-unit {
    flex: 0 0 6rem;
}

.edit-save-button,
.edit-cancel-button {
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
}

.edit-cancel-button {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.edit-cancel-button:hover {
    background: rgba(186, 26, 26, 0.08);
}

@media (max-width: 640px) {
    .item-row.is-editing {
        flex-wrap: wrap;
    }

    .edit-item-name {
        flex: 1 1 calc(100% - 3rem);
    }

    .edit-item-quantity,
    .edit-item-unit {
        flex: 1 1 6rem;
    }
}

.list-create-form {
    display: grid;
    gap: 0.75rem;
}

@media (min-width: 720px) {
    .list-create-form {
        grid-template-columns: 1fr 10rem 12rem auto;
        align-items: end;
    }

    .list-create-form .form-row {
        margin-bottom: 0;
    }
}

.list-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.list-card-actions {
    display: flex;
    gap: 0.4rem;
    flex: 0 0 auto;
}

.list-edit-button,
.list-delete-button {
    width: 2.2rem;
    height: 2.2rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: transparent;
    padding: 0;
    font-size: 1.05rem;
}

.list-edit-button {
    color: var(--primary);
}

.list-edit-button:hover {
    border-color: var(--primary);
    background: rgba(47, 111, 237, 0.08);
}

.list-delete-button {
    color: var(--danger);
}

.list-delete-button:hover {
    border-color: var(--danger);
    background: rgba(186, 26, 26, 0.08);
}

.list-edit-form {
    display: grid;
    gap: 0.75rem;
}

.list-edit-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (min-width: 720px) {
    .list-edit-form {
        grid-template-columns: 1fr 10rem 12rem auto;
        align-items: end;
    }

    .list-edit-form .form-row {
        margin-bottom: 0;
    }
}

.change-password-form {
    display: grid;
    gap: 0.75rem;
    max-width: 28rem;
}

.user-create-form {
    display: grid;
    gap: 0.75rem;
}

.user-create-form select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    background: var(--card);
    color: var(--text);
}

.user-list {
    display: grid;
    gap: 0.65rem;
}

.user-row {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
}

@media (min-width: 900px) {
    .user-create-form {
        grid-template-columns: 12rem 1fr 12rem 8rem auto;
        align-items: end;
    }

    .user-create-form .form-row {
        margin-bottom: 0;
    }
}

.user-row-main {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.user-row-actions {
    display: flex;
    gap: 0.4rem;
    flex: 0 0 auto;
}

.user-edit-button,
.user-toggle-button,
.user-reset-password-button {
    width: 2.2rem;
    height: 2.2rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: transparent;
    padding: 0;
    font-size: 1.05rem;
}

.user-edit-button,
.user-reset-password-button {
    color: var(--primary);
}

.user-toggle-button {
    color: var(--danger);
}

.user-edit-button:hover,
.user-reset-password-button:hover {
    border-color: var(--primary);
    background: rgba(47, 111, 237, 0.08);
}

.user-toggle-button:hover {
    border-color: var(--danger);
    background: rgba(186, 26, 26, 0.08);
}

.user-edit-form {
    display: grid;
    gap: 0.75rem;
}

.user-edit-form select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    background: var(--card);
    color: var(--text);
}

.user-edit-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

@media (min-width: 900px) {
    .user-edit-form {
        grid-template-columns: 12rem 1fr 8rem 8rem auto;
        align-items: end;
    }

    .user-edit-form .form-row {
        margin-bottom: 0;
    }
}

.audit-list {
    display: grid;
    gap: 0.75rem;
}

.audit-row {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
}

.audit-row-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.35rem;
}

.audit-details {
    margin: 0.6rem 0 0;
    padding: 0.75rem;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.06);
    overflow-x: auto;
    white-space: pre-wrap;
    font-size: 0.85rem;
}

@media (prefers-color-scheme: dark) {
    .audit-details {
        background: rgba(255, 255, 255, 0.06);
    }
}

.backup-list {
    display: grid;
    gap: 0.75rem;
}

.backup-row {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
}

.backup-row-main {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.backup-row-actions {
    display: flex;
    gap: 0.4rem;
    flex: 0 0 auto;
}

.backup-download-button {
    white-space: nowrap;
}

.checksum-line {
    word-break: break-all;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.backup-delete-button {
    white-space: nowrap;
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
}

.backup-delete-button:hover {
    background: rgba(186, 26, 26, 0.08);
}

.member-add-form {
    display: grid;
    gap: 0.75rem;
}

.member-add-form select,
.member-role-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font: inherit;
    background: var(--card);
    color: var(--text);
}

.member-list {
    display: grid;
    gap: 0.65rem;
}

.member-row {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.75rem;
}

.member-row-main {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.member-row-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex: 0 0 auto;
}

.member-role-select {
    min-width: 9rem;
}

.member-remove-button {
    background: transparent;
    color: var(--danger);
    border: 1px solid var(--danger);
    white-space: nowrap;
}

.member-remove-button:hover {
    background: rgba(186, 26, 26, 0.08);
}

.member-remove-button:disabled,
.member-role-select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (min-width: 720px) {
    .member-add-form {
        grid-template-columns: 12rem 12rem auto;
        align-items: end;
    }

    .member-add-form .form-row {
        margin-bottom: 0;
    }
}

@media (max-width: 640px) {
    .member-row-main {
        flex-direction: column;
    }

    .member-row-actions {
        width: 100%;
        flex-wrap: wrap;
    }
}

.member-search-row {
    position: relative;
}

.member-user-suggestions {
    display: grid;
    gap: 0.35rem;
    margin-top: 0.35rem;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    z-index: 5;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.35rem;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
}

.member-user-suggestion {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    width: 100%;
    text-align: left;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    padding: 0.55rem 0.7rem;
    font-weight: 400;
}

.member-user-suggestion:hover {
    border-color: var(--primary);
    background: rgba(47, 111, 237, 0.08);
}

.member-user-no-result {
    margin: 0;
    padding: 0.55rem 0.7rem;
}

.device-list {
    display: grid;
    gap: 0.75rem;
}

.device-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 0.85rem;
}

.device-row > div {
    min-width: 0;
}

.device-row strong {
    display: inline-block;
    margin-right: 0.4rem;
    margin-bottom: 0.25rem;
}

.device-revoke-button {
    flex: 0 0 auto;
    border: 1px solid var(--danger);
    background: transparent;
    color: var(--danger);
}

.device-revoke-button:hover:not(:disabled) {
    background: rgba(186, 26, 26, 0.08);
}

.device-revoke-button:disabled {
    cursor: default;
    opacity: 0.5;
}

@media (max-width: 640px) {
    .device-row {
        flex-direction: column;
    }

    .device-revoke-button {
        width: 100%;
    }
}

.list-card {
    position: relative;
    overflow: hidden;
    border-left: 0.4rem solid var(--list-color, var(--primary));
}

.list-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.list-color-dot {
    width: 0.85rem;
    height: 0.85rem;
    flex: 0 0 auto;
    border-radius: 50%;
    background: var(--list-color, var(--primary));
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.75);
}

.list-detail-header {
    border-left: 0.4rem solid var(--list-color, var(--primary));
}

@media (prefers-color-scheme: dark) {
    .list-color-dot {
        box-shadow: 0 0 0 2px rgba(16, 24, 40, 0.85);
    }
}

