:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --border: #dbe3ef;
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #f59e0b;
  --radius: 14px;
  --shadow: 0 10px 25px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at top right, #dbeafe 0%, var(--bg) 30%);
  color: var(--text);
  font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  width: 100%;
}

.container {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 1.25rem 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

h1, h2, h3, h4 {
  margin: 0 0 1rem;
  line-height: 1.2;
}

h1 { font-size: clamp(1.4rem, 2.3vw, 2rem); }
h3 { margin-top: 0.5rem; }

p { margin-top: 0; color: var(--muted); }

a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}
a:hover { color: var(--primary-dark); }

.grid {
  display: grid;
  gap: 1rem;
}

.grid.cols-2 {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

nav.menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

nav.menu a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  background: #eff6ff;
  border: 1px solid #cfe0ff;
}

form {
  display: grid;
  gap: 0.75rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
}

input, select, textarea, button {
  width: 100%;
  font: inherit;
  border-radius: 10px;
}

input, select, textarea {
  margin-top: 0.25rem;
  border: 1px solid var(--border);
  background: #fff;
  padding: 0.58rem 0.7rem;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid #bfdbfe;
  border-color: #93c5fd;
}

button {
  width: auto;
  border: 0;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  padding: 0.62rem 1rem;
  cursor: pointer;
}

button:hover { background: var(--primary-dark); }

.btn-danger { background: var(--danger); }

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: block;
}

thead, tbody, tr {
  width: 100%;
  display: table;
  table-layout: fixed;
}

th, td {
  border-bottom: 1px solid var(--border);
  padding: 0.7rem;
  text-align: left;
  vertical-align: top;
  font-size: 0.9rem;
}

th {
  color: #334155;
  background: var(--surface-soft);
  font-weight: 700;
}

.status-ok { color: var(--success); font-weight: 700; }
.status-alert { color: var(--warning); font-weight: 700; }

.flash {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  margin-bottom: 1rem;
  font-weight: 600;
}
.flash.success { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.flash.error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.small { font-size: 0.84rem; color: var(--muted); }

@media (max-width: 900px) {
  table { overflow-x: auto; }
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.clients-stack {
  display: grid;
  gap: 0.8rem;
}

.client-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 0.75rem;
}

.client-item summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.client-item summary::-webkit-details-marker { display: none; }

.client-summary-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  background: #eef2ff;
  color: #3730a3;
  font-weight: 700;
  font-size: 0.82rem;
}

.muted { color: var(--muted); }

.client-summary-side {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.status-chip {
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
}

.status-chip.ok {
  background: #dcfce7;
  color: #166534;
}

.status-chip.off {
  background: #f1f5f9;
  color: #475569;
}

.summary-action {
  color: var(--primary);
  font-weight: 700;
  font-size: 0.86rem;
}

.client-detail-form {
  margin-top: 0.8rem;
}

.modal {
  border: 1px solid var(--border);
  border-radius: 16px;
  width: min(960px, 94vw);
  max-height: 85vh;
  overflow: auto;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
}

button.ghost {
  background: #e2e8f0;
  color: #0f172a;
}

@media (max-width: 680px) {
  .page-header { align-items: stretch; flex-direction: column; }
  .client-item summary { flex-direction: column; align-items: flex-start; }
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
  margin: 1rem 0;
}

.kpi-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.kpi-card span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  margin-bottom: 0.35rem;
}

.kpi-card strong {
  font-size: 1.25rem;
}
.kpi-link {
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.kpi-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 18px rgba(37,99,235,0.15);
}
