:root {
    --primary: #2271b1;
    --primary-hover: #135e96;
    --bg-color: #f8fafc;
    --surface: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 8px;
    --success: #10b981;
    --warning: #f59e0b;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
}

/* Navbar */
.navbar {
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary);
    margin-right: 2rem;
}

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

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    transition: all 0.2s;
}

.nav-links a:hover {
    color: var(--primary);
    background: #f1f5f9;
}

.nav-links a.active {
    color: var(--primary);
    background: #e0e7ff;
    font-weight: 600;
}

.badge {
    background-color: #e0e7ff;
    color: #4338ca;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Main Container */
.container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1rem;
}

/* Header TITLE */
.header-title {
    margin-bottom: 2rem;
}

.header-title h1 {
    font-size: 1.875rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.header-title p {
    color: var(--text-muted);
}

/* Controls Wrapper */
.controls-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    align-items: flex-end;
    justify-content: space-between;
    background: var(--surface);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.search-wrapper {
    flex: 1;
    min-width: 300px;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-box i, .search-box svg {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    width: 18px;
    height: 18px;
}

.search-box input[type="text"] {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    outline: none;
    transition: all 0.2s;
    background-color: #f8fafc;
}

.search-box input:focus {
    border-color: var(--primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.2);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-left: 2px;
}

.filters-actions-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    flex-wrap: wrap;
}

.filter-select {
    width: auto;
    min-width: 200px;
}

.divider {
    width: 1px;
    height: 38px;
    background-color: var(--border);
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.stat-card h3 {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.stat-card .value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

/* Table */
.table-container {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    background-color: #f8fafc;
    padding: 1rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

th[data-sort] {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: color 0.2s;
}

th[data-sort]:hover {
    color: var(--primary);
}

th[data-sort]::after {
    content: '⇅';
    margin-left: 6px;
    font-size: 0.7rem;
    opacity: 0.4;
    transition: opacity 0.2s;
}

th[data-sort].sort-asc::after {
    content: '▲';
    opacity: 1;
    color: var(--primary);
}

th[data-sort].sort-desc::after {
    content: '▼';
    opacity: 1;
    color: var(--primary);
}

td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.875rem;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover {
    background-color: #f1f5f9;
}

.loading {
    text-align: center;
    padding: 3rem !important;
    color: var(--text-muted);
    font-style: italic;
}

.empty-state {
    text-align: center;
    padding: 3rem !important;
    color: var(--text-muted);
}

/* Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: capitalize;
}

.status-submitted { background: #e0e7ff; color: #4338ca; }
.status-under_review { background: #fef3c7; color: #d97706; }
.status-accepted { background: #d1fae5; color: #059669; }
.status-rejected { background: #fee2e2; color: #dc2626; }
.status-withdrawn { background: #f1f5f9; color: #475569; }

/* UUID copy chip */
.uuid-copy {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 11px;
    color: var(--text-muted);
    background: #f1f5f9;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.uuid-copy:hover {
    background: #e0e7ff;
    color: var(--primary);
}

/* Buttons */
.actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: #f1f5f9;
    color: var(--text-main);
    border-color: #cbd5e1;
}

.btn-icon.danger:hover {
    background: #fee2e2;
    color: #dc2626;
    border-color: #fca5a5;
}

.btn-icon i, .btn-icon svg {
    width: 16px;
    height: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-secondary {
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: #f1f5f9;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: #cbd5e1;
    color: #475569;
    border-color: #cbd5e1;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 50;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    background: var(--surface);
    width: 100%;
    max-width: 600px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.25rem;
}

.email-modal {
    max-width: 800px;
}

.selected-recipients-info {
    background-color: #e0e7ff;
    border: 1px solid #c7d2fe;
    color: #3730a3;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.placeholders-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.placeholders-legend code {
    background: #e0e7ff;
    color: #4338ca;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
}

.placeholders-legend code:hover {
    background: #4338ca;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(67, 56, 202, 0.3);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

input[type="text"],
input[type="email"],
textarea,
select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
}

textarea {
    resize: vertical;
}

.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.checkbox input {
    width: auto;
}

.checkbox label {
    margin-bottom: 0;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #1e293b;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    transform: translateY(150%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
}

.toast.show {
    transform: translateY(0);
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}
