/* ========================================
   SETTINGS PAGES - UNIFIED MODERN UI
   ======================================== */

.settings-page {
    min-height: calc(100vh - 48px);
    padding: 28px 28px 64px;
    color: #1c1c1e;
    background: #f5f5f7;
    font-family: -apple-system, system-ui, sans-serif;
}

/* -- Page header ------------------------------------------------------- */
.settings-header {
    max-width: 1020px;
    margin: 0 auto 22px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.settings-header-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.settings-kicker {
    color: #007aff;
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.settings-header h1 {
    margin: 3px 0 0;
    color: #1c1c1e;
    font-size: 1.72rem;
    font-weight: 800;
    line-height: 1.15;
}

.settings-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
}

.settings-title-link {
    padding: 0;
    border: none;
    background: transparent;
    color: #007aff;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s;
    min-width: 0;
    text-align: left;
}

.settings-title-link:hover {
    opacity: 0.7;
}

.settings-title-sep {
    color: #c7c7cc;
    font-weight: 600;
    flex-shrink: 0;
}

.settings-title-current {
    color: #1c1c1e;
    font-weight: 800;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* -- Card -------------------------------------------------------------- */
.settings-card {
    max-width: 1020px;
    margin: 0 auto;
    background: white;
    border: 1.5px solid #e5e5ea;
    border-radius: 16px;
    box-shadow: 0 18px 42px rgba(28, 28, 30, 0.08);
    overflow: hidden;
}

.settings-card + .settings-card {
    margin-top: 16px;
}

/* -- Toolbar ----------------------------------------------------------- */
.settings-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-bottom: 1px solid #e5e5ea;
    background: #fafafa;
}

.settings-counter {
    color: #636366;
    font-size: 0.84rem;
    font-weight: 600;
}

/* -- Buttons ----------------------------------------------------------- */
.settings-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    padding: 0 14px;
    border-radius: 11px;
    border: 1.5px solid transparent;
    font: inherit;
    font-size: 0.86rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.12s, box-shadow 0.15s;
}

.settings-btn:active {
    transform: translateY(1px);
}

.settings-btn--primary {
    color: white;
    background: #007aff;
    box-shadow: 0 5px 14px rgba(0, 122, 255, 0.18);
}

.settings-btn--primary:hover {
    background: #006fe6;
    box-shadow: 0 8px 18px rgba(0, 122, 255, 0.24);
}

.settings-btn--ghost {
    color: #636366;
    background: white;
    border-color: #e5e5ea;
}

.settings-btn--ghost:hover {
    color: #1c1c1e;
    background: #f5f5f7;
    border-color: #d1d1d6;
}

.settings-btn--danger {
    color: white;
    background: #ff3b30;
    box-shadow: 0 5px 14px rgba(255, 59, 48, 0.2);
}

.settings-btn--danger:hover {
    background: #ed3328;
    box-shadow: 0 8px 18px rgba(255, 59, 48, 0.26);
}

.settings-btn--danger[disabled] {
    background: #ffb3ae;
    cursor: not-allowed;
    box-shadow: none;
}

.settings-btn--sm {
    height: 34px;
    padding: 0 12px;
    font-size: 0.82rem;
}

/* -- Inline form ------------------------------------------------------- */
.settings-inline-form {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: #f0f7ff;
    border-bottom: 1px solid #d9e8fb;
}

.settings-input {
    box-sizing: border-box;
    height: 40px;
    border: 1.5px solid #e5e5ea;
    border-radius: 11px;
    padding: 0 12px;
    color: #1c1c1e;
    background: #ffffff;
    font: inherit;
    font-size: 0.92rem;
    line-height: 1.2;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
    min-width: 0;
    -webkit-appearance: none;
    appearance: none;
}

select.settings-input {
    -webkit-appearance: auto;
    appearance: auto;
}

.settings-input:focus {
    outline: none;
    border-color: #007aff;
    background: #f0f7ff;
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

.settings-input--flex {
    min-width: 0;
}

.settings-inline-form .settings-input--flex {
    flex: 1 1 240px;
}

.settings-input--erp {
    width: 96px;
    flex-shrink: 0;
}

.settings-input--num {
    width: 110px;
    flex-shrink: 0;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.settings-input--unit {
    width: 100px;
    flex-shrink: 0;
    cursor: pointer;
}

.settings-input--error {
    border-color: #ff3b30;
    background: #fff0ef;
}

.settings-input--error:focus {
    border-color: #ff3b30;
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.16);
}

.settings-field-error {
    width: 100%;
    margin: -4px 0 0;
    color: #ff3b30;
    font-size: 0.82rem;
    font-weight: 600;
}

.settings-field-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 0 0 auto;
}

