/* EduDex+ main stylesheet — modern SaaS design */

:root {
    --color-primary: #4f46e5;
    --color-primary-hover: #4338ca;
    --color-primary-light: #eef2ff;
    --color-danger: #ef4444;
    --color-danger-hover: #dc2626;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-bg: #f8fafc;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-secondary: #64748b;
    --color-text-muted: #94a3b8;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.04), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
    --transition: 150ms ease;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--color-text);
    background-color: #435165;
    margin: 0;
    padding-top: 24px; /* space for environment banner */
}

body.loggedin {
    background-color: var(--color-bg);
}

[x-cloak] {
    display: none !important;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    color: var(--color-text);
    line-height: 1.3;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.375rem; }
h3 { font-size: 1.125rem; }

a {
    color: var(--color-primary);
}

a:hover {
    color: var(--color-primary-hover);
}

/* ---------- Environment Banner ---------- */

.environment-banner {
    color: #fff;
    text-align: center;
    padding: 4px 0;
    font-size: 12px;
    font-weight: bold;
    letter-spacing: 1px;
    text-transform: uppercase;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
}

/* ---------- Messages ---------- */

.messages {
    max-width: 1200px;
    margin: 12px auto 0;
    padding: 0 16px;
}

.messages .message {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
}

.messages .message.success {
    background-color: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.messages .message.error {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.messages .message.warning {
    background-color: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.messages .message.info {
    background-color: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

/* ---------- Login / Register ---------- */

.login-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 48px);
    padding: 24px 16px;
}

.login {
    width: 440px;
    background-color: var(--color-surface);
    box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 1px 3px rgba(0,0,0,0.08);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.login-header {
    text-align: center;
    padding: 36px 32px 28px;
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    color: #fff;
}

.login-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: rgba(255,255,255,0.2);
    border-radius: 14px;
    font-size: 1.25rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}

.login-logo--success {
    background: rgba(255,255,255,0.2);
    font-size: 1.5rem;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 4px;
    padding: 0;
    color: #fff;
    border: none;
}

.login-subtitle {
    font-size: 14px;
    color: rgba(255,255,255,0.8);
    margin: 0;
    line-height: 1.5;
}

.login form {
    padding: 28px 32px 8px;
}

.login-field {
    margin-bottom: 20px;
}

.login-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.login-field input[type="text"],
.login-field input[type="password"],
.login-field input[type="email"],
.login-field input {
    width: 100%;
    height: 46px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0 14px;
    font-size: 15px;
    color: var(--color-text);
    background: var(--color-bg);
    transition: border-color var(--transition), box-shadow var(--transition), background-color var(--transition);
}

.login-field input:focus {
    background: var(--color-surface);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.login-alert {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 20px;
}

.login-alert p {
    margin: 0;
    font-size: 14px;
    color: #991b1b;
    line-height: 1.5;
}

.login-submit {
    display: block;
    width: 100%;
    padding: 13px;
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    font-family: inherit;
    color: #fff;
    transition: box-shadow var(--transition), transform var(--transition);
    margin-bottom: 20px;
}

.login-submit:hover {
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.35);
    transform: translateY(-1px);
}

.login-submit:active {
    transform: translateY(0);
    box-shadow: none;
}

.login-footer {
    text-align: center;
    padding: 0 32px 28px;
    font-size: 14px;
}

.login-footer a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

.login-footer a:hover {
    text-decoration: underline;
}

.login-message {
    padding: 0 32px;
}

.login-message p {
    font-size: 14px;
    color: var(--color-text-secondary);
    line-height: 1.6;
    margin: 0 0 20px;
}

.login-help {
    display: block;
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 6px;
    line-height: 1.5;
}

.login-lang {
    margin-top: 24px;
}

/* ---------- Focus States ---------- */

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* ---------- Base Input Styles ---------- */

input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
select,
textarea {
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.5;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

textarea {
    min-height: 80px;
    resize: vertical;
}

/* ---------- Top Navigation ---------- */

.navtop {
    background-color: #1e293b;
    height: 64px;
    width: 100%;
}

.navtop div {
    display: flex;
    align-items: center;
    margin: 0 auto;
    max-width: 1200px;
    padding: 0 16px;
    height: 100%;
}

.navtop div h1 {
    flex: 1;
    font-size: 1.25rem;
    padding: 0;
    margin: 0;
    color: #f1f5f9;
    font-weight: 600;
}

.navtop div a {
    padding: 0 16px;
    text-decoration: none;
    color: #94a3b8;
    font-weight: 500;
    font-size: 14px;
    transition: color var(--transition);
}

.navtop div a:hover {
    color: #f1f5f9;
}

.navtop .institute-name {
    color: #818cf8;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 500;
}

/* ---------- Institute Switcher ---------- */

.institute-switcher {
    position: relative;
}

.institute-switcher > a {
    color: #818cf8 !important;
    font-size: 13px !important;
}

.institute-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    min-width: 260px;
    z-index: 100;
    padding: 4px 0;
}

.institute-dropdown form {
    margin: 0;
}

.institute-dropdown button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 10px 16px;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-text);
    transition: background-color var(--transition);
}

