:root {
    --primary-color: #4CAF50;
    --primary-dark: #388E3C;
    --glass-bg: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    --text-color: #2c3e50;
    --input-bg: rgba(255, 255, 255, 0.9);
    --border-radius: 16px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #a8e063 0%, #56ab2f 100%);
    color: var(--text-color);
    line-height: 1.6;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.container {
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 30px;
    border-radius: var(--border-radius);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

header {
    margin-bottom: 25px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    padding: 0 10px;
    gap: 15px;
    /* Add gap between elements */
}

.logo {
    height: 50px;
    width: auto;
    max-width: 70px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

h1 {
    color: var(--primary-dark);
    font-size: 1.8rem;
    margin-bottom: 2px;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
    font-weight: 800;
    line-height: 1.2;
}

h2 {
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0.8;
    margin-top: 0;
}

.title-container {
    text-align: center;
    flex: 1;
    /* Take remaining space */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 15px;
}

.half-width {
    flex: 1;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    color: #444;
}

input,
select,
textarea {
    width: 100%;
    padding: 14px;
    background: var(--input-bg);
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
    transform: translateY(-1px);
}

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

button {
    width: 100%;
    padding: 16px;
    background: linear-gradient(145deg, #4CAF50, #45a049);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(76, 175, 80, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

button:hover {
    background: linear-gradient(145deg, #45a049, #388E3C);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(76, 175, 80, 0.4);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

#statusMessage {
    margin-top: 20px;
    padding: 15px;
    border-radius: 12px;
    text-align: center;
    font-weight: bold;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

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

.success {
    background-color: rgba(232, 245, 233, 0.9);
    color: #2E7D32;
    border: 1px solid #C8E6C9;
}

.error {
    background-color: rgba(255, 235, 238, 0.9);
    color: #C62828;
    border: 1px solid #FFCDD2;
}

.hidden {
    display: none;
}

/* Tabs */
.tabs {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
}

.tab-btn {
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.6);
    padding: 10px 20px;
    border-radius: 20px;
    color: #1a4d1c;
    /* Dark Green Text */
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: #4CAF50;
    color: white;
    /* Keep white for active tab */
    border-color: #4CAF50;
    box-shadow: 0 4px 15px rgba(76, 175, 80, 0.3);
}

/* List View */
.list-controls {
    margin-bottom: 20px;
}

#searchInput {
    width: 100%;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.6);
    color: #333;
    font-size: 16px;
}

#searchInput::placeholder {
    color: #555;
    opacity: 0.8;
}

.actions-grid {
    display: grid;
    gap: 15px;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 5px;
}

/* Scrollbar */
.actions-grid::-webkit-scrollbar {
    width: 6px;
}

.actions-grid::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

/* Action Card */
.action-card {
    background: rgba(255, 255, 255, 0.6);
    /* More opaque */
    border: 1px solid rgba(255, 255, 255, 0.8);
    border-radius: 15px;
    padding: 15px;
    transition: transform 0.2s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.action-card:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.8);
}

.action-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    color: #555;
    /* Darker gray */
    margin-bottom: 8px;
    font-weight: 500;
}

.action-unit {
    background: #4CAF50;
    color: white;
    padding: 2px 8px;
    border-radius: 8px;
    font-size: 0.8em;
}

.action-title {
    margin: 0 0 10px 0;
    font-size: 1.1em;
    color: #1a4d1c;
    /* Dark Green */
    font-weight: 700;
}

.action-detail {
    margin: 5px 0;
    font-size: 0.95em;
    color: #333;
    /* Black/Dark Gray */
}

.action-detail strong {
    color: #000;
}

.action-actions {
    display: flex;
    flex-direction: row;
    gap: 10px;
    margin-top: 15px;
    justify-content: flex-end;
}

.edit-btn,
.delete-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.9em;
    cursor: pointer;
    border: none;
    color: white;
    font-weight: 600;
    text-transform: uppercase;
}

.edit-btn {
    background: #2196F3;
    box-shadow: 0 2px 5px rgba(33, 150, 243, 0.3);
}

.delete-btn {
    background: #F44336;
    box-shadow: 0 2px 5px rgba(244, 67, 54, 0.3);
}

.form-actions-group {
    display: flex;
    gap: 15px;
}

.form-actions-group button {
    flex: 1;
    /* Equal width */
    width: auto;
    /* Override 100% */
}

.cancel-btn {
    background: #9E9E9E;
    /* margin-left: 10px; REMOVED default margin, using gap */
    color: white;
    padding: 12px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
}

.loading-text,
.empty-text,
.error-text {
    text-align: center;
    color: #333;
    padding: 20px;
    font-weight: 500;
}

