:root {
  --bg: #f3f2ef;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6f6c66;
  --line: #e2dfd8;
  --accent: #2f4638;
  --accent-soft: #e8eee9;
  --danger: #b42318;
  --ok: #1f7a46;
  --sidebar: 232px;
  --shadow: 0 1px 2px rgba(26, 26, 26, 0.06);
}

* {
  box-sizing: border-box;
}

html, body {
  font-family: "Segoe UI", ui-sans-serif, system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
}

a { color: inherit; }

button, input, textarea, select {
  font: inherit;
}

/* Login */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 40px 36px 28px;
  width: 100%;
  max-width: 380px;
}

.logo-container {
  width: 48px;
  height: 48px;
  margin: 0 auto 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.logo-container img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-title {
  text-align: center;
  margin-bottom: 28px;
}

.login-title h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.login-title p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.login-title .divider { display: none; }

.input-group { margin-bottom: 14px; }

.input-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.input-simple {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}

.input-simple:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-simple {
  width: 100%;
  margin-top: 8px;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
}

.btn-simple:hover:not(:disabled) { filter: brightness(1.05); }
.btn-simple:disabled { opacity: 0.6; cursor: not-allowed; }

.error-message {
  margin-top: 12px;
  padding: 10px 12px;
  background: #f8e8e6;
  border: 1px solid #efc4bf;
  border-radius: 6px;
  color: var(--danger);
  font-size: 13px;
  text-align: center;
}

.login-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

.login-footer .security-info { display: none; }
.login-footer .copyright { margin: 0; }

/* Sidebar */
.sidebar {
  width: var(--sidebar);
  background: #fafaf8;
  border-right: 1px solid var(--line);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
}

.sidebar-header,
.sidebar .h-20 {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: #fafaf8;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  margin: 0 10px 2px;
  border-radius: 6px;
  color: #3f3d39;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.nav-item::before { display: none !important; }
.nav-item .tooltip { display: none !important; }

.nav-item i {
  width: 20px;
  margin-right: 10px;
  text-align: center;
  color: #7a766e;
}

.nav-item:hover {
  background: #efeee9;
  color: var(--text);
  transform: none;
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  box-shadow: none;
}

.nav-item.active i { color: var(--accent); }

.main-content {
  margin-left: var(--sidebar);
  min-height: 100vh;
}

.page-header {
  background: transparent;
  border: 0;
  box-shadow: none;
  border-radius: 0;
  padding: 0 0 20px;
  margin-bottom: 20px;
}

.page-header h1,
.page-header h1[style] {
  font-size: 22px !important;
  font-weight: 650 !important;
  letter-spacing: -0.02em;
  color: var(--text) !important;
  background: none !important;
  -webkit-text-fill-color: unset !important;
}

.page-header p { color: var(--muted); margin: 4px 0 0; }

.stat-card,
.content-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: none;
}

.stat-card {
  padding: 16px;
}

.stat-card:hover,
.content-card:hover,
#products-container .bg-white:hover {
  transform: none !important;
  box-shadow: none !important;
  border-color: var(--line) !important;
}

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  box-shadow: none !important;
  font-size: 14px;
}

.btn-primary,
.btn-primary:hover {
  background: var(--accent) !important;
  color: #fff !important;
  border: 0;
  border-radius: 6px;
  box-shadow: none !important;
  transform: none !important;
  font-weight: 600;
  padding: 8px 14px;
}

.btn-secondary,
.btn-secondary:hover {
  background: #fff !important;
  color: var(--text) !important;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: none !important;
  transform: none !important;
  font-weight: 550;
  padding: 8px 14px;
}

.section-content { animation: none; }

table thead { background: #f7f6f3; }
table thead th { font-weight: 600 !important; font-size: 12px; color: var(--muted) !important; }
table tbody tr:hover { background: #f7f6f3; }

input, textarea, select {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: none;
}

.whatsapp-message {
  background: #f3f6f4;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: none;
}

.whatsapp-message::after { display: none; }

.badge { border-radius: 4px; font-weight: 600; }

/* Pairing */
.pair-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.pair-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 32px;
  letter-spacing: 0.18em;
  font-weight: 650;
  text-align: center;
  padding: 18px;
  background: #f7f6f3;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--text);
}

.pair-steps {
  margin: 16px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.pair-steps li { margin: 6px 0; }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: #c4c0b8;
}

.status-dot.ok { background: var(--ok); }
.status-dot.warn { background: #b45309; }
.status-dot.off { background: #a3a09a; }

.details-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fafaf8;
}

.details-box summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cfcbc3; border-radius: 8px; }

html {
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 100vh;
}

.content-card {
  overflow: visible;
}

.settings-tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.settings-tab {
  white-space: nowrap;
  flex-shrink: 0;
  padding: 12px 16px !important;
}

.log-viewer {
  max-height: min(70vh, 640px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.advisory-chat-panel {
  height: min(70vh, 700px);
}

.mobile-topbar {
  display: none;
}

.sidebar-overlay {
  display: none;
}

.menu-toggle {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
}

.section-content {
  padding-bottom: 48px;
}

@media (max-width: 1024px) {
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 25;
    height: 56px;
    padding: 0 12px;
    background: #fafaf8;
    border-bottom: 1px solid var(--line);
    font-weight: 650;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 26, 0.35);
    z-index: 35;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
  }

  .sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 40 !important;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0 !important;
  }

  .section-content {
    padding: 16px 12px 40px !important;
  }

  .pair-code {
    font-size: 22px;
    letter-spacing: 0.08em;
    padding: 14px 8px;
    overflow-x: auto;
  }

  .pair-box .flex.items-start.justify-between,
  .pair-box .flex.items-center.justify-between {
    flex-wrap: wrap;
    gap: 12px;
  }

  .log-viewer {
    max-height: calc(100dvh - 260px);
  }

  .advisory-chat-panel {
    height: min(80dvh, 640px);
  }
}

@media (max-width: 640px) {
  .page-header h1,
  .page-header h1[style] {
    font-size: 18px !important;
  }

  .settings-tab {
    padding: 10px 12px !important;
    font-size: 13px !important;
  }

  .pair-code {
    font-size: 18px;
    letter-spacing: 0.06em;
  }

  .stat-card .text-3xl {
    font-size: 1.5rem;
  }
}