.institute-dropdown button:hover {
    background-color: var(--color-primary-light);
}

.institute-dropdown button.active {
    color: var(--color-primary);
    font-weight: 600;
}

/* ---------- Sub Navigation ---------- */

.navbody div {
    display: flex;
    align-items: center;
    margin: 0 auto;
    padding: 16px 16px 12px;
    max-width: 1200px;
    border-bottom: 1px solid var(--color-border);
}

.navbody div h2 {
    flex: 1;
    font-size: 1.125rem;
    padding: 0;
    margin: 0;
    color: var(--color-text);
    font-weight: 600;
}

.navbody div a {
    padding: 0 16px;
    text-decoration: none;
    color: var(--color-text-secondary);
    font-weight: 500;
    font-size: 14px;
    transition: color var(--transition);
}

.navbody div a:hover {
    color: var(--color-primary);
}

/* ---------- Content ---------- */

.content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
}

.content .block {
    box-shadow: var(--shadow-sm);
    margin: 24px 0;
    padding: 32px;
    background-color: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
}

.content .block h2 {
    margin: 0 0 16px;
    color: var(--color-text);
    font-size: 1.25rem;
    font-weight: 600;
}

.content .block h3 {
    margin: 24px 0 12px;
    color: var(--color-text);
    font-size: 1rem;
    font-weight: 600;
}

.content .block p {
    padding: 4px 0;
    margin: 0 0 10px;
    color: var(--color-text-secondary);
}

/* ---------- Profile Page ---------- */

.profile-page {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 24px;
    margin: 24px 0;
    align-items: stretch;
}

.profile-sidebar .block {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.profile-sidebar-body {
    flex: 1;
}

.profile-sidebar-top {
    background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    padding: 32px 24px 28px;
    text-align: center;
}

.profile-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: #fff;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 14px;
    border: 3px solid rgba(255,255,255,0.3);
}

.profile-name {
    font-size: 1.125rem !important;
    margin: 0 0 8px !important;
    color: #fff !important;
}

.profile-role {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background: rgba(255,255,255,0.2);
    padding: 3px 14px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.profile-sidebar-body {
    padding: 20px 24px 24px;
}

.profile-meta {
    text-align: left;
}

.profile-meta-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
}

.profile-meta-item:last-child {
    border-bottom: none;
}

.profile-meta-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.profile-meta-value {
    font-size: 14px;
    color: var(--color-text);
    font-weight: 500;
}

.profile-action {
    display: block;
    width: 100%;
    margin-top: 16px;
    text-align: center;
}

.profile-main .block {
    margin: 0;
    height: 100%;
}

.profile-main .block h2 {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 24px;
}

.profile-main .form-group input[type="text"],
.profile-main .form-group input[type="email"] {
    max-width: 400px;
}

/* ---------- Password Change Page ---------- */

.password-change-page {
    max-width: 520px;
    margin: 24px 0;
}

