* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f6f8;
  color: #17202a;
}

button,
input {
  font: inherit;
}

.hidden {
  display: none !important;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at top right, #243b55 0, transparent 35%),
    linear-gradient(135deg, #0b1320, #17283d);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #ffffff;
  border-radius: 18px;
  padding: 38px;
  box-shadow: 0 24px 70px rgba(0,0,0,.28);
}

.brand {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 4px;
}

.brand-sub {
  margin-top: 4px;
  margin-bottom: 32px;
  color: #697586;
}

label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin: 18px 0 8px;
}

input {
  width: 100%;
  border: 1px solid #d7dde5;
  border-radius: 10px;
  padding: 13px 14px;
  outline: none;
}

input:focus {
  border-color: #34495e;
  box-shadow: 0 0 0 3px rgba(52,73,94,.10);
}

.login-card button {
  width: 100%;
  border: 0;
  margin-top: 24px;
  padding: 14px;
  border-radius: 10px;
  background: #17283d;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.message {
  min-height: 22px;
  margin-top: 16px;
  font-size: 14px;
  color: #c0392b;
}

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

.sidebar {
  width: 250px;
  min-height: 100vh;
  background: #111c2b;
  color: white;
  display: flex;
  flex-direction: column;
  padding: 26px 18px;
}

.sidebar-brand {
  padding: 0 12px 28px;
}

.sidebar-brand strong {
  display: block;
  font-size: 25px;
  letter-spacing: 3px;
}

.sidebar-brand span {
  color: #93a4b8;
  font-size: 13px;
}

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

.nav-item {
  border: 0;
  background: transparent;
  color: #b8c5d3;
  padding: 12px 14px;
  text-align: left;
  border-radius: 9px;
  cursor: pointer;
}

.nav-item:hover,
.nav-item.active {
  color: white;
  background: #22344b;
}

.nav-item.disabled {
  opacity: .45;
  cursor: default;
}

.logout-button {
  margin-top: auto;
  border: 1px solid #34485f;
  background: transparent;
  color: #dce4ec;
  border-radius: 9px;
  padding: 11px;
  cursor: pointer;
}

.main {
  flex: 1;
  padding: 30px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
}

.topbar p {
  margin: 5px 0 0;
  color: #748091;
}

.admin-user {
  text-align: right;
}

.admin-user span {
  display: block;
  font-weight: 700;
}

