:root {
  --color-primary: #0544a4;
  --color-accent-start: #2baee7;
  --color-accent-end: #a6d13e;
  --accent-gradient: linear-gradient(135deg, var(--color-accent-start), var(--color-accent-end));
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 30px;
  --shadow-soft: 0 18px 45px rgba(5, 68, 164, 0.08);
  --shadow-panel: 0 24px 60px rgba(8, 35, 67, 0.12);
  --sidebar-width: 260px;
  --content-max: 1500px;
}

body.light-theme {
  --bg-base: #fefefe;
  --bg-elevated: rgba(255, 255, 255, 0.94);
  --bg-muted: #f4f8ff;
  --bg-panel: linear-gradient(180deg, rgba(43, 174, 231, 0.06), rgba(166, 209, 62, 0.07));
  --sidebar-bg: linear-gradient(180deg, #083a84, #0544a4 52%, #06357f);
  --sidebar-surface: rgba(255, 255, 255, 0.1);
  --sidebar-text: #fefefe;
  --text-primary: #333333;
  --text-secondary: #5f748b;
  --text-muted: #7f93ab;
  --line-color: rgba(18, 49, 84, 0.12);
  --line-strong: rgba(18, 49, 84, 0.18);
  --button-text: #fefefe;
  --status-panel-bg: linear-gradient(135deg, rgba(43, 174, 231, 0.09), rgba(166, 209, 62, 0.08));
  --status-card-bg: rgba(255, 255, 255, 0.88);
  --status-error: #c85050;
  --status-success: #3d8d2f;
  --status-pending: #0b76c8;
}

body.dark-theme {
  --bg-base: #0a192f;
  --bg-elevated: #16263f;
  --bg-muted: rgba(17, 34, 64, 0.92);
  --bg-panel: linear-gradient(180deg, rgba(43, 174, 231, 0.12), rgba(166, 209, 62, 0.09));
  --sidebar-bg: linear-gradient(180deg, #03111f, #07284c 55%, #0b3563);
  --sidebar-surface: rgba(255, 255, 255, 0.06);
  --sidebar-text: #f5fbff;
  --text-primary: #e6f1ff;
  --text-secondary: #b4c6da;
  --text-muted: #8fa7c0;
  --line-color: rgba(180, 198, 218, 0.14);
  --line-strong: rgba(180, 198, 218, 0.24);
  --button-text: #fefefe;
  --status-panel-bg: linear-gradient(135deg, rgba(43, 174, 231, 0.14), rgba(166, 209, 62, 0.08));
  --status-card-bg: rgba(10, 25, 47, 0.72);
  --status-error: #ff8f8f;
  --status-success: #b4eb76;
  --status-pending: #84d8ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text-primary);
  background:
    radial-gradient(circle at top right, rgba(43, 174, 231, 0.12), transparent 24%),
    radial-gradient(circle at bottom left, rgba(166, 209, 62, 0.12), transparent 22%),
    var(--bg-base);
  transition: background 180ms ease, color 180ms ease;
  overflow-x: hidden;
}

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

button {
  border: 0;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, color 140ms ease, opacity 140ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
}

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  border: 1px solid var(--line-color);
  border-radius: var(--radius-md);
  padding: 13px 15px;
  background: var(--bg-base);
  color: var(--text-primary);
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease, color 140ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(43, 174, 231, 0.72);
  box-shadow: 0 0 0 4px rgba(43, 174, 231, 0.12);
}

.hidden {
  display: none !important;
}

.hidden-by-role {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(166, 209, 62, 0.2), transparent 20%),
    linear-gradient(160deg, #06275f, #0544a4);
}

.login-card {
  width: min(440px, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--line-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-panel);
  padding: 34px;
  display: grid;
  gap: 16px;
}

.login-brand {
  display: flex;
  justify-content: flex-start;
}

.login-logo {
  width: 180px;
  height: auto;
  object-fit: contain;
}

.eyebrow,
.section-tag {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.login-card h1,
.page-card h2 {
  margin: 0;
  line-height: 1.06;
}

.login-card h1 {
  font-size: clamp(2rem, 4vw, 2.5rem);
}

.login-copy,
.sidebar-copy {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.6;
}

.login-credit {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

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

.mobile-sidebar-backdrop,
.mobile-sidebar-button,
.mobile-sidebar-close {
  display: none;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 0;
  width: 100%;
  background: linear-gradient(180deg, #0c1524, #0c1524);
  color: var(--sidebar-text);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 26px;
  min-height: 78px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.sidebar-top,
.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 16px;
}

.sidebar-footer {
  margin-left: auto;
}

.sidebar-brand-logo {
  width: 148px;
  height: auto;
  object-fit: contain;
}

.sidebar .eyebrow,
.sidebar-copy,
.sidebar-signature {
  color: rgba(254, 254, 254, 0.8);
}

.theme-toggle-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.theme-label {
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  color: rgba(254, 254, 254, 0.86);
}

.theme-toggle {
  min-width: 76px;
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--sidebar-text);
  box-shadow: none;
}

.nav-tabs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
}

.nav-tab {
  text-align: center;
  padding: 12px 14px;
  border-radius: 12px;
  background: transparent;
  color: var(--sidebar-text);
  box-shadow: none;
  font-weight: 500;
}

.nav-tab.active {
  background: rgba(255, 255, 255, 0.08);
  color: #fefefe;
  font-weight: 700;
}

.main-content {
  width: 100%;
  min-width: 0;
  padding: 24px 30px 30px;
}

.main-content > .tab-panel {
  width: min(100%, var(--content-max));
  min-width: 0;
  margin: 0 auto;
}

.tab-panel {
  display: none;
  min-width: 0;
}

.tab-panel.active {
  display: grid;
  gap: 24px;
}

.main-header {
  width: min(100%, var(--content-max));
  margin: 0 auto 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
}

.brand-inline {
  display: flex;
  align-items: flex-end;
  gap: 14px;
}

.mobile-sidebar-button {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  padding: 0;
  background: rgba(5, 68, 164, 0.1);
  box-shadow: none;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-direction: column;
}

.mobile-sidebar-button span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: var(--color-primary);
}

.mobile-sidebar-close {
  margin-left: auto;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--sidebar-text);
  font-size: 1.5rem;
  line-height: 1;
  box-shadow: none;
}

