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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    background: #f0f2f5;
    color: #1a1a1a;
    line-height: 1.6;
    min-height: 100vh;
}

/* ============================================================
   Navbar
   ============================================================ */
.navbar {
    background: #1e3a5f;
    color: #fff;
    padding: 0 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.nav-brand {
    color: #fff;
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 700;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-links a {
    color: #c8d6e5;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: #fff;
}

.nav-user {
    color: #a0b4cc;
    font-size: 0.85rem;
    margin-right: 0.5rem;
}

/* ============================================================
   Container
   ============================================================ */
.container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

/* ============================================================
   Flash messages
   ============================================================ */
.flash {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.flash-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flash-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.flash-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.flash-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ============================================================
   Forms
   ============================================================ */
.form-wrapper {
    max-width: 520px;
    margin: 0 auto;
    background: #fff;
    padding: 2rem;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.form-wrapper h1 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: #1e3a5f;
}

.form-wrapper h2 {
    margin: 1.5rem 0 1rem;
    font-size: 1.15rem;
    color: #333;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: #444;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #1e3a5f;
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.15);
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn {
    display: inline-block;
    padding: 0.6rem 1.4rem;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: #1e3a5f;
    color: #fff;
}

.btn-primary:hover {
    background: #162d4a;
}

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

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

.btn-success {
    background: #28a745;
    color: #fff;
}

.btn-success:hover {
    background: #218838;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
}

/* ============================================================
   Tables
   ============================================================ */
.table-wrapper {
    overflow-x: auto;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table thead {
    background: #1e3a5f;
    color: #fff;
}

.table th {
    padding: 0.75rem 0.75rem;
    text-align: left;
    font-weight: 600;
    white-space: nowrap;
}

.table td {
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid #eee;
}

.table tbody tr:hover {
    background: #f5f7fa;
}

.desc-cell {
    max-width: 280px;
    white-space: normal;
    word-break: break-word;
}

.row-completed {
    background: #f0fff0;
}

.row-pending {
    background: #fff;
}

.row-controlled {
    background: #f0fff0;
}

.row-uncontrolled {
    background: #fff;
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-controlled {
    background: #d4edda;
    color: #155724;
}

.badge-uncontrolled {
    background: #fff3cd;
    color: #856404;
}

/* ============================================================
   Toolbar
   ============================================================ */
.toolbar {
    margin-bottom: 1rem;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

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

.modal {
    background: #fff;
    padding: 2rem;
    border-radius: 10px;
    width: 90%;
    max-width: 440px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.modal h2 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.modal-close {
    float: right;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    color: #999;
    line-height: 1;
}

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

.actions-cell {
    white-space: nowrap;
}

.actions-cell .btn {
    margin-right: 0.4rem;
}

/* ============================================================
   Info / Success boxes
   ============================================================ */
.success-box {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1.5rem;
    color: #155724;
}

.info-box {
    background: #e7f0fd;
    border: 1px solid #b8d4f0;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.info-warning {
    background: #fff3cd;
    border-color: #ffeeba;
    color: #856404;
}

.link-display {
    display: block;
    background: #f5f5f5;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.85rem;
    word-break: break-all;
    margin: 0.5rem 0;
}

.hint {
    font-size: 0.85rem;
    color: #666;
    margin-top: 0.25rem;
}

/* ============================================================
   Empty / Error pages
   ============================================================ */
.empty-message {
    text-align: center;
    color: #888;
    padding: 2rem;
    font-size: 1rem;
}

.error-page {
    text-align: center;
    padding: 4rem 1rem;
}

.error-page h1 {
    font-size: 4rem;
    color: #1e3a5f;
    margin-bottom: 0.5rem;
}

.error-page p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 1.5rem;
}

/* ============================================================
   Thanks page
   ============================================================ */
.thanks-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.thanks-box {
    text-align: center;
    background: #fff;
    padding: 3rem;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.thanks-box h1 {
    font-size: 2rem;
    color: #1e3a5f;
    margin-bottom: 0.75rem;
}

.thanks-box p {
    font-size: 1.2rem;
    color: #555;
}

/* ============================================================
   Sortable table headers
   ============================================================ */
.sortable a {
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
}

.sortable a:hover {
    text-decoration: underline;
}

/* ============================================================
   Link row (copy button)
   ============================================================ */
.link-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.5rem 0;
}

.link-row .link-display {
    flex: 1;
    margin: 0;
}

/* ============================================================
   Danger button
   ============================================================ */
.btn-danger {
    background: #dc3545;
    color: #fff;
}

.btn-danger:hover {
    background: #c82333;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        height: auto;
        padding: 0.75rem 0;
        gap: 0.5rem;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }

    .container {
        padding: 0 0.75rem;
        margin: 1rem auto;
    }

    .form-wrapper {
        padding: 1.25rem;
    }

    .form-actions {
        flex-direction: column;
    }

    .table {
        font-size: 0.8rem;
    }

    .table th,
    .table td {
        padding: 0.4rem 0.4rem;
    }
}
