/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: #f0f2f5;
    color: #1a1a2e;
    line-height: 1.5;
    min-height: 100vh;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

.login-container {
    background: #fff;
    border-radius: 12px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 24px;
    color: #1a1a2e;
    margin-bottom: 4px;
}

.login-header p {
    color: #666;
    font-size: 14px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #444;
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #0f3460;
    box-shadow: 0 0 0 3px rgba(15, 52, 96, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    gap: 6px;
}

.btn-primary {
    background: #0f3460;
    color: #fff;
}

.btn-primary:hover {
    background: #1a4a7a;
}

.btn-secondary {
    background: #e5e7eb;
    color: #374151;
}

.btn-secondary:hover {
    background: #d1d5db;
}

.btn-outline {
    background: transparent;
    color: #374151;
    border: 1px solid #d1d5db;
}

.btn-outline:hover {
    background: #f3f4f6;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-full {
    width: 100%;
}

/* Error message */
.error-message {
    background: #fef2f2;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid #fecaca;
}

/* Header */
.app-header {
    background: #1a1a2e;
    color: #fff;
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left h1 {
    font-size: 18px;
    font-weight: 700;
}

.header-left .subtitle {
    font-size: 12px;
    color: #94a3b8;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex: 1;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.user-email {
    font-size: 13px;
    color: #94a3b8;
}

.access-badge {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
}

.access-badge.write {
    background: #059669;
    color: #fff;
}

.access-badge.read {
    background: #6366f1;
    color: #fff;
}

.header-user .btn-outline {
    color: #94a3b8;
    border-color: #475569;
}

.header-user .btn-outline:hover {
    background: #334155;
    color: #fff;
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-toggle {
    color: #e2e8f0;
    border-color: #475569;
}

.dropdown-toggle:hover {
    background: #334155;
    color: #fff;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    min-width: 320px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 200;
    margin-top: 4px;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: #374151;
    text-decoration: none;
    font-size: 13px;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
    word-break: break-word;
}

.dropdown-menu a:last-child {
    border-bottom: none;
}

.dropdown-menu a:hover {
    background: #f0f2f5;
}

/* Main content */
.content {
    padding: 24px;
}

.table-container {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    overflow-x: auto;
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead {
    background: #f8fafc;
    position: sticky;
    top: 0;
}

thead th {
    padding: 12px 14px;
    text-align: left;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #e2e8f0;
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s;
}

tbody tr:hover {
    background: #f8fafc;
}

tbody tr.selected {
    background: #eff6ff;
}

tbody td {
    padding: 10px 14px;
    vertical-align: top;
}

.col-check {
    width: 40px;
    text-align: center;
}

.col-id {
    width: 40px;
    text-align: center;
}

.col-category {
    min-width: 200px;
    font-weight: 600;
}

.col-action {
    min-width: 250px;
}

.col-before,
.col-critical {
    min-width: 130px;
}

.col-why {
    min-width: 200px;
}

.col-status {
    min-width: 140px;
}

.loading {
    text-align: center;
    padding: 40px;
    color: #94a3b8;
    font-style: italic;
}

/* Status select in table */
.status-select {
    padding: 6px 10px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    background: #fff;
}

.status-select:disabled {
    cursor: default;
    opacity: 1;
    background: transparent;
    border-color: transparent;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.status-select.status-not-started { color: #6b7280; }
.status-select.status-started { color: #2563eb; }
.status-select.status-completed { color: #059669; }
.status-select.status-paused { color: #d97706; }
.status-select.status-cancelled { color: #dc2626; }

/* Status badge (read-only display) */
.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.status-not-started { background: #f3f4f6; color: #6b7280; }
.status-badge.status-started { background: #dbeafe; color: #2563eb; }
.status-badge.status-completed { background: #d1fae5; color: #059669; }
.status-badge.status-paused { background: #fef3c7; color: #d97706; }
.status-badge.status-cancelled { background: #fee2e2; color: #dc2626; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h2 {
    font-size: 18px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #9ca3af;
    line-height: 1;
}

.modal-close:hover {
    color: #374151;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
}

/* Toast notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
}

.toast.success { background: #059669; }
.toast.error { background: #dc2626; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateY(10px); }
}

/* Responsive */
@media (max-width: 768px) {
    .app-header {
        padding: 10px 16px;
    }

    .header-actions {
        order: 3;
        width: 100%;
        justify-content: flex-start;
    }

    .content {
        padding: 12px;
    }

    .modal {
        margin: 16px;
        max-width: calc(100% - 32px);
    }
}