.settings-field-label > span {
    color: #636366;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* -- List -------------------------------------------------------------- */
.settings-list {
    max-height: calc(100vh - 280px);
    overflow-y: auto;
    padding: 8px 8px;
}

.settings-list::-webkit-scrollbar {
    width: 10px;
}

.settings-list::-webkit-scrollbar-thumb {
    background: #d1d1d6;
    border-radius: 6px;
    border: 2px solid white;
}

.settings-list::-webkit-scrollbar-thumb:hover {
    background: #aeaeb2;
}

/* -- Row --------------------------------------------------------------- */
.settings-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: 11px;
    background: white;
    border: 1.5px solid transparent;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
    position: relative;
}

.settings-row:hover {
    background: #f5f5f7;
}

.settings-row--drag-target {
    border-color: #007aff;
    background: #f0f7ff;
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.18);
}

.settings-row--editing {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 14px;
    background: #f0f7ff;
    border-color: #d9e8fb;
    box-shadow: 0 0 0 1px rgba(0, 122, 255, 0.08);
}

.settings-row--editing:hover {
    background: #f0f7ff;
}

.settings-edit-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}

.settings-edit-actions .settings-btn {
    min-width: 100px;
}

.settings-edit-row-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.settings-row--drag-source {
    opacity: 0.35;
}

.settings-row-text {
    flex: 1;
    min-width: 0;
    color: #1c1c1e;
    font-size: 0.94rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-row-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-row-body .settings-row-name {
    color: #1c1c1e;
    font-size: 0.94rem;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-row-body .settings-row-meta {
    color: #636366;
    font-size: 0.82rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-row-nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.settings-row-nav-btn:hover .settings-row-name {
    color: #007aff;
}

.settings-row-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    color: #007aff;
    background: #e8f3ff;
}

.settings-row-chevron {
    flex-shrink: 0;
    color: #c7c7cc;
    transition: transform 0.15s, color 0.15s;
}

.settings-row-nav-btn:hover .settings-row-chevron {
    color: #007aff;
    transform: translateX(2px);
}

/* -- Drag handle ------------------------------------------------------- */
.settings-drag-handle {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    color: #c7c7cc;
    cursor: grab;
    touch-action: none;
    transition: color 0.15s, background 0.15s;
}

.settings-drag-handle:hover {
    color: #007aff;
    background: #f0f7ff;
}

.settings-drag-handle:active {
    cursor: grabbing;
}

.settings-drag-ghost {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 20px 38px rgba(0, 0, 0, 0.18);
    border: 1.5px solid #007aff !important;
    background: white !important;
    border-radius: 11px;
    opacity: 0.92;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
}

body.settings-dragging {
    cursor: grabbing !important;
    user-select: none;
}

body.settings-dragging * {
    cursor: grabbing !important;
}

/* -- Badge ------------------------------------------------------------- */
.settings-badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 26px;
    min-width: 42px;
    padding: 0 9px;
    border-radius: 8px;
    color: #007aff;
    background: #e8f3ff;
    font-size: 0.78rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.settings-badge--empty {
    color: #aeaeb2;
    background: #f2f2f7;
}

.settings-cost-badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    height: 28px;
    padding: 0 11px;
    border-radius: 8px;
    color: #1c1c1e;
    background: #f0f7ff;
    border: 1px solid #d9e8fb;
    font-size: 0.84rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

/* -- Row actions ------------------------------------------------------- */
.settings-row-action {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    border: none;
    background: transparent;
    color: #636366;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.settings-row-action:hover {
    color: #007aff;
    background: #e8f3ff;
}

.settings-row-action--delete:hover {
    color: #ff3b30;
    background: #ffeae8;
}

/* -- Empty state ------------------------------------------------------- */
.settings-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 60px 24px;
    color: #aeaeb2;
}

.settings-empty p {
    margin: 0;
    color: #8e8e93;
    font-size: 0.94rem;
    font-weight: 600;
}

/* -- Produkt-Form (Material) ------------------------------------------ */
.settings-produkt-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 18px;
    background: #f0f7ff;
    border-bottom: 1px solid #d9e8fb;
}