.password-change-page .block {
    margin: 0;
}

.block-subtitle {
    color: var(--color-text-secondary);
    font-size: 14px;
    margin: -8px 0 24px;
}

/* ---------- Form Alert ---------- */

.form-alert {
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}

.form-alert p {
    margin: 0;
}

.form-alert--error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
}

/* ---------- Success Icon ---------- */

.success-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #f0fdf4;
    color: var(--color-success);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 16px;
    border: 2px solid #bbf7d0;
}

@media screen and (max-width: 768px) {
    .profile-page {
        grid-template-columns: 1fr;
    }
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-block;
    text-decoration: none;
    border: 0;
    cursor: pointer;
    color: var(--color-surface);
    background-color: var(--color-primary);
    margin: 0 6px 0 0;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.5;
    transition: background-color var(--transition), box-shadow var(--transition);
}

.btn:hover {
    background-color: var(--color-primary-hover);
    box-shadow: var(--shadow-sm);
    color: var(--color-surface);
    text-decoration: none;
}

.btn:active {
    transform: translateY(1px);
    box-shadow: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
    border-radius: 6px;
}

.btn-secondary {
    display: inline-block;
    text-decoration: none;
    cursor: pointer;
    color: var(--color-primary);
    background-color: var(--color-surface);
    border: 1px solid var(--color-primary);
    margin: 0 6px 0 0;
    padding: 9px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.5;
    transition: background-color var(--transition), box-shadow var(--transition);
}

.btn-secondary:hover {
    background-color: var(--color-primary-light);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
}

.btn-secondary:active {
    transform: translateY(1px);
    box-shadow: none;
}

.btn-danger {
    display: inline-block;
    text-decoration: none;
    border: 0;
    cursor: pointer;
    color: var(--color-surface);
    background-color: var(--color-danger);
    margin: 0 6px 0 0;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.5;
    transition: background-color var(--transition), box-shadow var(--transition);
}

.btn-danger:hover {
    background-color: var(--color-danger-hover);
    box-shadow: var(--shadow-sm);
    color: var(--color-surface);
    text-decoration: none;
}

.btn-danger:active {
    transform: translateY(1px);
    box-shadow: none;
}

/* Keep legacy class as alias */
.profile-btn { /* deprecated — use .btn */ }

/* ---------- Tabs ---------- */

.tab-header {
    position: relative;
}

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 24px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color var(--transition), border-color var(--transition), background-color var(--transition);
}

.tab-btn:hover {
    color: var(--color-primary);
    background-color: var(--color-primary-light);
    border-radius: var(--radius) var(--radius) 0 0;
}

.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tab-actions {
    position: absolute;
    top: 0;
    right: 0;
}

/* ---------- Imported Field Marking ---------- */

.imported-field {
    background-color: #fffbeb !important;
}

.imported-field input,
.imported-field select,
.imported-field textarea {
    background-color: #fffbeb;
}

/* ---------- Fieldset / Legend ---------- */

.form-table fieldset,
fieldset {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
    background: var(--color-surface);
}

fieldset legend {
    font-weight: 600;
    font-size: 13px;
    color: var(--color-primary);
    padding: 2px 10px;
    background: var(--color-primary-light);
    border-radius: 999px;
    letter-spacing: 0.01em;
}

/* ---------- Form Tables (key-value) ---------- */

.form-table {
    width: 100%;
    border-collapse: collapse;
}

.form-table th {
    text-align: right;
    padding: 10px 14px 10px 0;
    font-weight: 500;
    font-size: 13px;
    color: var(--color-text-secondary);
    width: 200px;
    vertical-align: top;
}

.form-table td {
    padding: 8px 0;
}

