:root {
    --primary: #2d6a4f;
    --primary-dark: #1b4332;
    --primary-light: #52b788;
    --bg: #f5f6f5;
    --card-bg: #ffffff;
    --border: #e5e7eb;
    --text: #1b1b1b;
    --text-muted: #6b7280;
    --danger: #c0392b;
    --warning: #f39c12;
    --success: #27ae60;
    --info: #3498db;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.5;
}

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

body { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--primary-dark);
    color: #e8efe9;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-light);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.brand-icon-lg { width: 56px; height: 56px; font-size: 18px; }

.brand-title { font-weight: 600; color: white; font-size: 14px; }
.brand-subtitle { font-size: 12px; opacity: 0.75; }

.sidebar nav {
    display: flex;
    flex-direction: column;
    padding: 12px 8px;
    flex: 1;
}

.sidebar nav a {
    color: rgba(255, 255, 255, 0.85);
    padding: 9px 14px;
    border-radius: 6px;
    margin-bottom: 2px;
    font-size: 14px;
}

.sidebar nav a:hover {
    background: rgba(255, 255, 255, 0.08);
    text-decoration: none;
}

.sidebar nav a.active {
    background: var(--primary-light);
    color: white;
    font-weight: 500;
}

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-info { margin-bottom: 8px; }
.user-name { font-weight: 500; color: white; font-size: 13px; }
.user-email { font-size: 11px; opacity: 0.7; }

.btn-logout {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.9);
    padding: 6px 12px;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
    width: 100%;
}
.btn-logout:hover { background: rgba(255, 255, 255, 0.1); }

/* Content */
.content {
    flex: 1;
    padding: 28px 32px;
    max-width: 100%;
    overflow-x: auto;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.page-header h1 { margin: 0; font-size: 22px; }
.page-header p { margin: 4px 0 0; color: var(--text-muted); }

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

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
}
.stat-label { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.stat-value { font-size: 26px; font-weight: 600; margin: 6px 0 4px; }
.stat-meta { color: var(--text-muted); font-size: 12px; }

/* Sections */
.section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    margin-bottom: 20px;
}
.section h2 { margin: 0 0 12px; font-size: 16px; }

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.table th {
    text-align: left;
    padding: 10px 12px;
    background: #fafafa;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.4px;
}
.table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr:hover { background: #fafafa; }
.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    background: #eee;
}
.badge-active { background: #d1fae5; color: #065f46; }
.badge-escalated, .badge-new { background: #fef3c7; color: #92400e; }
.badge-live { background: #dbeafe; color: #1e40af; }
.badge-resolved, .badge-closed { background: #e5e7eb; color: #374151; }
.badge-spam { background: #fee2e2; color: #991b1b; }
.badge-admin { background: #ede9fe; color: #5b21b6; }
.badge-operator { background: #e0e7ff; color: #3730a3; }

/* Forms */
.form {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    max-width: 540px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form label,
.login-form label {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    gap: 5px;
}

.form label > span,
.login-form label > span {
    color: var(--text-muted);
    font-weight: 500;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.form input[type=text],
.form input[type=email],
.form input[type=password],
.form input[type=url],
.form input[type=number],
.form input[type=color],
.form select,
.form textarea,
.login-form input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    font-family: inherit;
}

.form textarea { min-height: 110px; resize: vertical; }

.form input:focus,
.form select:focus,
.form textarea:focus,
.login-form input:focus {
    outline: 2px solid rgba(82, 183, 136, 0.4);
    outline-offset: 0;
    border-color: var(--primary-light);
}

.checkbox {
    flex-direction: row !important;
    align-items: center;
    gap: 8px !important;
}
.checkbox input { width: 16px; height: 16px; margin: 0; }

.form-error {
    color: var(--danger);
    font-size: 12px;
    font-style: normal;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: white;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    font-family: inherit;
}
.btn:hover { background: #f9fafb; text-decoration: none; }

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

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

.btn-block { width: 100%; }

.link-danger {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 0;
    margin-left: 8px;
    font-family: inherit;
    font-size: inherit;
}
.link-danger:hover { text-decoration: underline; }

/* Flash messages */
.flash {
    padding: 11px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.flash-info    { background: #dbeafe; color: #1e3a8a; border: 1px solid #93c5fd; }

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

.cost-bars {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 120px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 4px;
}
.cost-bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; cursor: help; }
.cost-bar-fill { width: 100%; background: linear-gradient(to top, var(--primary), var(--primary-light)); border-radius: 3px 3px 0 0; min-height: 1px; }
.cost-bar-label { font-size: 10px; color: var(--text-muted); margin-top: 4px; }

/* Login page */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 16px;
    padding: 36px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.login-brand {
    text-align: center;
    margin-bottom: 22px;
}

.login-brand .brand-icon { margin: 0 auto 12px; }
.login-brand h1 { margin: 0 0 4px; font-size: 18px; }
.login-brand p { margin: 0; color: var(--text-muted); font-size: 13px; }

.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

@media (max-width: 720px) {
    body { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; padding: 12px; gap: 8px; }
    .sidebar nav { flex-direction: row; flex-wrap: wrap; padding: 0; }
    .sidebar nav a { font-size: 12px; padding: 6px 10px; }
    .sidebar-footer { width: 100%; padding: 8px 12px; border-top: none; border-left: 1px solid rgba(255,255,255,0.08); }
    .content { padding: 20px 16px; }
}