.settings-produkt-nums-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.settings-calc-preview {
    display: inline-flex;
    align-items: center;
    height: 40px;
    padding: 0 12px;
    border-radius: 11px;
    color: #1c1c1e;
    background: white;
    border: 1.5px solid #d9e8fb;
    font-size: 0.92rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

/* -- Toggle ----------------------------------------------------------- */
.settings-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    height: 40px;
}

.settings-toggle-input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.settings-toggle-track {
    width: 44px;
    height: 26px;
    border-radius: 999px;
    background: #d1d1d6;
    position: relative;
    transition: background 0.18s;
}

.settings-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
    transition: transform 0.18s;
}

.settings-toggle-input:checked + .settings-toggle-track {
    background: #007aff;
}

.settings-toggle-input:checked + .settings-toggle-track .settings-toggle-thumb {
    transform: translateX(18px);
}

/* -- Color picker (Baustellen-Status) --------------------------------- */
.settings-color-input {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1.5px solid #e5e5ea;
    border-radius: 11px;
    background: white;
    cursor: pointer;
}

.settings-color-input::-webkit-color-swatch-wrapper {
    padding: 4px;
}

.settings-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 7px;
}

.settings-color-presets {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px;
    border-radius: 11px;
    background: white;
    border: 1.5px solid #e5e5ea;
}

.settings-color-preset {
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 7px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.15s;
}

.settings-color-preset:hover {
    transform: scale(1.08);
}

.settings-color-preset--active {
    border-color: #1c1c1e;
    transform: scale(1.05);
}

.settings-status-dot {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--status-color, #007aff);
    box-shadow: 0 0 0 3px var(--status-surface, rgba(0, 122, 255, 0.18));
}

.settings-status-badge {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    height: 26px;
    padding: 0 9px;
    border-radius: 8px;
    color: var(--status-color, #007aff);
    background: var(--status-surface, rgba(0, 122, 255, 0.14));
    font-size: 0.78rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    text-transform: uppercase;
}

/* -- Delete dialog ----------------------------------------------------- */
.settings-delete-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.settings-delete-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(28, 28, 30, 0.42);
    backdrop-filter: blur(2px);
    border: none;
    cursor: pointer;
}

.settings-delete-card {
    position: relative;
    width: min(420px, 100%);
    background: white;
    border-radius: 16px;
    box-shadow: 0 28px 56px rgba(0, 0, 0, 0.28);
    overflow: hidden;
}

.settings-delete-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    border-bottom: 1px solid #f2f2f7;
    color: #ff3b30;
}

.settings-delete-header h2 {
    margin: 0;
    color: #1c1c1e;
    font-size: 1.1rem;
    font-weight: 800;
}

.settings-delete-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
}

.settings-delete-subject {
    margin: 0;
    color: #1c1c1e;
    font-size: 1rem;
    font-weight: 700;
}

.settings-delete-cascade {
    margin: 0;
    color: #ff9500;
    font-size: 0.88rem;
    font-weight: 600;
    background: #fff7ed;
    border: 1px solid #ffe4c2;
    border-radius: 10px;
    padding: 9px 12px;
}

.settings-delete-timer {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
    padding: 6px 0 0;
}