@media (max-width: 600px) {
    body {
        padding: 0;
        align-items: flex-start;
        /* Allow full height scrolling */
    }

    .container {
        padding: 15px;
        /* Internal padding */
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        min-height: 100vh;
        /* Full height */
        border: none;
        box-shadow: none;
    }

    .header-content {
        flex-direction: row;
        /* Match screenshot: Row layout */
        gap: 10px;
        justify-content: space-between;
    }

    .form-row {
        flex-direction: row;
        /* Match screenshot: Side-by-side inputs */
        gap: 10px;
    }

    .half-width {
        width: 50%;
        /* Ensure equal split */
    }

    .action-card * {
        color: inherit;
        /* Reset to parent */
    }

    .action-title {
        color: #1a4d1c !important;
        /* Force Dark Green */
    }

    .action-detail,
    .action-detail strong,
    .action-date,
    .action-unit {
        color: #333 !important;
        /* Force Black/Dark Gray */
    }

    .action-unit {
        color: white !important;
        /* Keep unit badge white text */
    }

    h1 {
        font-size: 1.3rem;
    }

    h2 {
        font-size: 0.8rem;
    }

    .title-container {
        margin: 5px 0;
        order: 0;
        /* Keep natural order */
    }

    .logo {
        max-width: 45px;
        height: auto;
        max-height: 45px;
        flex-shrink: 0;
    }
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 15px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    animation: modalSlide 0.3s ease;
}

@keyframes modalSlide {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

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

.modal h3 {
    color: #e74c3c;
    margin-bottom: 10px;
}

.modal p {
    color: #555;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 15px;
}

.modal-btn {
    padding: 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    flex: 1;
}

.modal-btn.cancel {
    background: #e0e0e0;
    color: #333;
}

.modal-btn.confirm {
    background: #e74c3c;
    color: white;
}

/* Success Modal Specifics */
.success-icon {
    margin: 0 auto 15px;
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.success-icon svg {
    width: 100%;
    height: 100%;
    fill: #4CAF50;
    /* Green */
}

.full-width {
    width: 100%;
    margin-top: 15px;
    background: #4CAF50 !important;
    /* Always Green for Success OK */
}

/* Login specific styles */
#loginSection {
    text-align: center;
}

#loginSection h3 {
    color: var(--primary-dark);
    margin-bottom: 20px;
}

.login-error {
    color: #e74c3c;
    background: #fdf0ef;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: none;
    font-weight: 500;
}

.logout-btn {
    position: absolute;
    top: 50%;
    right: 15px;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.6);
    color: var(--primary-dark);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    width: auto;
    box-shadow: none;
    display: none;
    /* Shown via JS */
}

.logout-btn:hover {
    background: #4CAF50;
    color: white;
}

/* --- Settings Gear Button --- */
.settings-btn {
    background: rgba(255, 255, 255, 0.5) !important;
    border: 1px solid rgba(255, 255, 255, 0.6) !important;
    cursor: pointer;
    padding: 7px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    box-shadow: none !important;
    width: 38px !important;
    height: 38px !important;
    min-width: unset;
    flex-shrink: 0;
    text-transform: none;
    letter-spacing: 0;
    transition: background 0.3s, transform 0.3s !important;
}

.settings-btn.hidden {
    display: none !important;
}

.settings-btn:hover {
    background: white !important;
    transform: rotate(30deg) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
}

.gear-icon {
    width: 22px;
    height: 22px;
    fill: var(--primary-dark);
    display: block;
}

/* --- Settings Modal --- */
.settings-modal-content {
    text-align: left !important;
    padding: 25px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.settings-modal-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f5f5f5 !important;
    color: #333 !important;
    font-size: 1rem;
    font-weight: 600;
    padding: 14px 18px !important;
    border-radius: 12px;
    cursor: pointer;
    text-transform: none;
    width: 100%;
    box-shadow: none !important;
    border: 1px solid #eee;
    text-align: left;
    transition: background 0.2s;
}

.settings-modal-btn:hover {
    background: #e8f5e9 !important;
    color: var(--primary-dark) !important;
    transform: none !important;
    box-shadow: none !important;
}

.settings-modal-btn.logout-modal-btn:hover {
    background: #fdf0ef !important;
    color: #e74c3c !important;
}

/* --- Settings Container (layout) --- */
.settings-container {
    position: relative;
    display: flex;
    align-items: center;
}

@media (max-width: 600px) {
    .settings-container {
        position: static;
        margin: auto 0;
    }

    .logout-btn {
        position: static;
        transform: none;
        margin: auto 0;
    }
}

/* --- User Row Layout --- */
.user-row-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: #f8f8f8;
    border-radius: 10px;
    border: 1px solid #eee;
}

.user-row-info {
    flex: 1;
    min-width: 0;
}

.user-row-name {
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-row-email {
    font-size: 0.8rem;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-row-actions {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-shrink: 0;
    margin-left: 10px;
}

.user-row-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.user-col-header {
    font-size: 0.7rem;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- Toggle Switch --- */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 22px;
    transition: background 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.toggle-switch input:checked+.toggle-slider {
    background: #4CAF50;
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(18px);
}

/* --- Key Action Button --- */
.key-btn {
    width: 34px !important;
    height: 34px !important;
    padding: 6px !important;
    background: #f0f0f0 !important;
    border: 1px solid #ddd !important;
    border-radius: 8px !important;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    box-shadow: none !important;
    transition: background 0.2s !important;
    text-transform: none;
}

.key-btn:hover {
    background: #e0e0e0 !important;
    transform: none !important;
    box-shadow: none !important;
}

/* --- Edit Panel --- */
.user-edit-panel {
    background: #f5f5f5;
    border-radius: 10px;
    padding: 12px;
    margin-top: 6px;
    border: 1px solid #e0e0e0;
}