.form-table input,
.form-table select,
.form-table textarea {
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-table textarea {
    min-height: 80px;
    resize: vertical;
}

/* ---------- Formset Tables ---------- */

.formset-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.formset-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 13px;
    color: var(--color-text-secondary);
    border-bottom: 2px solid var(--color-border);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.formset-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.formset-table tbody tr:nth-child(even) {
    background-color: var(--color-bg);
}

.formset-table input,
.formset-table select,
.formset-table textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 13px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.formset-table textarea {
    min-height: 60px;
    resize: vertical;
}

/* Hide management/hidden fields in formset rows */
.formset-table input[type="hidden"] {
    display: none;
}

/* Delete checkbox styling in formset tables */
.formset-table .delete-col {
    width: 80px;
    text-align: center;
}

.btn-delete {
    display: inline-block;
    color: var(--color-danger);
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
    transition: background-color var(--transition), color var(--transition);
}

.btn-delete:hover {
    background-color: #fef2f2;
    color: var(--color-danger-hover);
}

/* Formset "add row" button */
.btn-formset-add {
    margin-top: 4px;
    margin-bottom: 16px;
}

/* ---------- Data Tables ---------- */

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--color-text-secondary);
    border-bottom: 2px solid var(--color-border);
    font-weight: 600;
}

table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
}

table tbody tr:hover {
    background-color: var(--color-bg);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--color-text-secondary);
    border-bottom: 2px solid var(--color-border);
    font-weight: 600;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
}

.data-table tbody tr:hover {
    background-color: var(--color-bg);
}

.data-table a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

.data-table a:hover {
    text-decoration: underline;
}

.data-table a.btn,
.data-table a.btn-secondary,
.data-table a.btn-danger {
    color: var(--color-surface);
    text-decoration: none;
}

.data-table a.btn-secondary {
    color: var(--color-primary);
}

/* ---------- Table Header ---------- */

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.table-header h2 {
    margin: 0;
}

/* ---------- Filter Bar ---------- */

.filter-bar {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 1.25rem;
}

.filter-bar input,
.filter-bar select {
    padding: 8px 12px;
    font-size: 14px;
}

.filter-bar input[type="text"] {
    flex: 1;
}

/* ---------- Dashboard ---------- */

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1.5rem 0;
}

.dashboard-card {
    padding: 1.25rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: box-shadow var(--transition);
}

.dashboard-card:hover {
    box-shadow: var(--shadow-md);
}

.dashboard-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.dashboard-card .stat-label {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-top: 4px;
}

.stat-value.success { color: var(--color-success); }
.stat-value.info { color: var(--color-primary); }
.stat-value.muted { color: var(--color-text-muted); }
.stat-value.default { color: var(--color-text); }

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.info-card {
    padding: 1.25rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.info-card strong {
    font-size: 13px;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.alert-banner {
    padding: 0.75rem 1rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    font-size: 14px;
    color: #92400e;
}

.alert-banner a {
    color: #92400e;
    font-weight: 600;
}

/* ---------- Form Groups ---------- */

.form-group p {
    margin: 0 0 16px;
}

.form-group label {
    display: block;
    padding: 0 0 6px;
    font-weight: 500;
    font-size: 13px;
    color: var(--color-text-secondary);
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="email"],
.form-group input[type="number"],
.form-group textarea,
.form-group select {
    padding: 10px 14px;
    width: 100%;
    max-width: 600px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-group select[multiple] {
    padding: 8px;
    max-width: 600px;
}

.form-group textarea {
    min-height: 100px;
    max-width: 600px;
    resize: vertical;
}

/* ---------- Quick Links ---------- */

.quick-links {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 10px;
}

/* ---------- Form Actions ---------- */

.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

/* ---------- Help Text & Field Errors ---------- */

.help-text {
    display: block;
    font-size: 13px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.field-error {
    display: block;
    font-size: 13px;
    color: var(--color-danger);
    margin-top: 4px;
}

/* ---------- Ticket Detail ---------- */

.ticket-body {
    margin: 24px 0;
    padding: 1.25rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    line-height: 1.7;
}

.comment {
    margin-bottom: 12px;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}

.comment-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 8px;
}

.comment-date {
    font-size: 13px;
    color: var(--color-text-muted);
}

.comment-body {
    line-height: 1.6;
}

.back-link {
    margin-top: 16px;
}

/* ---------- Pause Button ---------- */

.pause-btn.paused {
    background-color: var(--color-danger);
}

.pause-btn.paused:hover {
    background-color: var(--color-danger-hover);
}

/* ---------- Quill Editor ---------- */

.quill-editor {
    border: 1px solid var(--color-border);
    border-radius: 0 0 var(--radius) var(--radius);
    min-height: 150px;
    background: var(--color-surface);
}

.quill-editor .ql-editor {
    min-height: 120px;
    font-size: 14px;
    line-height: 1.6;
    font-family: inherit;
}

/* Override Quill toolbar to match design system */
.ql-toolbar.ql-snow {
    border: 1px solid var(--color-border);
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--color-bg);
}

.ql-container.ql-snow {
    border: none;
}

/* ---------- Stacked Formset Layout ---------- */

.formset-stacked {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 20px;
}

.formset-stacked-item {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    overflow: hidden;
}

.formset-stacked-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.formset-stacked-header label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.formset-stacked-header select {
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
}

.formset-stacked-header .delete-label {
    margin-left: auto;
    font-size: 13px;
    color: var(--color-danger);
    display: flex;
    align-items: center;
    gap: 4px;
}

.formset-stacked-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 14px;
}

.formset-stacked-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}

