:root {
    --primary: #2563eb;
    --primary-dark: #1e40af;
    --primary-light: #dbeafe;
    --danger: #ef4444;
    --success: #10b981;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-secondary: #64748b;
    --bg: #f8fafc;
    --card: #ffffff;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.login-card {
    background: var(--card);
    border-radius: 24px;
    box-shadow: 0 32px 80px rgba(0, 0, 0, 0.25);
    padding: 1rem;
    width: 100%;
    max-width: 380px;
}

/* Header */
.card-header {
    text-align: center;
    margin-bottom: 1.75rem;
}

.brand-icon {
    width: 48px;
    height: 48px;
    background: var(--primary);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    margin: 0 auto 1rem;
}

.card-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.card-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* User Dropdown */
.dropdown-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.4rem;
}

select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s, box-shadow 0.2s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 2.5rem;
}

select:focus {
    border-color: var(--primary);
    background-color: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

select.input-error {
    border-color: var(--danger);
}

/* Code display */
.code-display {
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    text-align: center;
    font-size: 2rem;
    letter-spacing: 8px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1.25rem;
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.2s;
}

.code-display.has-input {
    border-color: var(--primary);
    background: white;
}

.code-display.error {
    border-color: var(--danger);
}

.code-display .placeholder {
    font-size: 0.875rem;
    letter-spacing: 0;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Dial Pad */
.dial-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.625rem;
    margin-bottom: 1.25rem;
}

.dial-key {
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 0.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    font-family: inherit;
    color: var(--text);
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
    user-select: none;
}

.dial-key:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}

.dial-key:active {
    transform: scale(0.95);
}

.dial-key.zero {
    grid-column: 2;
}

.dial-key.delete-key {
    background: #fef2f2;
    border-color: #fca5a5;
    color: var(--danger);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.85rem;
    grid-column: 3;
}

.dial-key.delete-key:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* Proceed Button */
.btn-proceed {
    width: 100%;
    padding: 0.9rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-proceed:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-proceed:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Field error */
.field-error {
    font-size: 0.775rem;
    color: var(--danger);
    margin-top: 0.3rem;
    display: none;
}

/* Admin link */
.admin-link {
    text-align: center;
    margin-top: 1.25rem;
    font-size: 0.825rem;
    color: var(--text-secondary);
}

.admin-link a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.admin-link a:hover {
    text-decoration: underline;
}

/* Toast */
.toast {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    padding: 0.875rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    z-index: 9999;
    display: none;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    max-width: 320px;
    animation: slideIn 0.3s ease;
}

.toast.success {
    background: var(--success);
    display: flex;
}

.toast.error {
    background: var(--danger);
    display: flex;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}


/* Custom dropdown — iPad only */
.custom-select-wrapper {
    position: relative;
    width: 100%;
}

.custom-select-trigger {
    width: 100%;
    padding: 0.875rem 1.25rem;
    border: 1.5px solid var(--border);
    border-radius: 14px;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    outline: none;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.custom-select-trigger:focus,
.custom-select-trigger.open {
    border-color: var(--primary);
    background-color: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.custom-select-trigger.input-error {
    border-color: var(--danger);
}

.custom-select-trigger svg {
    flex-shrink: 0;
    transition: transform 0.2s;
}

.custom-select-trigger.open svg {
    transform: rotate(180deg);
}

.custom-select-options {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    /* ← stays within card width */
    background: white;
    border: 1.5px solid var(--primary);
    border-radius: 14px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    z-index: 100;
    list-style: none;
    padding: 6px;
    max-height: 220px;
    /* ← scrolls inside, never overflows card */
    overflow-y: auto;
}

.custom-select-options.open {
    display: block;
}

.custom-select-option {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 1rem;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s;
}

.custom-select-option:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.custom-select-option.selected {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.custom-select-option[data-value=""] {
    color: var(--text-secondary);
}

/* ── iPad / Tablet Responsive (768px – 1024px) ──────────────────────────── */
@media (min-width: 768px) and (max-width: 1024px) {

    body {
        padding: 2rem;
        align-items: center;
    }

    .login-card {
        max-width: 480px;
        padding: 2.5rem;
        border-radius: 28px;
    }

    .brand-icon {
        width: 64px;
        height: 64px;
        border-radius: 18px;
    }

    .brand-icon svg {
        width: 36px;
        height: 36px;
    }

    .card-title {
        font-size: 1.85rem;
    }

    .card-subtitle {
        font-size: 0.95rem;
    }

    .card-header {
        margin-bottom: 2rem;
    }

    /* Dropdown */
    select {
        padding: 0.875rem 1.25rem;
        font-size: 1rem;
        border-radius: 14px;
    }

    .dropdown-group {
        margin-bottom: 1.5rem;
    }

    label {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }

    /* Code display — bigger on iPad */
    .code-display {
        font-size: 2.5rem;
        letter-spacing: 14px;
        min-height: 76px;
        border-radius: 14px;
        margin-bottom: 1.5rem;
    }

    /* Dial pad — bigger keys with more spacing */
    .dial-pad {
        gap: 0.875rem;
        margin-bottom: 1.5rem;
    }

    .dial-key {
        padding: 1.25rem 0.5rem;
        font-size: 1.5rem;
        border-radius: 14px;
    }

    .dial-key.delete-key {
        font-size: 1rem;
    }

    .dial-key.delete-key svg {
        width: 22px;
        height: 22px;
    }

    /* Proceed button */
    .btn-proceed {
        padding: 1.1rem;
        font-size: 1.1rem;
        border-radius: 14px;
    }

    .btn-proceed svg {
        width: 22px;
        height: 22px;
    }

    /* Admin link */
    .admin-link {
        margin-top: 1.5rem;
        font-size: 0.9rem;
    }

    /* Field errors */
    .field-error {
        font-size: 0.825rem;
    }

    /* Toast */
    .toast {
        max-width: 380px;
        font-size: 0.95rem;
        padding: 1rem 1.5rem;
    }

    .custom-select-trigger {
        padding: 0.875rem 1.25rem;
        /* bigger tap target on iPad */
        font-size: 1rem;
        border-radius: 14px;
    }

    .custom-select-options {
        border-radius: 14px;
    }

    .custom-select-option {
        font-size: 1rem;
        padding: 0.75rem 1rem;
    }
}