:root {
    --bg: #0f1419;
    --sidebar: #1a2332;
    --card: #1e2a3a;
    --border: #2d3f56;
    --text: #e8edf4;
    --muted: #8b9cb3;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #22c55e;
    --warning: #f59e0b;
    --error: #ef4444;
    --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-card { background: var(--card); padding: 2.5rem; border-radius: var(--radius); width: 100%; max-width: 400px; border: 1px solid var(--border); }
.auth-card h1 { font-size: 1.8rem; margin-bottom: .25rem; }
.auth-card h1 span { color: var(--primary); }
.subtitle { color: var(--muted); margin-bottom: 1.5rem; font-size: .9rem; }

.sidebar { position: fixed; left: 0; top: 0; width: 240px; height: 100vh; background: var(--sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 1.5rem 0; overflow: hidden; }
.brand { font-size: 1.3rem; font-weight: 700; padding: 0 1.25rem 1rem; }
.brand-slogan { display: block; font-size: .7rem; font-weight: 400; color: var(--muted); margin-top: .35rem; }
.nav-group-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .85rem 1rem .25rem; }
.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: .15rem; padding: 0 .75rem; overflow-y: auto; }
.brand span { color: var(--primary); }
.brand-logo { max-width: 160px; max-height: 48px; object-fit: contain; display: block; margin-bottom: .5rem; }
.section-title { font-size: .95rem; font-weight: 600; color: var(--text); margin-top: .5rem; padding-bottom: .35rem; border-bottom: 1px solid var(--border); }
.logo-upload { display: flex; flex-direction: column; gap: 1rem; }
.logo-preview {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    width: 100%;
    max-width: 480px;
}
.logo-preview img {
    max-width: 100%;
    max-height: 180px;
    width: auto;
    height: auto;
    object-fit: contain;
}
input[type="file"] { padding: .4rem 0; }
.sidebar nav { flex: 1; display: flex; flex-direction: column; gap: .25rem; padding: 0 .75rem; }
.sidebar nav a { padding: .65rem 1rem; border-radius: 8px; color: var(--muted); }
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(59,130,246,.15); color: var(--text); text-decoration: none; }
.sidebar-footer { padding: 1rem 1.25rem; border-top: 1px solid var(--border); font-size: .85rem; color: var(--muted); display: flex; flex-direction: column; gap: .5rem; }

.content { margin-left: 240px; padding: 2rem; }
.page-header { margin-bottom: 1.5rem; display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-header h1 { font-size: 1.5rem; }
.tenant-switch label { flex-direction: row; align-items: center; gap: .5rem; }
.tenant-switch select { min-width: 180px; }
.meta-info-box { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.meta-info-box dl { display: grid; grid-template-columns: auto 1fr; gap: .35rem 1rem; font-size: .85rem; }
.meta-info-box dt { color: var(--muted); }
.meta-info-box dd { margin: 0; word-break: break-all; }
.test-send-box { margin-top: 1.5rem; padding-top: 1.5rem; border-top: 1px solid var(--border); }
.test-send-box h3 { font-size: 1rem; margin-bottom: .75rem; }
.client-badge { display: inline-block; margin-top: .35rem; font-size: .8rem; color: var(--primary); background: rgba(59,130,246,.12); padding: .2rem .6rem; border-radius: 6px; }

.dashboard-client-header {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
    padding: 1.5rem 2rem;
}
.dashboard-client-logo {
    flex-shrink: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 200px;
    min-height: 100px;
}
.dashboard-client-logo img {
    max-width: 220px;
    max-height: 90px;
    object-fit: contain;
}
.dashboard-client-info h2 { font-size: 1.4rem; margin-bottom: .25rem; }
.dashboard-client-sub { color: var(--muted); font-size: .9rem; margin: 0; }

.dashboard-filters { margin-bottom: 1.25rem; }
.dashboard-filters h2 { font-size: 1rem; margin-bottom: .75rem; }
.filter-row { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; }
.filter-row label { min-width: 120px; }
.filter-row .btn { margin-bottom: 2px; }

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

.charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.chart-card { min-height: 320px; display: flex; flex-direction: column; }
.chart-card h2 { font-size: 1rem; margin-bottom: 1rem; }
.chart-card canvas { flex: 1; min-height: 240px; max-height: 280px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.stat-label { display: block; color: var(--muted); font-size: .85rem; margin-bottom: .5rem; }
.stat-value { font-size: 1.8rem; display: block; }
.stat-card small { color: var(--muted); font-size: .75rem; }
.stat-warning .stat-value { color: var(--warning); }
.stat-success .stat-value { color: var(--success); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1rem; }
.card h2 { font-size: 1.1rem; margin-bottom: 1rem; }

.form { display: flex; flex-direction: column; gap: 1rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid .full { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; color: var(--muted); }
input, select, textarea { background: var(--bg); border: 1px solid var(--border); color: var(--text); padding: .6rem .75rem; border-radius: 8px; font-size: .95rem; }
input:focus, select:focus { outline: none; border-color: var(--primary); }
.form-actions { grid-column: 1 / -1; margin-top: .5rem; }
.inline-form { margin-top: 1rem; }

.btn { display: inline-block; padding: .6rem 1.2rem; border-radius: 8px; border: none; cursor: pointer; font-size: .9rem; font-weight: 500; text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); text-decoration: none; }
.btn-secondary { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; }

.alert { padding: .85rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-size: .9rem; }
.alert-error { background: rgba(239,68,68,.15); border: 1px solid var(--error); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.15); border: 1px solid var(--success); color: #86efac; }
.alert-warning { background: rgba(245,158,11,.15); border: 1px solid var(--warning); color: #fcd34d; }

.tabs { display: flex; gap: .5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .5rem 1rem; border-radius: 8px; background: var(--card); border: 1px solid var(--border); color: var(--muted); }
.tabs a.active { background: var(--primary); border-color: var(--primary); color: #fff; text-decoration: none; }

.hint { color: var(--muted); font-size: .85rem; margin-bottom: 1rem; }
.mt { margin-top: 1rem; }

.table-info { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table-info th, .table-info td { padding: .6rem; text-align: left; border-bottom: 1px solid var(--border); }
.table-info th { color: var(--muted); font-weight: 500; }
code { background: var(--bg); padding: .15rem .4rem; border-radius: 4px; font-size: .85rem; }

.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table th, .data-table td { padding: .65rem .5rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); font-weight: 500; position: sticky; top: 0; background: var(--card); }
.data-table .empty { text-align: center; color: var(--muted); padding: 2rem; }
.badge { background: rgba(59,130,246,.2); color: var(--primary); padding: .2rem .5rem; border-radius: 4px; font-size: .75rem; }

.toolbar { display: flex; gap: .75rem; align-items: center; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar-info { color: var(--muted); font-size: .85rem; margin-left: auto; }

.empty-state { color: var(--muted); padding: 2rem 1rem; text-align: center; line-height: 1.5; }
.table-wrap { overflow-x: auto; }
.kanban { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .75rem; align-items: start; }
.kanban-col { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: .75rem; min-height: 160px; }
.kanban-col h3 { font-size: .8rem; color: var(--muted); margin-bottom: .75rem; display: flex; justify-content: space-between; }
.kanban-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: .7rem; margin-bottom: .5rem; display: flex; flex-direction: column; gap: .25rem; }
.kanban-card small { color: var(--muted); }

@media (max-width: 768px) {
    .sidebar { width: 100%; height: auto; position: relative; }
    .content { margin-left: 0; }
    .form-grid { grid-template-columns: 1fr; }
}
