@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:wght@400;500;700&display=swap');

:root {
    --sidebar-bg:     #1E2761;
    --sidebar-width:  240px;
    --accent:         #0088CC;
    --accent-hover:   #065A82;
    --bg:             #f1f5f9;
    --card:           #ffffff;
    --text:           #1E2761;
    --text-muted:     #64748b;
    --border:         #e2e8f0;
    --success:        #10b981;
    --danger:         #ef4444;
    --warning:        #f59e0b;
    --radius:         8px;
    --shadow:         0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:      0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.05);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 0.9375rem;
    line-height: 1.5;
}

/* ── Layout ── */
.layout {
    display: flex;
    min-height: 100vh;
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.content {
    padding: 2rem;
    flex: 1;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem 1rem;
    color: #fff;
    font-family: 'Syne', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 0.5rem;
}

.sidebar-brand .brand-icon {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar-section {
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(202, 220, 252, 0.5);
    margin-top: 0.75rem;
}

.sidebar-nav {
    list-style: none;
    padding: 0 0.75rem;
    flex: 1;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.75rem;
    color: #CADCFC;
    text-decoration: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    transition: background 0.15s, color 0.15s;
}

.sidebar-nav li a:hover {
    background: rgba(255,255,255,0.08);
    color: #ffffff;
}

.sidebar-nav li a.active {
    background: rgba(0, 136, 204, 0.2);
    color: #ffffff;
    font-weight: 500;
}

.sidebar-nav li a .nav-icon {
    width: 18px;
    text-align: center;
    opacity: 0.8;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-footer .user-avatar {
    width: 32px;
    height: 32px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

.sidebar-footer .user-info { flex: 1; min-width: 0; }
.sidebar-footer .user-name {
    color: #e2e8f0;
    font-size: 0.825rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-footer .user-role {
    color: #CADCFC;
    font-size: 0.725rem;
}
.sidebar-footer .logout-link {
    color: #CADCFC;
    text-decoration: none;
    font-size: 1rem;
    transition: color 0.15s;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}
.sidebar-footer .logout-link:hover { color: #ffffff; }

/* ── Topbar ── */
.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.topbar h1 {
    font-family: 'Syne', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.topbar-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* ── Cards / Panels ── */
.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h2 {
    font-family: 'Syne', sans-serif;
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--text);
}

.card-body { padding: 1.5rem; }

/* ── Stat Cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    border-top: 3px solid var(--accent);
}

.stat-card .stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stat-card .stat-value {
    font-family: 'Syne', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
}

.stat-card .stat-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

/* ── Tables ── */
.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 0.625rem 1.25rem;
    text-align: left;
    font-size: 0.73rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.875rem;
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f0f7ff; }

/* ── Badges ── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.badge-online  { background: #dcfce7; color: #166534; }
.badge-offline { background: #fee2e2; color: #991b1b; }
.badge-admin   { background: #dbeafe; color: #1e3a8a; }
.badge-user    { background: #f1f5f9; color: #475569; }

/* ── Progress bars ── */
.bar-wrap {
    background: #e2e8f0;
    border-radius: 999px;
    height: 6px;
    width: 80px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

.bar-fill {
    height: 6px;
    border-radius: 999px;
    background: var(--accent);
    transition: width 0.3s;
}

.bar-fill.high    { background: var(--danger); }
.bar-fill.mid     { background: var(--warning); }
.bar-fill.success { background: var(--success); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
    background: var(--card);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: #f0f7ff; border-color: var(--accent); }

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover { background: #dc2626; border-color: #dc2626; }

.btn-warning {
    background: var(--warning);
    color: #fff;
    border-color: var(--warning);
}
.btn-warning:hover { background: #d97706; }

.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
}

/* ── Forms ── */
.form-group { margin-bottom: 1.25rem; }

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 0.4rem;
}

.form-control {
    width: 100%;
    padding: 0.55rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--text);
    background: var(--card);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: 'DM Sans', sans-serif;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 136, 204, 0.12);
}

select.form-control { cursor: pointer; }

/* ── Alerts ── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-info    { background: #e0f2fe; color: #075985; border: 1px solid #bae6fd; }

/* ── Login page ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1E2761 0%, #065A82 100%);
}

.login-card {
    background: var(--card);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
}

.login-card .login-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.75rem;
}

.login-card .login-logo .logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #1E2761, #0088CC);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
}

.login-card .login-logo span {
    font-family: 'Syne', sans-serif;
    font-size: 1.3rem;
    font-weight: 800;
    color: #1E2761;
    letter-spacing: -0.02em;
}

.login-card h2 {
    font-family: 'Syne', sans-serif;
    font-size: 1.3rem;
    font-weight: 700;
    color: #1E2761;
    margin-bottom: 0.25rem;
}

.login-card p {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

/* ── Misc ── */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.page-header h2 {
    font-family: 'Syne', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
}

.text-muted { color: var(--text-muted); }
.text-small { font-size: 0.8rem; }
.monospace  { font-family: 'SFMono-Regular', Consolas, monospace; font-size: 0.82rem; }
.mt-1 { margin-top: 0.5rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 1.5rem; }

.empty-state {
    padding: 3rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.25rem 0;
}

.input-with-btn {
    display: flex;
    gap: 0.5rem;
}

.input-with-btn .form-control { flex: 1; }

/* ── Dark Mode ── */
body.dark {
    --bg:        #0f172a;
    --card:      #1e293b;
    --border:    #334155;
    --text:      #f1f5f9;
    --text-muted:#94a3b8;
}

body.dark thead th {
    background: #162032;
    color: var(--text-muted);
    border-bottom-color: var(--border);
}

body.dark tbody td {
    border-bottom-color: #273548;
}

body.dark tbody tr:hover td {
    background: #1a2d44;
}

body.dark .btn-secondary {
    background: #1e293b;
    color: var(--text);
    border-color: var(--border);
}

body.dark .btn-secondary:hover { background: #1a2d44; border-color: var(--accent); }

body.dark .btn-danger {
    background: #3b1c1c;
    color: #f87171;
    border-color: #7f1d1d;
}

body.dark .form-control {
    background: #0f172a;
    color: var(--text);
    border-color: var(--border);
}

body.dark .form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(0, 136, 204, 0.2);
}

body.dark .badge-online  { background: #14532d; color: #86efac; }
body.dark .badge-offline { background: #7f1d1d; color: #fca5a5; }
body.dark .badge-admin   { background: #1e3a5f; color: #93c5fd; }
body.dark .badge-user    { background: #1e293b; color: #94a3b8; }

body.dark .alert-error   { background: #3b1c1c; color: #fca5a5; border-color: #7f1d1d; }
body.dark .alert-success { background: #14532d; color: #86efac; border-color: #166534; }
body.dark .alert-info    { background: #0c2d4a; color: #7dd3fc; border-color: #0369a1; }

body.dark .topbar {
    background: #1e293b;
    border-bottom-color: var(--border);
}

body.dark .disk-item, body.dark .net-item { background: #162032; }
body.dark .disk-bar { background: #334155; }

body.dark .stat-card {
    background: #1e293b;
    border-color: #334155;
}

/* Tag pills */
.tag-pill {
    display:inline-flex;align-items:center;
    padding:0.12rem 0.5rem;border-radius:999px;
    font-size:0.7rem;font-weight:600;
    background:#dbeafe;color:#1e3a8a;
    margin:0.1rem;cursor:pointer;
    text-decoration:none;
    transition:background 0.15s;
}
.tag-pill:hover { background:#bfdbfe; }
body.dark .tag-pill { background:#1e3a5f;color:#93c5fd; }
body.dark .tag-pill:hover { background:#1e40af; }

/* ── PSA-specific ── */
.badge {
    display: inline-block;
    padding: 0.2em 0.6em;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.badge-open       { background: #dbeafe; color: #1d4ed8; }
.badge-in_progress{ background: #fef3c7; color: #b45309; }
.badge-waiting    { background: #e9d5ff; color: #7c3aed; }
.badge-resolved   { background: #d1fae5; color: #065f46; }
.badge-closed     { background: #f1f5f9; color: #475569; }

.badge-low      { background: #f1f5f9; color: #475569; }
.badge-medium   { background: #fef3c7; color: #b45309; }
.badge-high     { background: #fee2e2; color: #b91c1c; }
.badge-critical { background: #b91c1c; color: #fff; }

.ticket-row:hover { background: #f8fafc; cursor: pointer; }

.comment-block { border-left: 3px solid var(--border); padding: 0.75rem 1rem; margin-bottom: 1rem; background: var(--card); border-radius: 0 var(--radius) var(--radius) 0; }
.comment-block.internal { border-left-color: var(--warning); background: #fffbeb; }

.time-total { font-size: 1.1rem; font-weight: 700; color: var(--accent); }

.sla-ok      { color: var(--success); }
.sla-warning { color: var(--warning); }
.sla-breached{ color: var(--danger); }

.client-card { border-top: 3px solid var(--accent); }

/* ── PSA missing aliases ── */
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--accent);
    color: var(--accent);
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .45rem .9rem;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.btn-outline:hover { background: var(--accent); color: #fff; }

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: .75rem 1rem;
    margin-bottom: 1rem;
}

.topbar-title {
    font-family: 'Syne', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text);
}

.form-control-sm {
    padding: .35rem .65rem;
    font-size: .8rem;
}

.btn-sm {
    padding: .3rem .7rem;
    font-size: .8rem;
}