.formset-stacked-field textarea {
    width: 100%;
    min-height: 120px;
    resize: vertical;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
}

.formset-stacked-empty {
    padding: 14px;
    color: var(--color-text-muted);
    font-size: 14px;
}

/* ---------- Toast Notifications ---------- */

.toast-container {
    position: fixed;
    top: 32px;
    right: 16px;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background-color: #166534;
    color: #fff;
    padding: 12px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 500;
    pointer-events: auto;
    max-width: 360px;
}

/* ---------- Responsive ---------- */

@media screen and (max-width: 480px) {
    .login {
        width: 100%;
        border-radius: var(--radius-lg);
    }
    .login-header {
        padding: 28px 24px 24px;
    }
    .login form {
        padding: 24px 24px 8px;
    }
    .login-footer {
        padding: 0 24px 24px;
    }
}

@media screen and (max-width: 1200px) {
    .navtop {
        height: auto;
        padding: 12px 0;
    }
    .navtop div {
        flex-flow: wrap;
        max-width: 100%;
    }
    .navtop div h1 {
        display: block;
        flex-basis: 100%;
    }
    .navtop div a {
        padding: 10px 0;
        flex-basis: 50%;
    }
    .messages,
    .content {
        padding: 0 16px;
        max-width: 100%;
    }
    .content .block.profile form input[type="text"],
    .content .block.profile form input[type="password"],
    .content .block.profile form input[type="email"] {
        width: 100%;
        max-width: 100%;
    }

    /* Responsive formset tables */
    .formset-table {
        font-size: 13px;
    }
    .formset-table th,
    .formset-table td {
        padding: 6px 8px;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }

    .filter-bar {
        flex-wrap: wrap;
    }
}

/* Language toggle */
.lang-toggle {
    display: inline-flex;
    align-items: center;
    margin-left: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.lang-toggle form {
    display: inline;
}

.lang-toggle strong,
.lang-toggle button {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    font-family: inherit;
    font-weight: 600;
    line-height: 1;
    border: none;
    cursor: default;
}

.lang-toggle strong {
    background: rgba(255, 255, 255, 0.2);
    color: #f1f5f9;
}

.lang-toggle button {
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
}

.lang-toggle button:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #f1f5f9;
}

.lang-sep {
    display: none;
}

/* Login page language toggle */
.login-lang {
    text-align: center;
}

.login-lang .lang-toggle {
    margin-left: 0;
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.2);
}

.login-lang .lang-toggle strong {
    background: rgba(255,255,255,0.25);
    color: #f1f5f9;
}

.login-lang .lang-toggle button {
    color: rgba(255,255,255,0.6);
}

.login-lang .lang-toggle button:hover {
    background: rgba(255,255,255,0.2);
    color: #f1f5f9;
}