.header-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-inline h2 {
  margin: 0;
  font-size: clamp(2rem, 3vw, 2.75rem);
  line-height: 1.1;
}

.main-copy {
  margin: 0;
  max-width: 680px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.session-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.96);
  font-weight: 700;
  white-space: nowrap;
}

.session-inline span {
  opacity: 0.94;
}

.ghost-button {
  border-radius: 10px;
  background: transparent;
  color: var(--sidebar-text);
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.75);
}

.secondary-ghost {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
}

.page-card {
  width: 100%;
  min-width: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--line-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-panel);
  padding: 26px;
}

.hero-card-main {
  background: var(--bg-panel), var(--bg-elevated);
}

.dashboard-shell {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.toolbar-search-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: 999px;
  background: rgba(5, 68, 164, 0.08);
  color: var(--color-primary);
  box-shadow: none;
}

.toolbar-search-button:hover:not(:disabled) {
  background: rgba(5, 68, 164, 0.14);
}

.search-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(5, 68, 164, 0.12);
  font-size: 0.95rem;
  line-height: 1;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}

.top-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}

.activation-grid .field-olt,
.activation-grid .field-onu,
.activation-grid .field-vlan,
.activation-grid .field-description {
  grid-column: span 6;
}

.activation-grid .field-model {
  grid-column: span 6;
}

.activation-grid .field-operator {
  grid-column: span 6;
}

.activation-grid .field-customer {
  grid-column: 1 / -1;
}

.inline-form {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.93rem;
  min-width: 0;
  overflow: hidden;
  word-break: break-word;
}

.button-cell {
  align-self: end;
}

.button-cell button {
  width: 100%;
}

.full-width {
  grid-column: 1 / -1;
}

button:not(.nav-tab):not(.ghost-button):not(.theme-toggle) {
  background: linear-gradient(135deg, var(--color-primary), #2364cf);
  color: var(--button-text);
  border-radius: var(--radius-md);
  padding: 13px 18px;
  box-shadow: 0 14px 30px rgba(5, 68, 164, 0.18);
}

button.secondary {
  background: rgba(18, 49, 84, 0.08);
  color: var(--text-primary);
  box-shadow: none;
}

button.danger {
  background: rgba(200, 80, 80, 0.12);
  color: #b33d3d;
}

button.small {
  padding: 10px 14px;
  border-radius: 12px;
}

.form-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.status-text {
  color: var(--text-secondary);
  font-size: 0.92rem;
}

.status-text.error {
  color: var(--status-error);
}

.progress-panel {
  width: 100%;
  max-width: 960px;
  min-width: 0;
  padding: 20px;
  border-radius: 12px;
  background: var(--status-panel-bg);
  border: 1px solid var(--line-color);
}

.progress-panel h3 {
  margin: 0 0 14px;
}

.stage-list {
  display: grid;
  gap: 12px;
}

.stage-card {
  padding: 14px 16px;
  border-radius: 12px;
  background: var(--status-card-bg);
  border: 1px solid var(--line-strong);
  display: grid;
  gap: 6px;
}

.stage-card.success {
  border-color: rgba(166, 209, 62, 0.4);
  background: rgba(166, 209, 62, 0.15);
}

.stage-card.pending {
  border-color: rgba(43, 174, 231, 0.36);
  background: rgba(43, 174, 231, 0.12);
}

.stage-card.error {
  border-color: rgba(200, 80, 80, 0.28);
  background: rgba(200, 80, 80, 0.09);
}

.existing-ont-panel {
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 243, 205, 0.8);
  border: 1px solid rgba(184, 134, 11, 0.24);
  display: grid;
  gap: 10px;
}

