:root {
  --bg: #071a3a;
  --bg-soft: #0b2551;
  --card: #0f2f63;
  --text: #eef4ff;
  --muted: #b5c8eb;
  --blue: #1f7cff;
  --orange: #ff8c1a;
  --orange-strong: #ff7700;
  --ok: #22c55e;
  --danger: #ef4444;
  --border: #2a4d89;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.25);
}

* {
  box-sizing: border-box;
  font-family: "Segoe UI", Arial, sans-serif;
}

body {
  margin: 0;
  background: radial-gradient(circle at top right, #113d7d 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

a {
  color: #9ec2ff;
  text-decoration: none;
}
a:hover {
  color: #c9dcff;
}

.container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 24px;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  background: linear-gradient(180deg, #0a2249 0%, #071a3a 100%);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.2s ease, padding 0.2s ease;
}

.sidebar .brand {
  font-size: 18px;
  margin-bottom: 16px;
}

.sidebar .user-info {
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar .user-info .user-name {
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar .user-info .user-role {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sidebar .user-info .online-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--ok);
  font-weight: 600;
}

.sidebar .user-info .online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
  animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

body.sidebar-collapsed .sidebar .user-info {
  display: none;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #2d5798;
  background: linear-gradient(180deg, #134381 0%, #0d3367 100%);
  color: #eef4ff;
  font-weight: 600;
}

.sidebar-nav a.active {
  background: linear-gradient(180deg, #ff9f3f 0%, var(--orange-strong) 100%);
  border-color: #ff9d38;
  color: #fff;
}

.sidebar-toggle {
  margin-top: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.main-content {
  flex: 1;
  min-width: 0;
}

body.sidebar-collapsed .sidebar {
  width: 74px;
  padding: 16px 8px;
}

body.sidebar-collapsed .sidebar .brand span,
body.sidebar-collapsed .sidebar-nav a span {
  display: none;
}

body.sidebar-collapsed .sidebar .brand {
  justify-content: center;
}

body.sidebar-collapsed .sidebar-nav a {
  text-align: center;
  padding: 10px 6px;
  width: 100%;
  overflow: hidden;
}

body.sidebar-collapsed .sidebar-toggle {
  font-size: 12px;
  padding: 10px 6px;
}

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01)), var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

/* Client list grid */
#clientsContainer,
#instaladosContainer {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.client-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  overflow: hidden;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.client-card:hover {
  border-color: #3a6db0;
}

.client-card .cc-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.client-card .cc-header input[type="checkbox"] {
  accent-color: #ef4444;
  flex-shrink: 0;
}

.client-card .cc-name {
  font-weight: 700;
  font-size: 15px;
  color: #22c55e;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-card .cc-id {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
  flex-shrink: 0;
}

.client-card .cc-email {
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-card .cc-divider {
  border-top: 1px solid #2a4d89;
  margin: 4px 0;
}

.client-card .cc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 12px;
  font-size: 12px;
}

.client-card .cc-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-card .cc-label {
  color: var(--muted);
}

.client-card .cc-row {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-card .cc-muted {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-card .cc-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
}

.client-card .cc-photo img {
  max-width: 100%;
  max-height: 120px;
  border-radius: 6px;
  border: 1px solid #2a4d89;
  object-fit: contain;
}

.client-card .cc-maps {
  display: inline-block;
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 4px;
  line-height: 1.3;
  text-decoration: none;
  color: #22c55e;
}

.client-card .cc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.client-card .cc-actions button {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 4px;
  line-height: 1.3;
  white-space: nowrap;
}

.client-card .cc-actions .btn-ok {
  color: #fff;
  background: #16a34a;
  border: 1px solid #16a34a;
}

.client-card .cc-actions .btn-danger {
  color: #fff;
  background: #dc2626;
  border: 1px solid #dc2626;
}

.client-card .cc-actions .btn-purple {
  background: #7c3aed;
  border-color: #7c3aed;
}

.client-card .cc-actions .btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.client-card .cc-actions .btn-warn {
  color: #fff;
  background: #d97706;
  border: 1px solid #d97706;
}

.client-card .cc-actions .btn-primary {
  color: #fff;
  background: #2563eb;
  border: 1px solid #2563eb;
}

.dashboard-hero {
  max-width: 920px;
  margin: 8px auto 0;
  padding: 28px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(31, 124, 255, 0.2) 0%, rgba(255, 140, 26, 0.2) 100%), var(--card);
}

.dashboard-hero h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 30px;
  letter-spacing: 0.2px;
}

.dashboard-hero p {
  font-size: 16px;
  line-height: 1.65;
  margin: 8px 0;
}

.dash-section h3 {
  margin: 0 0 14px 0;
  font-size: 20px;
}

.dash-metrics-1 {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 12px;
}

.dash-metrics-3,
.dash-metrics-2 {
  display: grid;
  gap: 12px;
}

.dash-metrics-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dash-metrics-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.metric-box {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  padding: 14px;
}

.metric-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 6px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.traffic-footer {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.dash-footer {
  text-align: center;
}

.dash-footer p {
  margin: 6px 0;
  color: var(--muted);
}

@media (max-width: 900px) {
  .dash-metrics-3,
  .dash-metrics-2 {
    grid-template-columns: 1fr;
  }

  .metric-value {
    font-size: 21px;
  }
}

.row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

input,
select,
textarea,
button {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-size: 14px;
}

input,
select,
textarea {
  background: #0a2249;
  color: var(--text);
  outline: none;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 140, 26, 0.2);
}

button {
  background: linear-gradient(180deg, #ff9f3f 0%, var(--orange-strong) 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.12s ease, filter 0.12s ease;
}
button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}
button:active {
  transform: translateY(0);
}
button.danger {
  background: linear-gradient(180deg, #ff6e6e 0%, var(--danger) 100%);
}
button.secondary {
  background: linear-gradient(180deg, #2d88ff 0%, #1d64d2 100%);
}
button.ok {
  background: linear-gradient(180deg, #39db7a 0%, var(--ok) 100%);
  color: #04220f;
}
button.warn {
  background: linear-gradient(180deg, #ffb45e 0%, var(--orange-strong) 100%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(8, 33, 72, 0.88);
  border: 1px solid var(--border);
  backdrop-filter: blur(6px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.2px;
}
.brand img {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.16);
  background: #fff;
}

.table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td {
  border-bottom: 1px solid var(--border);
  padding: 11px;
  text-align: left;
  font-size: 14px;
}
.table th {
  color: #ffd2a0;
  font-weight: 700;
}

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

.nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.nav a {
  background: linear-gradient(180deg, #1a4d9b 0%, #103976 100%);
  color: #ecf3ff;
  padding: 9px 13px;
  border-radius: 11px;
  border: 1px solid #3566af;
}
.nav a:hover {
  background: linear-gradient(180deg, #2361bd 0%, #15458e 100%);
}

pre {
  background: #081c3d;
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 10px;
  overflow: auto;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-main {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 430px;
}
.login-card .brand {
  justify-content: center;
  margin-bottom: 10px;
}
.login-card .brand img {
  width: 72px;
  height: 72px;
  border-radius: 14px;
}
.login-card h2 {
  text-align: center;
  margin: 6px 0 4px;
  font-size: 24px;
}
.login-card .muted {
  text-align: center;
  margin-top: 0;
  margin-bottom: 14px;
}

@media (max-width: 980px) {
  .app-layout {
    display: block;
  }
  .sidebar {
    position: static;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  body.sidebar-collapsed .sidebar {
    width: 100%;
    padding: 16px 12px;
  }
  body.sidebar-collapsed .sidebar .brand span,
  body.sidebar-collapsed .sidebar-nav a span {
    display: inline;
  }
  .login-wrap {
    flex-direction: column;
  }
  .row-3 {
    grid-template-columns: 1fr;
  }
  .row {
    grid-template-columns: 1fr;
  }
}

/* ===================== MOBILE RESPONSIVE ===================== */
@media (max-width: 768px) {
  .container {
    padding: 12px;
  }

  .card {
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 12px;
  }

  .topbar {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
    padding: 10px;
  }

  .brand {
    font-size: 18px;
  }
  .brand img {
    width: 36px;
    height: 36px;
  }

  .dashboard-hero {
    padding: 16px;
    margin: 4px auto 0;
  }
  .dashboard-hero h2 {
    font-size: 22px;
  }
  .dashboard-hero p {
    font-size: 14px;
  }

  input,
  select,
  textarea,
  button {
    font-size: 16px;
    padding: 10px;
  }

  .table th,
  .table td {
    padding: 8px 6px;
    font-size: 12px;
  }
  .table td button {
    font-size: 10px;
    padding: 5px 8px;
    white-space: nowrap;
  }

  .dash-metrics-3 {
    grid-template-columns: repeat(2, 1fr);
  }
  .dash-metrics-2 {
    grid-template-columns: 1fr;
  }
  .metric-value {
    font-size: 20px;
  }

  .card {
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 12px;
  }

  .topbar {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
    padding: 10px;
  }

  .brand {
    font-size: 18px;
  }
  .brand img {
    width: 36px;
    height: 36px;
  }

  .dashboard-hero {
    padding: 16px;
    margin: 4px auto 0;
  }
  .dashboard-hero h2 {
    font-size: 22px;
  }
  .dashboard-hero p {
    font-size: 14px;
  }

  input,
  select,
  textarea,
  button {
    font-size: 16px;
    padding: 10px;
  }

  .table th,
  .table td {
    padding: 8px 6px;
    font-size: 12px;
  }
  .table td button {
    font-size: 10px;
    padding: 5px 8px;
    white-space: nowrap;
  }

  .dash-metrics-3,
  .dash-metrics-2 {
    grid-template-columns: 1fr;
  }
  .metric-value {
    font-size: 20px;
  }

  .sidebar {
    padding: 10px 8px;
  }
  .sidebar .brand {
    font-size: 16px;
  }
  .sidebar-nav a {
    padding: 8px 10px;
    font-size: 13px;
  }
  .sidebar .user-info {
    padding: 8px 10px;
    font-size: 12px;
  }
  .sidebar-toggle {
    font-size: 12px;
    padding: 8px;
  }

  .traffic-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .traffic-footer button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 8px;
  }

  .card {
    padding: 10px;
    border-radius: 10px;
    margin-bottom: 10px;
  }

  .table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .table th,
  .table td {
    padding: 6px 5px;
    font-size: 11px;
  }
  .table td button {
    font-size: 9px;
    padding: 4px 6px;
  }

  .brand {
    font-size: 16px;
  }
  .brand img {
    width: 30px;
    height: 30px;
  }

  .dashboard-hero {
    padding: 12px;
  }
  .dashboard-hero h2 {
    font-size: 18px;
  }
  .dashboard-hero p {
    font-size: 13px;
  }

  .topbar {
    padding: 8px;
    margin-bottom: 10px;
  }

  input,
  select,
  textarea,
  button {
    font-size: 14px;
    padding: 9px;
  }

  .sidebar-nav a {
    padding: 7px 8px;
    font-size: 12px;
  }

  .metric-box {
    padding: 10px;
  }
  .dash-section h3 {
    font-size: 17px;
  }

  .dash-metrics-3 {
    grid-template-columns: 1fr;
  }
  .metric-value {
    font-size: 18px;
  }
  .nav a {
    padding: 7px 10px;
    font-size: 12px;
  }

  pre {
    font-size: 12px;
    padding: 8px;
  }

  .login-card {
    padding: 16px;
  }
  .login-card h2 {
    font-size: 20px;
  }
}
