* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
    font-size: 14px;
    color: #1f2937;
    background: #f3f4f6;
}
a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }
.sidebar {
    width: 230px;
    background: #111827;
    color: #d1d5db;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand {
    padding: 20px 18px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid #1f2937;
    letter-spacing: .5px;
}
.sidebar nav { flex: 1; padding: 12px 0; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    color: #d1d5db;
    font-weight: 500;
}
.sidebar nav a:hover { background: #1f2937; color: #fff; text-decoration: none; }
.sidebar nav a.active { background: #2563eb; color: #fff; }
.sidebar nav .icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #374151;
    border-radius: 6px;
    font-size: 13px;
    flex-shrink: 0;
}
.sidebar nav a.active .icon { background: rgba(255,255,255,.25); }
.side-user {
    padding: 14px 18px;
    border-top: 1px solid #1f2937;
    font-size: 13px;
}
.side-name { font-weight: 600; color: #fff; margin-bottom: 4px; }
.logout { color: #f87171; }

.content { flex: 1; padding: 24px 30px 50px; min-width: 0; }
.topbar {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.topbar h1 { font-size: 24px; font-weight: 700; }
.search-global { display: flex; gap: 8px; align-items: center; }
.search-global input[type=text] { padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; width: 280px; }
.search-global input[type=text]:focus { outline: 2px solid #93c5fd; border-color: #2563eb; }

.flash { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash-ok { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.flash-warn { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.flash-err { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

.card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card h2 { font-size: 16px; margin-bottom: 14px; }
.card h3 { font-size: 14px; margin-bottom: 10px; color: #374151; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: #1d4ed8; text-decoration: none; }
.btn.secondary { background: #fff; color: #374151; border: 1px solid #d1d5db; }
.btn.secondary:hover { background: #f3f4f6; }
.btn.danger { background: #dc2626; }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn.ok { background: #16a34a; }
.btn.ok:hover { background: #15803d; }

table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #e5e7eb; vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: #6b7280; background: #f9fafb; }
tr:hover td { background: #f9fafb; }
td.actions { white-space: nowrap; text-align: right; }
td.actions a { margin-left: 8px; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.badge.ok { background: #dcfce7; color: #166534; }
.badge.bad { background: #fee2e2; color: #991b1b; }
.badge.warn { background: #fef3c7; color: #92400e; }
.badge.info { background: #dbeafe; color: #1e40af; }
.badge.muted { background: #f3f4f6; color: #6b7280; }

.alert-list { list-style: none; }
.alert-list li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #eef0f2;
}
.alert-list li:last-child { border-bottom: none; }
.alert-list .a-date { color: #6b7280; font-size: 13px; white-space: nowrap; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; padding: 16px 18px; }
.kpi .kpi-label { font-size: 12px; text-transform: uppercase; color: #6b7280; letter-spacing: .4px; }
.kpi .kpi-value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.kpi .kpi-sub { font-size: 12px; color: #6b7280; margin-top: 2px; }

form .row { margin-bottom: 14px; }
form label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 13px; }
form input[type=text], form input[type=email], form input[type=password], form input[type=date], form input[type=number], form select, form textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
}
form input:focus, form select:focus, form textarea:focus { outline: 2px solid #93c5fd; border-color: #2563eb; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
textarea { min-height: 90px; resize: vertical; }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }

.search-input { padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 8px; font-size: 14px; width: 260px; }

.client-social { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 14px; }
.social-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid #e5e7eb;
    background: #f9fafb;
}
.social-chip.yes { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.social-chip.no { background: #f3f4f6; color: #9ca3af; }

.checklist { list-style: none; }
.checklist li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #eef0f2; }
.checklist li:last-child { border-bottom: none; }
.checklist .item-done { text-decoration: line-through; color: #6b7280; }
.checklist .item-link { color: #2563eb; font-size: 13px; }

.hint { font-size: 13px; color: #6b7280; }
.tag { display: inline-block; background: #eef2ff; color: #3730a3; border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 600; margin-right: 6px; }

.inline-edit summary { cursor: pointer; font-weight: 600; color: #2563eb; font-size: 13px; }
.inline-edit summary:hover { text-decoration: underline; }
.inline-form { display: block; width: 320px; text-align: left; background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px; box-shadow: 0 4px 12px rgba(0,0,0,.08); }
.inline-form label { font-size: 12px; margin-top: 8px; }
.inline-form select, .inline-form input[type=text], .inline-form textarea { font-size: 13px; padding: 6px 8px; }
details.inline-edit { position: relative; }
details.inline-edit[open] .inline-form { position: absolute; right: 0; top: 24px; z-index: 20; }

.dl { display: grid; grid-template-columns: 160px 1fr; gap: 8px 14px; }
.dl dt { color: #6b7280; font-size: 13px; }
.dl dd { font-weight: 500; word-break: break-word; }
.empty { color: #9ca3af; padding: 20px; text-align: center; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.dot.info { background: #2563eb; }
.dot.warn { background: #f59e0b; }
.dot.bad { background: #dc2626; }
.dot.ok { background: #16a34a; }

.charts-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

.vchart { display: flex; align-items: flex-end; gap: 10px; height: 170px; padding-top: 20px; }
.vcol { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; }
.vbar-wrap { flex: 1; display: flex; align-items: flex-end; width: 100%; max-width: 46px; }
.vbar {
    width: 100%;
    background: linear-gradient(180deg, #60a5fa, #2563eb);
    border-radius: 6px 6px 0 0;
    position: relative;
    min-height: 4px;
}
.vbar .vval { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 10px; color: #374151; white-space: nowrap; }
.vlab { font-size: 11px; color: #6b7280; font-weight: 600; }

.hchart { display: flex; flex-direction: column; gap: 10px; }
.hrow { display: flex; align-items: center; gap: 10px; }
.hname { width: 120px; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-wrap { flex: 1; background: #f3f4f6; border-radius: 999px; height: 16px; overflow: hidden; }
.hbar { height: 100%; border-radius: 999px; min-width: 4px; }
.hbar.info { background: #2563eb; }
.hval { width: 24px; text-align: right; font-weight: 700; font-size: 13px; }

.stacked-bar { display: flex; height: 26px; border-radius: 8px; overflow: hidden; background: #f3f4f6; margin: 12px 0 14px; }
.s-seg { height: 100%; }
.s-seg.ok { background: #16a34a; }
.s-seg.warn { background: #f59e0b; }
.stacked-legend { display: flex; gap: 20px; flex-wrap: wrap; font-size: 13px; color: #374151; }
.stacked-legend span { display: inline-flex; align-items: center; }

.cal-legend { display: flex; gap: 20px; flex-wrap: wrap; margin-bottom: 14px; font-size: 13px; color: #374151; }
.cal-legend span { display: inline-flex; align-items: center; }
.cal-table { width: 100%; border-collapse: collapse; table-layout: fixed; background: #fff; }
.cal-table th { padding: 8px 10px; }
.cal-table td { border: 1px solid #e5e7eb; vertical-align: top; height: 96px; padding: 6px; }
.cal-table td.cal-empty { background: #f9fafb; }
.cal-today { background: #eff6ff; box-shadow: inset 0 0 0 2px #2563eb; }
.cal-daynum { font-weight: 700; font-size: 12px; color: #374151; margin-bottom: 4px; }
.cal-none { height: 4px; }
.cal-event {
    display: block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 5px;
    margin-bottom: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
}
.cal-event:hover { text-decoration: none; filter: brightness(.95); }
.cal-event.info { background: #dbeafe; color: #1e40af; }
.cal-event.warn { background: #fef3c7; color: #92400e; }
.cal-event.bad { background: #fee2e2; color: #991b1b; }
.cal-event.ok { background: #dcfce7; color: #166534; }

@media (max-width: 900px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; height: auto; position: static; }
    .sidebar nav { display: flex; flex-wrap: wrap; }
    .side-user { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .search-global { width: 100%; }
    .search-global input[type=text] { flex: 1; width: auto; }
    .cal-table td { height: 64px; padding: 4px; }
    .cal-event { font-size: 10px; }
    .hname { width: 90px; }
}
