:root {
    --bg-page: #f8fafc;
    --bg-nav: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;
    --bg-selected: #f3f0fb;
    --bg-archived: #f8fafc;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-light: #f8fafc;
    
    --primary: #513094;
    --primary-hover: #402377;
    --secondary: #e2e8f0;
    --secondary-hover: #cbd5e1;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --warning: #f59e0b;
    
    --border: #e2e8f0;
    --border-focus: #513094;
    
    --radius-md: 6px;
    --radius-lg: 10px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1);
    
    --font-sans: 'Inter', sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.5;
}

/* Typography */
h1, h2, h3 { font-weight: 600; color: var(--text-main); }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; }
.text-lg { font-size: 1.125rem; }
.text-danger { color: var(--danger); font-size: 0.875rem; }

.mb-0 { margin-bottom: 0 !important; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.block { display: block; }
.code-font { font-family: var(--font-mono); letter-spacing: 1px; }
.pointer { cursor: pointer; }
.text-center { text-align: center; }

.link-primary { color: var(--primary); text-decoration: none; font-weight: 500; }
.link-primary:hover { text-decoration: underline; }

/* Layouts */
.view { display: none; }
.view.active { display: block; }

.sub-view { display: none; animation: fadeIn 0.15s ease; }
.sub-view.active { display: block; }

#app-layout { display: flex; flex-direction: column; min-height: 100vh; }
.hidden { display: none !important; }

/* Top Nav */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--bg-nav);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 50;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.nav-brand .header-logo {
    width: 43px;
    height: 43px;
    object-fit: contain;
    vertical-align: middle;
}
.nav-brand .brand-text {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-muted);
    border-left: 1px solid var(--border);
    padding-left: 0.5rem;
}
.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Toast Feedback */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: #10b981;
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 999px;
    font-weight: 500;
    font-size: 0.875rem;
    z-index: 1000;
    box-shadow: var(--shadow-md);
    animation: slideUp 0.3s ease;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem 2rem 4rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.page-header {
    display: flex;
    flex-direction: column;
    margin-bottom: 2rem;
}
.breadcrumb { margin-bottom: 0.5rem; }

/* Dashboard Actions */
.dashboard-actions {
    display: flex;
    gap: 1.25rem;
    flex-wrap: wrap;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    padding: 1.5rem;
}
.filter-banner { padding: 1.25rem; background: var(--bg-hover); }
.max-w-md { max-width: 500px; }
.max-w-lg { max-width: 700px; }

/* Forms */
.form-group { margin-bottom: 1.5rem; }
label { display: block; margin-bottom: 0.5rem; font-size: 0.875rem; font-weight: 600; color: #334155; }
input[type="email"], input[type="text"], select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(81, 48, 148, 0.1);
}
.disabled-input { background-color: var(--bg-page); color: var(--text-muted); cursor: not-allowed; }
.form-actions { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 2rem; }
.divider { border: 0; border-top: 1px solid var(--border); margin: 2rem 0; }
.url-bar { display: flex; gap: 0.5rem; }
.url-bar input { flex: 1; min-width: 0; }
.flex-end { display: flex; align-items: flex-end; }

/* Tabs */
.tabs { display: flex; border-bottom: 1px solid var(--border); }
.tab-btn {
    padding: 0.75rem 1rem; cursor: pointer; border: none; background: transparent; 
    border-bottom: 2px solid transparent; font-size: 0.95rem; font-weight: 500; color: var(--text-muted);
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Worksheet Catalogue Picker */
.catalogue-list {
    max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-md);
}
.catalogue-item {
    padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); cursor: pointer; transition: background 0.15s;
}
.catalogue-item:last-child { border-bottom: none; }
.catalogue-item:hover { background: var(--bg-hover); }
.catalogue-item-title { font-weight: 600; display: block; color: var(--primary); margin-bottom: 0.125rem; }
.selected-box { border: 2px solid var(--border-focus); background: var(--bg-selected); padding: 1rem; border-radius: var(--radius-md); display: flex; justify-content: space-between; align-items: center; }

/* Inline Edit Lists */
.list-container { display: flex; flex-direction: column; }
.list-item {
    display: flex; justify-content: space-between; align-items: flex-start; padding: 1.25rem 1rem; border-bottom: 1px solid var(--border); gap: 1rem;
    transition: background 0.2s;
}
.list-item:last-child { border-bottom: none; }
.list-item.archived { background-color: var(--bg-archived); opacity: 0.8; border-left: 4px solid var(--text-muted); }
.list-item-content { flex: 1; display: flex; flex-direction: column; gap: 0.25rem; }
.list-item-actions { display: flex; gap: 0.5rem; align-items: flex-start; flex-wrap: wrap;}
.edit-input { width: 100%; max-width: 300px; }

/* Confirmation Boxes */
.confirm-box { 
    width: 100%; display: flex; justify-content: space-between; align-items: center; 
    background: #fee2e2; padding: 1rem; border-radius: var(--radius-md); border: 1px solid #fca5a5; flex-wrap: wrap; gap: 1rem;
}
.confirm-box.confirm-archive { background: #fef3c7; border: 1px solid #fde68a; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; padding: 0.625rem 1rem;
    border-radius: var(--radius-md); font-weight: 500; font-size: 0.875rem; cursor: pointer;
    border: none; font-family: inherit; transition: background-color 0.2s, color 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { background: var(--secondary); color: var(--text-muted); cursor: not-allowed; }
.btn-secondary { background: var(--secondary); color: var(--text-main); }
.btn-secondary:hover { background: var(--secondary-hover); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover { background: var(--danger); color: white; }
.btn-warning { background: transparent; color: #d97706; border: 1px solid #f59e0b; }
.btn-warning:hover { background: #f59e0b; color: white; border: 1px solid #f59e0b;}
.btn-text { background: transparent; color: var(--primary); padding: 0.25rem 0.5rem; }
.btn-text:hover { background: rgba(81, 48, 148, 0.05); }
.btn-block { width: 100%; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; }
.btn-lg { padding: 0.75rem 1.75rem; font-size: 1rem; }

/* Login */
.login-container {
    max-width: 400px; margin: 10vh auto; padding: 2.5rem; background: var(--bg-card);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-md); text-align: center;
}
.login-container .login-logo { width: 43px; height: 43px; object-fit: contain; margin-bottom: 1.5rem; display: block; margin-left: auto; margin-right: auto; }
.login-container .subtitle { margin-bottom: 2rem; color: var(--text-muted); font-size: 0.9rem;}
.login-container form { text-align: left; }

/* Tables */
.table-container { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; text-align: left; }
.data-table th, .data-table td { padding: 0.875rem 1rem; border-bottom: 1px solid var(--border); }
.data-table th { background: var(--bg-page); font-weight: 600; font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; transition: color 0.2s; }
.data-table th.sortable:hover { color: var(--text-main); }
.data-table th.active-sort { color: var(--primary); }
.data-table tr:hover { background-color: var(--bg-hover); }
.data-table tr.archived-row { opacity: 0.6; }

/* Filters */
.filters-grid { display: flex; gap: 1rem; }
.filters-grid .form-group { flex: 1; max-width: 250px; margin-bottom: 0; }

/* Task Details Specifics */
.badges { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.badge { background: var(--secondary); padding: 0.25rem 0.625rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; color: var(--text-main); }
.badge-archived { background: #f1f5f9; border: 1px solid #cbd5e1; color: var(--text-muted); }
.codes-row { display: flex; gap: 2rem; background: var(--bg-page); padding: 1rem; border-radius: var(--radius-md); border: 1px solid var(--border); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