.settings-delete-ring {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: conic-gradient(#ff3b30 calc(var(--pct, 0) * 1%), #f2f2f7 0);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.settings-delete-ring::before {
    content: "";
    position: absolute;
    inset: 5px;
    background: white;
    border-radius: 50%;
}

.settings-delete-ring span {
    position: relative;
    color: #1c1c1e;
    font-size: 1.2rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.settings-delete-hint {
    color: #636366;
    font-size: 0.86rem;
    font-weight: 600;
}

.settings-delete-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid #f2f2f7;
    background: #fafafa;
}

/* -- Settings overview tiles ------------------------------------------ */
.settings-overview {
    max-width: 1020px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.settings-tile {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px;
    background: white;
    border: 1.5px solid #e5e5ea;
    border-radius: 16px;
    box-shadow: 0 12px 28px rgba(28, 28, 30, 0.06);
    text-decoration: none;
    transition: border-color 0.15s, transform 0.12s, box-shadow 0.15s;
    cursor: pointer;
}

.settings-tile:hover {
    border-color: #007aff;
    transform: translateY(-2px);
    box-shadow: 0 18px 36px rgba(0, 122, 255, 0.12);
}

.settings-tile-icon {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    color: #007aff;
    background: #e8f3ff;
}

.settings-tile-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-tile-title {
    color: #1c1c1e;
    font-size: 1rem;
    font-weight: 800;
}

.settings-tile-desc {
    color: #636366;
    font-size: 0.86rem;
    font-weight: 500;
    line-height: 1.36;
}

.settings-tile-chevron {
    flex-shrink: 0;
    color: #c7c7cc;
    transition: transform 0.15s, color 0.15s;
}

.settings-tile:hover .settings-tile-chevron {
    color: #007aff;
    transform: translateX(2px);
}

/* -- NumPad popup (global, used by Material & Lohn settings pages) ----- */
.np-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: transparent;
}

.np-popup {
    position: fixed;
    z-index: 301;
    background: white;
    border: 1.5px solid #e5e5ea;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
    padding: 0 0 4px;
    display: flex;
    flex-direction: column;
    animation: settings-np-in 0.15s cubic-bezier(0.34, 1.3, 0.64, 1);
    width: 220px;
    height: 288px;
}

@keyframes settings-np-in {
    from {
        opacity: 0;
        transform: scale(0.92);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* -- Responsive -------------------------------------------------------- */
@media (max-width: 720px) {
    .settings-page {
        padding: 16px 12px 48px;
    }

    /* Einheitliche Höhe für alle Form-Elemente (Tap-Target) */
    .settings-input,
    .settings-calc-preview,
    .settings-btn,
    .settings-btn--sm,
    .settings-toggle,
    .settings-toggle-wrap {
        height: 44px;
        min-height: 44px;
    }

    .settings-color-input {
        height: 44px;
        width: 44px;
    }


    .settings-header {
        flex-direction: column;
        align-items: stretch;
        margin-bottom: 14px;
    }

    .settings-header h1 {
        font-size: 1.42rem;
    }

    .settings-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px 14px;
    }

    .settings-counter {
        font-size: 0.78rem;
    }

    .settings-toolbar .settings-btn {
        width: 100%;
    }

    .settings-inline-form {
        padding: 12px 14px;
    }

    .settings-inline-form .settings-input--erp,
    .settings-inline-form .settings-input--flex {
        width: 100%;
        flex: 1 1 100%;
    }

    .settings-list {
        padding: 6px 6px;
        max-height: none;
    }

    /* Compact one-line row on phone */
    .settings-row {
        gap: 6px;
        padding: 8px 10px;
        flex-wrap: nowrap;
    }

    .settings-drag-handle {
        width: 28px;
        height: 28px;
    }

    .settings-row-action {
        width: 30px;
        height: 30px;
    }

    .settings-row-icon {
        width: 28px;
        height: 28px;
    }

    .settings-badge {
        height: 22px;
        min-width: 36px;
        padding: 0 7px;
        font-size: 0.72rem;
    }

    .settings-cost-badge,
    .settings-status-badge {
        height: 24px;
        padding: 0 8px;
        font-size: 0.74rem;
    }

    .settings-row-text,
    .settings-row-body .settings-row-name {
        font-size: 0.88rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .settings-row-body .settings-row-meta {
        font-size: 0.74rem;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .settings-row-nav-btn {
        gap: 8px;
    }

    /* Produkt-Form sinnvoll umbrechen */
    .settings-produkt-form {
        padding: 12px 14px;
    }

    .settings-produkt-nums-row {
        gap: 8px;
    }

    .settings-field-label {
        flex: 1 1 calc(50% - 4px);
        min-width: 0;
    }

    .settings-field-label .settings-input--num,
    .settings-field-label .settings-input--unit {
        width: 100%;
    }

    /* Edit-Modus innerhalb der Liste */
    .settings-row--editing {
        padding: 12px;
        gap: 10px;
    }

    .settings-row--editing .settings-input--erp,
    .settings-row--editing .settings-input--flex {
        flex: 1 1 100%;
        width: 100%;
    }

    .settings-edit-actions {
        gap: 8px;
    }

    .settings-edit-actions .settings-btn {
        flex: 1;
    }

    /* Status-Form (Farbpicker + Presets) auf Mobile */
    .settings-color-input {
        flex-shrink: 0;
    }

    .settings-color-presets {
        flex: 1 1 100%;
        justify-content: flex-start;
    }

    /* Delete dialog */
    .settings-delete-card {
        width: 100%;
    }

    /* Tiles / breadcrumb */
    .settings-overview {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 420px) {
    .settings-row {
        gap: 4px;
        padding: 8px 8px;
    }

    .settings-drag-handle,
    .settings-row-icon {
        width: 26px;
        height: 26px;
    }

    .settings-row-action {
        width: 28px;
        height: 28px;
    }

    .settings-cost-badge,
    .settings-status-badge {
        display: none;
    }
}