body.dark-theme .existing-ont-panel {
  background: rgba(133, 96, 23, 0.25);
  border-color: rgba(224, 189, 90, 0.25);
}

.existing-ont-panel p {
  margin: 0;
}

.table-wrap {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: auto;
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 860px;
}

th,
td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line-color);
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--text-muted);
  font-size: 0.81rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pagination-bar {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.pagination-numbers {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pagination-pill {
  min-width: 38px;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(18, 49, 84, 0.08);
  color: var(--text-primary);
  box-shadow: none;
}

.pagination-pill.active {
  background: var(--accent-gradient);
  color: #062b51;
  font-weight: 700;
}

.main-footer {
  width: min(100%, var(--content-max));
  margin: 8px auto 0;
  padding: 10px 4px 0;
}

.main-footer p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.status-success {
  background: rgba(61, 141, 47, 0.14);
  color: #2d7a22;
}

.status-removido {
  background: rgba(200, 80, 80, 0.14);
  color: #b33d3d;
}

.status-draft {
  background: rgba(5, 68, 164, 0.1);
  color: var(--color-primary);
}

.status-error {
  background: rgba(200, 80, 80, 0.14);
  color: #b33d3d;
}

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

  .activation-grid .field-olt,
  .activation-grid .field-onu,
  .activation-grid .field-vlan,
  .activation-grid .field-description,
  .activation-grid .field-model,
  .activation-grid .field-operator {
    grid-column: span 1;
  }
}

@media (max-width: 1100px) {
  .sidebar {
    padding: 14px 18px;
    min-height: auto;
    flex-wrap: wrap;
  }
}

@media (max-width: 860px) {
  .grid-form,
  .top-grid {
    grid-template-columns: 1fr;
  }

  .main-header,
  .inline-form,
  .card-header,
  .brand-inline,
  .header-title-row {
    flex-direction: column;
    align-items: stretch;
  }

  .app-shell {
    display: block;
  }

  .mobile-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(1, 10, 24, 0.58);
    backdrop-filter: blur(3px);
    z-index: 39;
  }

  .mobile-sidebar-backdrop.hidden {
    display: none !important;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(82vw, 320px);
    min-height: 100vh;
    padding: 22px 18px 18px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 20px;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 180ms ease;
    overflow-y: auto;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 0;
  }

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

  .sidebar-top,
  .sidebar-footer,
  .nav-tabs {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .sidebar-top {
    position: relative;
    padding-right: 52px;
  }

  .sidebar-footer {
    margin-left: 0;
    margin-top: auto;
  }

  .mobile-sidebar-close,
  .mobile-sidebar-button {
    display: inline-flex;
  }

  .main-content {
    width: 100%;
    padding: 18px 14px 24px;
    overflow-x: clip;
  }

  .main-header {
    margin-bottom: 18px;
  }

  .brand-inline {
    align-items: center;
    gap: 12px;
  }

  .brand-inline h2 {
    font-size: clamp(1.9rem, 8vw, 2.4rem);
  }

  .main-copy {
    font-size: 0.95rem;
  }

  .nav-tab {
    text-align: left;
    width: 100%;
  }

  .theme-toggle-group {
    display: flex;
    flex-direction: row;
    align-items: center;
  }

  .session-inline {
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
  }

  .ghost-button,
  .theme-toggle {
    width: 100%;
  }

  .toolbar-search-button {
    width: 100%;
    justify-content: center;
  }

  .page-card,
  .login-card {
    padding: 20px;
    border-radius: var(--radius-lg);
  }

  .progress-panel {
    max-width: none;
  }

  .pagination-bar {
    justify-content: center;
  }

  .page-card {
    padding: 18px 14px;
  }

  .card-header,
  .dashboard-shell,
  .progress-panel,
  .form-actions,
  .field,
  label {
    min-width: 0;
  }
}