.admin-user small {
  color: #748091;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card,
.panel {
  background: white;
  border: 1px solid #e4e8ed;
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(17,28,43,.04);
}

.stat-card {
  padding: 22px;
}

.stat-card span {
  display: block;
  color: #748091;
  font-size: 13px;
  margin-bottom: 10px;
}

.stat-card strong {
  font-size: 26px;
}

.panel {
  overflow: hidden;
}

.panel-header {
  padding: 20px 22px;
  border-bottom: 1px solid #edf0f3;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-header h2 {
  margin: 0;
  font-size: 19px;
}

.panel-header p {
  margin: 5px 0 0;
  color: #7c8796;
  font-size: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 18px;
  border-bottom: 1px solid #edf0f3;
  text-align: left;
  font-size: 14px;
}

th {
  background: #fafbfc;
  color: #687586;
  font-size: 12px;
  text-transform: uppercase;
}

.status {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.status.active {
  background: #e8f7ef;
  color: #1e7a46;
}

.status.disabled {
  background: #fbeaea;
  color: #a93226;
}

.status.pending {
  background: #fff4dd;
  color: #9a6700;
}

.secondary-button {
  border: 1px solid #d9dfe6;
  background: white;
  padding: 9px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.empty,
.loading {
  padding: 30px;
  text-align: center;
  color: #7a8696;
}

.global-message {
  margin-bottom: 20px;
  padding: 12px 15px;
  border-radius: 9px;
  background: #fbeaea;
  color: #922b21;
}

@media (max-width: 950px) {
  .cards {
    grid-template-columns: repeat(2, minmax(0,1fr));
  }
}

@media (max-width: 700px) {
  .sidebar {
    width: 190px;
  }

  .main {
    padding: 18px;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }
}

/* ============================================================
   MERGEN ADMIN CUSTOMER DETAIL V1
   ============================================================ */

.detail-back {
  margin-bottom: 18px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.detail-card {
  background: #fff;
  border: 1px solid #e4e8ed;
  border-radius: 12px;
  padding: 18px;
}

.detail-card span {
  display: block;
  color: #748091;
  font-size: 12px;
  margin-bottom: 7px;
}

.detail-card strong {
  display: block;
  word-break: break-word;
}

.home-block {
  margin-top: 18px;
  background: #fff;
  border: 1px solid #e4e8ed;
  border-radius: 14px;
  overflow: hidden;
}

.home-head {
  padding: 18px 20px;
  background: #fafbfc;
  border-bottom: 1px solid #edf0f3;
}

.home-head h3 {
  margin: 0 0 5px;
}

.home-head p {
  margin: 0;
  color: #748091;
  font-size: 13px;
}

.device-block {
  margin: 16px;
  border: 1px solid #e4e8ed;
  border-radius: 11px;
  overflow: hidden;
}

.device-head {
  padding: 15px 17px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
  background: #fff;
}

.device-meta {
  color: #748091;
  font-size: 12px;
  line-height: 1.7;
}

.module-title {
  padding: 11px 17px;
  font-size: 13px;
  font-weight: 700;
  background: #f8fafb;
  border-top: 1px solid #edf0f3;
  border-bottom: 1px solid #edf0f3;
}

.action-button {
  border: 1px solid #d9dfe6;
  background: #fff;
  padding: 7px 11px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}

.action-button:hover {
  background: #f4f6f8;
}

.status.online {
  background: #e8f7ef;
  color: #1e7a46;
}

.status.offline {
  background: #edf0f3;
  color: #596575;
}

.status.error {
  background: #fbeaea;
  color: #a93226;
}

@media (max-width: 950px) {
  .detail-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 650px) {
  .detail-grid {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   MERGEN ADMIN SYSTEM V1
   ============================================================ */

.system-section {
  padding: 22px;
  border-bottom: 1px solid #edf0f3;
}

.system-section:last-child {
  border-bottom: 0;
}

.system-section h3 {
  margin: 0 0 16px;
}

.system-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 14px;
}

.system-card {
  border: 1px solid #e4e8ed;
  border-radius: 12px;
  padding: 17px;
  background: #fafbfc;
}

.system-card span {
  display: block;
  color: #748091;
  font-size: 12px;
  margin-bottom: 8px;
}

.system-card strong {
  font-size: 19px;
}

.service-ok {
  color: #1e7a46;
}

.service-error {
  color: #a93226;
}

.system-device {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding: 15px 0;
  border-bottom: 1px solid #edf0f3;
}

.system-device:last-child {
  border-bottom: 0;
}

.system-device-meta {
  margin-top: 5px;
  color: #748091;
  font-size: 12px;
  line-height: 1.7;
}

@media (max-width: 800px) {
  .system-cards {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   MERGEN CUSTOMER ONBOARDING UI V1
   ============================================================ */

.customer-form-wrap {
  padding: 8px 28px 30px;
}

.form-section {
  padding: 24px 0;
  border-bottom: 1px solid #edf0f3;
}

.form-section:last-of-type {
  border-bottom: 0;
}

.form-section h3 {
  margin: 0 0 18px;
  font-size: 18px;
}

.admin-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.admin-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
}

.admin-form-grid input,
.admin-form-grid textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #d8dee6;
  border-radius: 9px;
  background: #fff;
  padding: 12px 13px;
  font: inherit;
  outline: none;
}

.admin-form-grid input:focus,
.admin-form-grid textarea:focus {
  border-color: #8797aa;
}

.admin-form-grid textarea {
  resize: vertical;
}

.form-wide {
  grid-column: 1 / -1;
}

.password-row {
  display: flex;
  gap: 10px;
}

.password-row input {
  flex: 1;
}

.admin-form-grid small {
  color: #748091;
  font-weight: 400;
  line-height: 1.5;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 24px;
}

.primary-button {
  border: 0;
  border-radius: 9px;
  background: #102033;
  color: #fff;
  padding: 12px 18px;
  font: inherit;
  cursor: pointer;
}

.primary-button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.onboarding-success {
  margin-top: 22px;
  padding: 18px;
  border: 1px solid #bfe5cf;
  border-radius: 10px;
  background: #f0faf4;
  line-height: 1.8;
}

.onboarding-success strong {
  color: #176b3a;
}

@media (max-width: 800px) {
  .admin-form-grid {
    grid-template-columns: 1fr;
  }

  .form-wide {
    grid-column: auto;
  }

  .password-row {
    flex-direction: column;
  }
}

/* ============================================================
   MERGEN DEVICE ASSIGNMENT UI V1
   ============================================================ */

.admin-form-grid select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #d8dee6;
  border-radius: 9px;
  background: #fff;
  padding: 12px 13px;
  font: inherit;
  outline: none;
}

.admin-form-grid select:focus {
  border-color: #8797aa;
}

.admin-form-grid select:disabled {
  background: #f3f5f7;
  color: #87919d;
}

.assignment-current {
  padding: 18px;
  margin-top: 18px;
  border: 1px solid #e1e6eb;
  border-radius: 11px;
  background: #fafbfc;
  line-height: 1.8;
}

.assignment-preview {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid #e5d7a5;
  border-radius: 11px;
  background: #fffaf0;
  line-height: 1.8;
}

.assignment-arrow {
  display: inline-block;
  padding: 0 9px;
  font-weight: 700;
}

.device-action-group {
  display: flex;
  gap: 7px;
  align-items: center;
}

.danger-confirm {
  margin-top: 10px;
  color: #8a5b00;
  font-size: 13px;
  font-weight: 600;
}

/* ============================================================
   MERGEN ADMIN PASSWORD UI V1
   ============================================================ */

.admin-password-panel {
  margin-top: 22px;
  padding: 26px 28px;
  background: #fff;
  border: 1px solid #e1e6eb;
  border-radius: 14px;
}

.admin-password-heading h3 {
  margin: 0 0 6px;
  font-size: 20px;
}

.admin-password-heading p {
  margin: 0;
  color: #748092;
}

.admin-password-form {
  max-width: 650px;
  margin-top: 22px;
}

.admin-password-form label > span {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.password-input-row {
  display: flex;
  gap: 10px;
}

.password-input-row input {
  flex: 1;
  min-width: 0;
  padding: 12px 13px;
  border: 1px solid #d8dee6;
  border-radius: 9px;
  font: inherit;
}

.password-input-row input:focus {
  outline: none;
  border-color: #8797aa;
}

.password-rules {
  margin-top: 8px;
  color: #758194;
  font-size: 13px;
}

.password-admin-note {
  margin-top: 16px;
  padding: 12px 14px;
  background: #f5f7fa;
  border-radius: 9px;
  color: #566273;
  font-size: 13px;
}

.password-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

.password-message {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 9px;
  font-weight: 600;
}

.password-success {
  background: #e9f7ef;
  color: #167343;
}

.password-error {
  background: #fff0f0;
  color: #a32929;
}

@media (max-width: 700px) {
  .password-input-row,
  .password-actions {
    flex-direction: column;
  }
}

/* ============================================================
   MERGEN ADMIN SUPPORT UI V1
   ============================================================ */

.admin-support-panel {
  margin-top: 22px;
  padding: 26px 28px;
  background: #fff;
  border: 1px solid #e1e6eb;
  border-radius: 14px;
}

.admin-support-panel h3 {
  margin: 0 0 6px;
  font-size: 20px;
}

.admin-support-panel p {
  margin: 0;
  color: #748092;
  max-width: 760px;
  line-height: 1.6;
}

.support-actions {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-top: 18px;
}

.support-expiry {
  color: #758194;
  font-size: 13px;
}

.support-message {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 9px;
  font-weight: 600;
}

.support-success {
  background: #e9f7ef;
  color: #167343;
}

.support-error {
  background: #fff0f0;
  color: #a32929;
}

@media (max-width: 700px) {
  .support-actions {
    flex-direction: column;
    align-items: stretch;
  }
}
