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

body {
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	background: #f0f2f5;
	color: #333;
	font-size: 13px;
}

/* Login */
.login-page {
	display: flex; align-items: center; justify-content: center;
	min-height: 100vh; background: #e8eef5;
}
.login-box {
	background: #fff; padding: 2.5rem; border-radius: 8px;
	box-shadow: 0 2px 12px rgba(0,0,0,.1); width: 320px;
}
.login-box h1 { text-align: center; margin-bottom: 1.5rem; color: #2563eb; }
.login-box input {
	width: 100%; padding: .7rem; margin-bottom: .8rem;
	border: 1px solid #ddd; border-radius: 4px; font-size: .95rem;
}
.login-box button {
	width: 100%; padding: .7rem; background: #2563eb; color: #fff;
	border: none; border-radius: 4px; font-size: 1rem; cursor: pointer;
}
.login-box button:hover { background: #1d4ed8; }
.error {
	background: #fef2f2; color: #dc2626; padding: .5rem;
	border-radius: 4px; margin-bottom: 1rem; text-align: center; font-size: .9rem;
}

/* Header */
header {
	display: flex; justify-content: space-between; align-items: center;
	padding: .6rem 1.2rem; background: #fff;
	border-bottom: 1px solid #e5e7eb; box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.header-left { display: flex; align-items: center; gap: 2rem; }
.header-left h1 { font-size: 1.1rem; color: #2563eb; }
.header-right { display: flex; align-items: center; gap: 1rem; }
.user-info { font-size: .8rem; color: #666; }
.btn-logout {
	padding: .3rem .7rem; background: #f3f4f6; color: #333;
	text-decoration: none; border-radius: 4px; font-size: .8rem;
}
.btn-logout:hover { background: #e5e7eb; }

/* Tabs */
nav { display: flex; gap: .3rem; }
.tab {
	padding: .4rem .9rem; border: none; background: transparent;
	cursor: pointer; font-size: .85rem; border-radius: 4px; color: #666;
}
.tab:hover { background: #f3f4f6; }
.tab.active { background: #2563eb; color: #fff; }
.tab-content { display: none; padding: 1rem; }
.tab-content.active { display: block; }

/* Toolbar */
.toolbar {
	display: flex; align-items: center; margin-bottom: .8rem; gap: .5rem;
}
.refresh-info { margin-left: auto; font-size: .75rem; color: #999; }
.btn {
	padding: .3rem .7rem; border: 1px solid #ddd; background: #fff;
	cursor: pointer; border-radius: 4px; font-size: .8rem;
}
.btn:hover { background: #f3f4f6; }

/* Period selector */
.period-selector { display: flex; gap: .2rem; }
.period {
	padding: .3rem .6rem; border: 1px solid #ddd; background: #fff;
	cursor: pointer; border-radius: 4px; font-size: .8rem;
}
.period:hover { background: #f9fafb; }
.period.active { background: #2563eb; color: #fff; border-color: #2563eb; }

/* ─── NIX-style card grid ─── */
.cards-grid {
	display: grid;
	grid-template-columns: repeat(2, 1fr);
	gap: .6rem;
}
.cards-grid-4 {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	gap: .6rem;
}
@media (max-width: 1200px) { .cards-grid { grid-template-columns: 1fr; } .cards-grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .cards-grid-4 { grid-template-columns: 1fr; } }

.nix-card {
	background: #fff;
	border: 1px solid #e0e4ea;
	border-radius: 6px;
	overflow: hidden;
}
.card-header {
	display: flex; align-items: center; justify-content: space-between;
	padding: .4rem .6rem;
	background: #f8f9fb;
	border-bottom: 1px solid #e0e4ea;
	font-size: .75rem; font-weight: 600; color: #444;
}
.card-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-chart {
	padding: .3rem;
	height: 180px;
	position: relative;
}
.card-chart canvas { width: 100% !important; height: 100% !important; }

/* Stats table inside card */
.card-stats {
	padding: .3rem .5rem .4rem;
	border-top: 1px solid #eee;
	font-size: .7rem;
}
.card-stats table { width: 100%; border-collapse: collapse; }
.card-stats th {
	text-align: left; font-weight: 600; padding: 1px 3px;
	color: #888; font-size: .65rem;
}
.card-stats td { padding: 1px 3px; }
.card-stats .dot-in { color: #4caf50; }
.card-stats .dot-out { color: #2196f3; }
.card-stats .label-row td { font-weight: 600; font-size: .65rem; color: #555; }

.card-footer {
	padding: .2rem .5rem .3rem;
	font-size: .65rem; color: #888;
	border-top: 1px solid #f0f0f0;
}

/* Loading state */
.card-loading {
	display: flex; align-items: center; justify-content: center;
	height: 180px; color: #aaa; font-size: .8rem;
}

/* Tables (switchlog) */
.table-container {
	background: #fff; border-radius: 6px;
	box-shadow: 0 1px 3px rgba(0,0,0,.08); overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; font-size: .8rem; }
th {
	background: #f9fafb; text-align: left; padding: .5rem .6rem;
	border-bottom: 2px solid #e5e7eb; font-weight: 600;
}
td { padding: .4rem .6rem; border-bottom: 1px solid #f3f4f6; }
tr:hover td { background: #f9fafb; }
.severity-error { color: #dc2626; font-weight: 600; }
.severity-critical { color: #dc2626; font-weight: 700; background: #fef2f2; }
.severity-notification { color: #2563eb; }

/* Sankey info */
#sankey-info {
	background: #fff; padding: .8rem; border-radius: 6px;
	box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: .8rem;
}
#sankey-info h3 { font-size: .9rem; margin-bottom: .3rem; }
.sankey-summary { display: flex; gap: 2rem; font-size: .8rem; }
.sankey-summary strong { color: #2563eb; }
.loading { text-align: center; padding: 1.5rem; color: #aaa; display: flex; align-items: center; justify-content: center; gap: .5rem; }
.spinner {
	display: inline-block; width: 18px; height: 18px;
	border: 2px solid #ddd; border-top-color: #2563eb;
	border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
