:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --sidebar: #1e293b;
    --sidebar-hover: #334155;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
}

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

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

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--sidebar);
    color: #fff;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    font-size: 1.25rem;
    font-weight: 700;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-nav { padding: 1rem 0; flex: 1; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: #cbd5e1;
    text-decoration: none;
    transition: background 0.15s;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
    background: var(--sidebar-hover);
    color: #fff;
    text-decoration: none;
}

.sidebar-user {
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.875rem;
    color: #94a3b8;
}

.main-content {
    flex: 1;
    padding: 2rem;
    overflow-x: auto;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header h1 { font-size: 1.5rem; font-weight: 600; }

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

.stat-card {
    background: var(--card);
    border-radius: 8px;
    padding: 1.25rem;
    border: 1px solid var(--border);
}

.stat-card .label { font-size: 0.875rem; color: var(--text-muted); }
.stat-card .value { font-size: 2rem; font-weight: 700; margin-top: 0.25rem; }
.stat-card.open .value { color: var(--primary); }
.stat-card.pending .value { color: var(--warning); }
.stat-card.resolved .value { color: var(--success); }

.card {
    background: var(--card);
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}

.card-body { padding: 1.25rem; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); font-weight: 600; }
tr:hover { background: #f8fafc; }

.badge {
    display: inline-block;
    padding: 0.125rem 0.625rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-open { background: #dbeafe; color: #1d4ed8; }
.badge-pending { background: #fef3c7; color: #b45309; }
.badge-resolved { background: #dcfce7; color: #15803d; }
.badge-closed { background: #f1f5f9; color: #475569; }

.priority { font-size: 0.75rem; font-weight: 600; }
.priority-low { color: var(--text-muted); }
.priority-medium { color: var(--primary); }
.priority-high { color: var(--warning); }
.priority-urgent { color: var(--danger); }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.375rem; }
.form-control {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
textarea.form-control { min-height: 120px; resize: vertical; }
select.form-control { appearance: auto; }

.filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filters .form-control { width: auto; min-width: 150px; }

.ticket-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.meta-item label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }
.meta-item .value { font-weight: 500; margin-top: 0.25rem; }

.replies { margin-top: 1.5rem; }
.reply {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 0.75rem;
}
.reply.internal { background: #fffbeb; border-color: #fde68a; }
.reply-header { display: flex; justify-content: space-between; margin-bottom: 0.5rem; font-size: 0.875rem; }
.reply-author { font-weight: 600; }
.reply-time { color: var(--text-muted); }
.reply-body { white-space: pre-wrap; }

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
}

.login-card {
    background: var(--card);
    padding: 2.5rem;
    border-radius: 12px;
    width: 100%;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-card h1 { margin-bottom: 0.5rem; }
.login-card p { color: var(--text-muted); margin-bottom: 2rem; }

.btn-microsoft {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem;
    background: #2f2f2f;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.9375rem;
    cursor: pointer;
    text-decoration: none;
}
.btn-microsoft:hover { background: #1a1a1a; color: #fff; text-decoration: none; }

.pagination {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}
.pagination a, .pagination span {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.875rem;
}
.pagination .active { background: var(--primary); color: #fff; border-color: var(--primary); }

.portal-layout { max-width: 640px; margin: 3rem auto; padding: 0 1rem; }
.portal-layout h1 { margin-bottom: 1.5rem; }

.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.sla-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}
.sla-ok { background: #dcfce7; color: #15803d; }
.sla-warning { background: #fef3c7; color: #b45309; }
.sla-breached { background: #fef2f2; color: #dc2626; }
.sla-met { background: #dcfce7; color: #15803d; }
.sla-none { background: #f1f5f9; color: #64748b; }

.sla-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
}
.sla-status-item label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    display: block;
    margin-bottom: 0.25rem;
}
.sla-status-item small {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.sla-table { margin-top: 0.5rem; }
.sla-table .form-control { max-width: 120px; }
.sla-input-group { display: flex; align-items: center; gap: 0.5rem; }
.sla-hint { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; }
.sla-note { font-size: 0.8125rem; color: var(--text-muted); margin-top: 1rem; }

.attachments { margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.attachment-link {
    font-size: 0.8125rem;
    background: var(--bg);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    border: 1px solid var(--border);
    text-decoration: none;
}
.attachment-link:hover { background: var(--border); }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}
.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem; display: block; }

.checkbox-group { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.875rem;
}