:root {
    --bg: #f6f7f5;
    --panel: #ffffff;
    --ink: #17201a;
    --muted: #66736d;
    --line: #dfe5dd;
    --soft: #eef3ef;
    --accent: #0f766e;
    --accent-strong: #115e59;
    --amber: #d97706;
    --danger: #b42318;
    --success: #16803c;
    --shadow: 0 18px 50px rgba(28, 43, 36, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    letter-spacing: 0;
}

a {
    color: inherit;
}

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

svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
}

.app-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 22px 16px;
    color: #f7fbf8;
    background: #13231d;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 800;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    color: #fff;
    background: var(--accent);
    font-size: 13px;
    font-weight: 900;
}

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

.nav-label {
    margin: 14px 10px 4px;
    color: rgba(255, 255, 255, 0.54);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border: 0;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.78);
    background: transparent;
    text-decoration: none;
    cursor: pointer;
}

.nav-item:hover,
.nav-item.is-active {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.logout-form {
    margin-top: auto;
}

.logout-button {
    width: 100%;
}

.main {
    min-width: 0;
    padding: 28px;
}

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

.topbar h1 {
    margin: 3px 0 0;
    font-size: 30px;
    line-height: 1.1;
}

.eyebrow {
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: 0;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--muted);
}

.network-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 8px 11px;
    border: 1px solid #f0c37a;
    border-radius: 8px;
    color: #7a4400;
    background: #fff8e8;
    font-weight: 900;
}

.install-app-button[hidden],
.network-chip[hidden] {
    display: none;
}

.install-app-floating {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 40;
    box-shadow: var(--shadow);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

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

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

.stat-card {
    padding: 18px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 28px;
    line-height: 1;
}

.panel {
    padding: 18px;
}

.panel-header,
.toolbar,
.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.panel-header {
    margin-bottom: 14px;
}

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

.panel-meta {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.toolbar {
    margin-bottom: 14px;
}

.dashboard-section {
    margin-bottom: 18px;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
}

.inline-action-form {
    display: inline-flex;
    margin: 0;
}

.inline-action-form .button {
    width: 100%;
}

.button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-weight: 800;
    text-decoration: none;
    cursor: pointer;
}

.button {
    padding: 9px 13px;
}

.button-primary {
    color: #fff;
    background: var(--accent);
}

.button-primary:hover {
    background: var(--accent-strong);
}

.button-secondary {
    color: var(--ink);
    border-color: var(--line);
    background: var(--panel);
}

.button-secondary:hover {
    background: var(--soft);
}

.icon-button {
    width: 36px;
    height: 36px;
    color: var(--muted);
    border-color: var(--line);
    background: #fff;
}

.icon-button:hover {
    color: var(--ink);
    background: var(--soft);
}

.icon-button.danger:hover {
    color: #fff;
    border-color: var(--danger);
    background: var(--danger);
}

.copy-button {
    width: 30px;
    height: 30px;
    min-height: 30px;
}

.copy-button svg {
    width: 15px;
    height: 15px;
}

.search-form {
    position: relative;
    flex: 1 1 360px;
    max-width: 520px;
}

.search-form svg {
    position: absolute;
    left: 12px;
    top: 50%;
    color: var(--muted);
    transform: translateY(-50%);
}

.search-form input {
    width: 100%;
    padding-left: 40px;
}

.ticket-search-form {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 180px auto;
    gap: 8px;
    max-width: 760px;
}

.ticket-search-form svg {
    top: 21px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
}

input,
select {
    height: 42px;
    padding: 9px 11px;
}

select[multiple] {
    height: auto;
    min-height: 116px;
}

textarea {
    min-height: 112px;
    padding: 10px 11px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(15, 118, 110, 0.15);
    border-color: var(--accent);
}

.form-panel {
    max-width: 980px;
}

.settings-layout {
    display: grid;
    gap: 18px;
    max-width: 980px;
}

.whatsapp-qr-layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr);
    gap: 14px;
    align-items: stretch;
}

.whatsapp-qr-box {
    display: grid;
    place-items: center;
    min-height: 300px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
}

.whatsapp-qr-box img {
    width: min(260px, 100%);
    height: auto;
}

.whatsapp-qr-info {
    display: grid;
    gap: 10px;
}

.whatsapp-qr-info article {
    display: grid;
    gap: 7px;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
}

.whatsapp-qr-info span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.whatsapp-qr-info strong {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 14px;
}

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

.form-section-title {
    margin: 22px 0 12px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    font-size: 16px;
}

.form-section-title:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.field,
.form-stack label {
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.field span,
.form-stack label span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

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

.input-copy-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 36px;
    gap: 8px;
    align-items: center;
}

.input-copy-row .copy-button {
    width: 36px;
    height: 42px;
}

.checkbox-field {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding-top: 23px;
}

.checkbox-field input {
    width: 18px;
    height: 18px;
}

.checkbox-field span {
    color: var(--ink);
}

.help-text {
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.form-actions {
    margin-top: 18px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

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

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

th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

tr:last-child td {
    border-bottom: 0;
}

.row-title {
    display: block;
    color: var(--ink);
    font-weight: 850;
    text-decoration: none;
}

.row-title-button {
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
}

.row-title:hover {
    color: var(--accent-strong);
}

.muted {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
}

.copy-line {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    max-width: 100%;
}

.copy-line + .copy-line {
    margin-top: 5px;
}

.copy-line span {
    overflow-wrap: anywhere;
}

.copy-line.muted {
    display: flex;
}

.client-table {
    min-width: 760px;
    table-layout: fixed;
}

.equipment-table {
    min-width: 1060px;
}

.client-col-name {
    width: 34%;
}

.client-col-document {
    width: 22%;
}

.client-col-email {
    width: 30%;
}

.client-col-equipment {
    width: 72px;
}

.client-col-actions {
    width: 92px;
}

.contact-list {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.contact-line {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) 30px;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.contact-line > svg {
    width: 16px;
    height: 16px;
    color: var(--muted);
}

.contact-value {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.client-toolbar {
    align-items: stretch;
}

.client-directory-panel {
    padding: 0;
    overflow: hidden;
}

.client-list-header,
.client-list-row {
    display: grid;
    grid-template-columns:
        minmax(190px, 1.35fr)
        minmax(170px, 0.95fr)
        minmax(190px, 1.1fr)
        86px
        158px
        118px;
    gap: 12px;
    align-items: center;
}

.client-list-header {
    min-height: 44px;
    padding: 0 16px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    background: #fbfcfb;
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.client-list-row {
    min-height: 78px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

.client-list-row:last-child {
    border-bottom: 0;
}

.client-list-row:hover {
    background: #fbfcfb;
}

.client-list-main,
.client-list-copy {
    min-width: 0;
}

.client-list-name {
    display: grid;
    grid-template-columns: minmax(0, auto) 18px;
    justify-content: start;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.client-list-name span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.client-list-name svg {
    width: 16px;
    height: 16px;
    color: var(--accent-strong);
}

.client-list-count {
    display: flex;
    justify-content: flex-start;
}

.client-list-ticket-counts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.client-count-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #fff;
    text-decoration: none;
}

.client-count-pill:hover {
    border-color: rgba(15, 118, 110, 0.35);
    background: var(--soft);
}

.client-count-pill strong {
    font-size: 17px;
    line-height: 1;
}

.client-count-pill span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.client-count-pill-alert strong {
    color: var(--amber);
}

.client-list-actions {
    justify-content: flex-end;
}

.client-directory {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
    gap: 14px;
}

.client-card {
    display: grid;
    gap: 15px;
    min-width: 0;
}

.client-card-header,
.client-card-footer {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.client-card-title {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 20px;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: var(--ink);
}

.client-card-title span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 17px;
}

.client-card-title svg {
    color: var(--accent-strong);
}

.client-card-contact {
    display: grid;
    gap: 8px;
    padding: 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
}

.client-card-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.client-metric {
    display: grid;
    gap: 3px;
    min-width: 0;
    min-height: 72px;
    padding: 10px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #fff;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
}

.client-metric:hover {
    border-color: rgba(15, 118, 110, 0.35);
    background: var(--soft);
}

.client-metric span {
    font-size: 24px;
    font-weight: 900;
    line-height: 1;
}

.client-metric small {
    min-width: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    line-height: 1.2;
}

.client-metric-alert span {
    color: var(--amber);
}

.client-card-footer {
    align-items: center;
    padding-top: 2px;
}

.client-card-footer .button {
    flex: 0 0 auto;
}

.client-detail-toolbar {
    align-items: stretch;
}

.client-detail-overview {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 14px;
    align-items: start;
    margin-bottom: 14px;
}

.client-detail-contact-panel {
    min-width: 0;
}

.client-detail-contact-header {
    margin-bottom: 12px;
}

.client-detail-contact-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.client-info-item {
    display: grid;
    gap: 7px;
    min-width: 0;
    min-height: 74px;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
}

.client-info-item.is-empty {
    background: #f7f9f7;
}

.client-info-label {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.client-info-label svg {
    width: 15px;
    height: 15px;
}

.client-info-value-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 30px;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.client-info-value-row strong {
    min-width: 0;
    overflow: hidden;
    color: var(--ink);
    font-size: 15px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.client-info-item.is-empty .client-info-value-row {
    grid-template-columns: minmax(0, 1fr);
}

.client-info-item.is-empty .client-info-value-row strong {
    color: var(--muted);
    font-weight: 700;
}

.client-detail-stats {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.client-detail-stat-link {
    display: grid;
    min-height: 88px;
    padding: 16px;
    text-decoration: none;
}

.client-detail-stat-link:hover {
    border-color: rgba(15, 118, 110, 0.35);
    background: #fbfcfb;
}

.client-detail-section-panel {
    margin-bottom: 14px;
}

.client-detail-page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.client-detail-page-header h2 {
    margin: 3px 0 0;
    font-size: 20px;
}

.client-equipment-section-header {
    align-items: stretch;
}

.client-equipment-header-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    min-width: min(640px, 100%);
}

.client-equipment-search-form {
    flex: 1 1 340px;
    max-width: 430px;
}

.client-equipment-no-results {
    margin-top: 12px;
}

.client-detail-ticket-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.client-detail-ticket-group {
    display: grid;
    gap: 10px;
    min-width: 0;
}

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

.client-equipment-card {
    display: grid;
    gap: 14px;
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
}

.client-equipment-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.client-equipment-heading {
    display: grid;
    gap: 7px;
    min-width: 0;
}

.client-equipment-title {
    font-size: 17px;
}

.client-equipment-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.client-equipment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.client-equipment-info {
    display: grid;
    gap: 8px;
    min-width: 0;
    min-height: 76px;
    padding: 10px 11px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.client-equipment-info.is-empty {
    background: #f7f9f7;
}

.client-equipment-label {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.client-equipment-label svg {
    width: 15px;
    height: 15px;
}

.client-equipment-value {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 30px;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.client-equipment-value strong {
    min-width: 0;
    overflow: hidden;
    color: var(--ink);
    font-size: 15px;
    font-weight: 750;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.client-equipment-info.is-empty .client-equipment-value {
    grid-template-columns: minmax(0, 1fr);
}

.client-equipment-info.is-empty .client-equipment-value strong {
    color: var(--muted);
    font-weight: 700;
}

body.modal-open {
    overflow: hidden;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(19, 35, 29, 0.48);
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-panel {
    width: min(1040px, 100%);
    max-height: min(760px, calc(100vh - 40px));
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px;
    border-bottom: 1px solid var(--line);
}

.modal-header h2 {
    margin: 3px 0 0;
    font-size: 20px;
}

.modal-body {
    padding: 18px;
    overflow: auto;
}

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

.client-detail-section {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.client-detail-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.client-detail-section-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 15px;
}

.client-detail-section-header svg {
    width: 18px;
    height: 18px;
    color: var(--accent-strong);
}

.client-summary {
    display: grid;
    gap: 10px;
    margin-bottom: 14px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
}

.client-summary strong {
    font-size: 16px;
}

.client-summary-contacts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.client-summary-contacts-simple {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.client-summary-line {
    display: grid;
    grid-template-columns: 17px minmax(0, 1fr) 30px;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.client-summary-line > svg {
    width: 15px;
    height: 15px;
    color: var(--muted);
}

.client-summary-line span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.equipment-detail-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: #fbfcfb;
}

.equipment-detail-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.equipment-detail-header h3 {
    margin: 0;
    font-size: 16px;
}

.equipment-detail-header span {
    display: block;
    margin-top: 3px;
    color: var(--muted);
    font-size: 13px;
}

.equipment-detail-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.equipment-detail-field {
    min-width: 0;
}

.equipment-detail-label {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.equipment-detail-value {
    display: grid;
    grid-template-columns: 17px minmax(0, 1fr) 30px;
    align-items: center;
    gap: 7px;
    min-height: 32px;
}

.equipment-detail-value > svg {
    width: 15px;
    height: 15px;
    color: var(--muted);
}

.equipment-detail-value span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.remote-connected-section {
    display: grid;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.wireguard-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) auto minmax(340px, 0.9fr);
    gap: 16px;
    align-items: stretch;
    margin-bottom: 16px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
}

.wireguard-hero-main {
    display: grid;
    align-content: start;
    gap: 8px;
    min-width: 0;
}

.wireguard-hero-main h2 {
    margin: 0;
    font-size: 22px;
}

.wireguard-hero-main p {
    margin: 0;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.wireguard-health {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.wireguard-health > div:first-child {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.wireguard-health strong {
    font-size: 28px;
    line-height: 1;
}

.wireguard-health span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.wireguard-health-track {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e8ece9;
}

.wireguard-health-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #0f766e, #2f9b6a);
}

.wireguard-actions {
    display: grid;
    align-content: start;
    gap: 10px;
    min-width: 170px;
}

.wireguard-kpis {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.wireguard-kpis article {
    min-height: 76px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
}

.wireguard-kpis span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.wireguard-kpis strong {
    display: block;
    margin-top: 8px;
    font-size: 26px;
    line-height: 1;
}

.wireguard-section {
    margin-bottom: 16px;
}

.remote-device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 10px;
}

.remote-device-card {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
}

.remote-device-meta {
    display: grid;
    justify-items: end;
    gap: 4px;
    color: var(--muted);
    font-size: 12px;
}

.remote-peer-main {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.remote-peer-key {
    max-width: 260px;
}

.wireguard-online-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.wireguard-online-card {
    background: #fbfcfb;
}

.wireguard-table {
    min-width: 980px;
    table-layout: fixed;
}

.wireguard-table th:nth-child(1),
.wireguard-table td:nth-child(1) {
    width: 150px;
}

.wireguard-table th:nth-child(2),
.wireguard-table td:nth-child(2) {
    width: 270px;
}

.wireguard-table th:nth-child(3),
.wireguard-table td:nth-child(3) {
    width: 170px;
}

.wireguard-table th:nth-child(4),
.wireguard-table td:nth-child(4) {
    width: 190px;
}

.wireguard-table th:nth-child(5),
.wireguard-table td:nth-child(5),
.wireguard-table th:nth-child(6),
.wireguard-table td:nth-child(6) {
    width: 100px;
}

.wireguard-table td {
    vertical-align: top;
}

.wireguard-status-cell {
    white-space: nowrap;
}

.wireguard-status-cell .muted {
    margin-left: 18px;
    white-space: normal;
}

.wireguard-copy-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 30px;
    align-items: center;
    gap: 8px;
    min-width: 0;
    max-width: 100%;
}

.wireguard-copy-line + .wireguard-copy-line,
.wireguard-peer-cell .badge {
    margin-top: 6px;
}

.wireguard-copy-line .mono,
.wireguard-copy-line .muted {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wireguard-copy-line .muted {
    display: block;
    margin-top: 0;
}

.wireguard-endpoint-cell .wireguard-copy-line {
    max-width: 180px;
}

.wireguard-compact-cell strong {
    display: block;
    font-size: 13px;
}

.wireguard-compact-cell .muted {
    margin-top: 0;
    font-size: 12px;
}

.generated-peer-panel {
    margin-bottom: 14px;
}

.wireguard-form-panel {
    max-width: 780px;
}

.generated-peer-panel.wireguard-form-panel {
    max-width: 1180px;
}

.wireguard-peer-layout {
    display: grid;
    grid-template-columns: minmax(340px, 0.85fr) minmax(420px, 1.15fr);
    gap: 14px;
    align-items: start;
    max-width: 1180px;
}

.wireguard-peer-layout .wireguard-form-panel {
    max-width: none;
}

.wireguard-peer-grid {
    grid-template-columns: 1fr;
}

.rb-config-panel {
    display: grid;
    gap: 14px;
}

.rb-config-grid {
    display: grid;
    gap: 10px;
}

.rb-config-item {
    display: grid;
    gap: 8px;
    min-width: 0;
    min-height: 72px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
}

.rb-config-item.is-empty {
    background: #f7f9f7;
}

.rb-config-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
    text-transform: uppercase;
}

.rb-config-value {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr) 30px;
    gap: 8px;
    align-items: center;
    min-width: 0;
}

.rb-config-item.is-empty .rb-config-value {
    grid-template-columns: 18px minmax(0, 1fr);
}

.rb-config-value > svg {
    width: 16px;
    height: 16px;
    color: var(--muted);
}

.rb-config-value strong {
    min-width: 0;
    overflow: hidden;
    color: var(--ink);
    font-size: 13px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rb-config-item.is-empty .rb-config-value strong {
    color: var(--muted);
}

.textarea-copy-wrap {
    display: grid;
    gap: 8px;
}

.textarea-copy-wrap textarea {
    min-height: 250px;
}

.client-ticket-list {
    display: grid;
    gap: 8px;
}

.client-ticket-card {
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
}

.client-ticket-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.client-ticket-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.tickets-table {
    min-width: 980px;
}

.ticket-code-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    min-height: 24px;
    margin: 0 0 5px;
    padding: 4px 8px;
    border: 1px solid #bfd8d4;
    border-radius: 8px;
    color: var(--accent-strong);
    background: #e8f4f2;
    font-size: 12px;
    font-weight: 900;
    line-height: 1.2;
}

.ticket-code-line {
    margin-bottom: 6px;
}

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

.ticket-detail-header h2 {
    margin: 4px 0 0;
    font-size: 22px;
}

.ticket-detail-header p {
    margin: 6px 0 0;
    color: var(--muted);
}

.ticket-status-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.ticket-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 390px;
    gap: 14px;
    align-items: start;
}

.ticket-main-form {
    max-width: none;
}

.ticket-side {
    display: grid;
    gap: 14px;
    min-width: 0;
}

.ticket-action-form {
    display: grid;
    gap: 10px;
}

.ticket-action-form + .ticket-action-form {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.ticket-history-panel {
    max-height: 660px;
    overflow: auto;
}

.ticket-history {
    display: grid;
    gap: 12px;
}

.ticket-history-item {
    display: grid;
    grid-template-columns: 14px minmax(0, 1fr);
    gap: 10px;
}

.ticket-history-marker {
    width: 10px;
    height: 10px;
    margin-top: 5px;
    border-radius: 999px;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.ticket-history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ticket-history-head strong {
    font-size: 13px;
}

.ticket-history-head span {
    color: var(--muted);
    font-size: 12px;
}

.ticket-history-item p {
    margin: 4px 0 0;
    color: var(--ink);
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.network-toolbar {
    margin-bottom: 14px;
}

.network-toolbar-grid {
    display: grid;
    grid-template-columns: minmax(220px, 0.8fr) minmax(240px, 1fr) auto;
    gap: 14px;
    align-items: end;
}

.network-save-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-end;
}

.network-builder {
    display: grid;
    grid-template-columns: 340px minmax(0, 1fr);
    gap: 14px;
}

.network-toolbox {
    align-self: start;
}

.network-toolbox .field {
    margin-bottom: 10px;
}

.network-toolbox h2 {
    margin: 18px 0 10px;
    font-size: 15px;
}

.network-toolbox h2:first-child {
    margin-top: 0;
}

.network-button-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.network-wide-button {
    width: 100%;
    margin-top: 8px;
}

.network-vlan-list {
    display: grid;
    gap: 7px;
    margin-top: 14px;
}

.network-vlan-item {
    display: grid;
    gap: 2px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfb;
}

.network-vlan-item strong {
    font-size: 13px;
}

.network-vlan-item span {
    color: var(--muted);
    font-size: 12px;
}

.network-canvas-panel {
    min-width: 0;
}

.network-canvas-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.network-canvas-header h2 {
    margin: 0;
    font-size: 18px;
}

.network-canvas-header p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.network-canvas {
    position: relative;
    height: min(620px, calc(100vh - 250px));
    min-height: 430px;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background:
        linear-gradient(#edf2ee 1px, transparent 1px),
        linear-gradient(90deg, #edf2ee 1px, transparent 1px),
        #fbfcfb;
    background-size: 24px 24px;
}

.network-links,
.network-nodes {
    position: absolute;
    inset: 0;
}

.network-links {
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.network-link-line {
    stroke: #6b7d75;
    stroke-width: 2.2;
    stroke-linecap: round;
}

.network-link-label {
    fill: #29352f;
    stroke: #fbfcfb;
    stroke-width: 5px;
    paint-order: stroke;
    font-size: 11px;
    font-weight: 900;
    pointer-events: none;
}

.network-node {
    position: absolute;
    width: 224px;
    min-height: 82px;
    display: block;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: #fff;
    box-shadow: 0 8px 24px rgba(28, 43, 36, 0.08);
    text-align: left;
    cursor: grab;
}

.network-node:active {
    cursor: grabbing;
}

.network-node-head {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 8px;
    row-gap: 2px;
    align-items: center;
}

.network-node-head > svg {
    grid-row: 1 / 3;
    width: 24px;
    height: 24px;
    color: var(--accent-strong);
}

.network-node-head strong,
.network-node-head span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.network-node-head strong {
    font-size: 13px;
}

.network-node-head span {
    color: var(--muted);
    font-size: 12px;
}

.network-node-device {
    min-height: 134px;
}

.network-port-list {
    display: grid;
    gap: 5px;
    max-height: 172px;
    margin-top: 10px;
    padding-top: 9px;
    border-top: 1px solid var(--line);
    overflow: auto;
}

.network-port-row {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr);
    gap: 6px;
    align-items: start;
    min-height: 26px;
    padding: 4px 5px;
    border: 1px solid #e8eee8;
    border-radius: 6px;
    background: #fbfcfb;
}

.network-port-name {
    color: var(--ink);
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    font-weight: 900;
}

.network-port-vlans {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-width: 0;
}

.network-port-vlan-badge,
.network-port-empty {
    display: inline-flex;
    align-items: center;
    min-height: 18px;
    padding: 2px 5px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 900;
    line-height: 1.2;
}

.network-port-vlan-badge {
    color: #0f5132;
    background: #dff4e7;
}

.network-port-empty {
    color: var(--muted);
    background: #eef3ef;
}

.network-node-router {
    border-color: #bfd8d4;
}

.network-node-switch {
    border-color: #c8d8bf;
}

.network-node-vlan {
    border-color: #ecd6a3;
    background: #fffaf0;
}

.network-node.is-selected {
    outline: 3px solid rgba(15, 118, 110, 0.2);
    border-color: var(--accent);
}

.mono,
.mono-input {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    font-size: 13px;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 900;
}

.badge-ativo,
.badge-online,
.badge-vpn {
    color: #0f5132;
    background: #dff4e7;
}

.badge-manutencao {
    color: #7a4400;
    background: #fff1d6;
}

.badge-ticket-aberto,
.badge-ticket-em_andamento {
    color: #0f5132;
    background: #dff4e7;
}

.badge-ticket-aguardando,
.badge-ticket-resolvido,
.badge-priority-media {
    color: #7a4400;
    background: #fff1d6;
}

.badge-ticket-fechado,
.badge-ticket-cancelado,
.badge-priority-baixa {
    color: #52605a;
    background: #eef0f2;
}

.badge-priority-alta {
    color: #8a3b00;
    background: #ffe2c2;
}

.badge-priority-critica {
    color: #842029;
    background: #fdecee;
}

.badge-desativado,
.badge-offline {
    color: #6b7280;
    background: #eef0f2;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-right: 7px;
    border-radius: 999px;
}

.status-dot.online {
    background: var(--success);
}

.status-dot.offline {
    background: #89938e;
}

.actions-column {
    width: 96px;
}

.actions-cell {
    display: flex;
    gap: 7px;
}

.actions-cell form {
    margin: 0;
}

.flash-stack {
    display: grid;
    gap: 8px;
    margin-bottom: 14px;
}

.flash {
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font-weight: 700;
}

.flash-success {
    color: #0f5132;
    border-color: #bde7c9;
    background: #e8f7ed;
}

.flash-error {
    color: #842029;
    border-color: #f1b8bf;
    background: #fdecee;
}

.flash-warning {
    color: #7a4400;
    border-color: #f5d8a8;
    background: #fff5df;
    margin-bottom: 14px;
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 140px;
    color: var(--muted);
    border: 1px dashed var(--line);
    border-radius: 8px;
    background: #fbfcfb;
}

.empty-state-compact {
    min-height: 74px;
}

.auth-shell {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 32%),
        var(--bg);
}

.auth-card {
    width: min(430px, 100%);
    padding: 24px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

.auth-brand h1 {
    margin: 0;
    font-size: 24px;
}

.auth-brand p {
    margin: 3px 0 0;
    color: var(--muted);
}

.form-stack {
    display: grid;
    gap: 14px;
}

.auth-link {
    display: inline-block;
    margin-top: 18px;
    color: var(--accent-strong);
    font-weight: 800;
    text-decoration: none;
}

.auth-link:hover {
    text-decoration: underline;
}

.auth-flashes {
    position: fixed;
    top: 16px;
    left: 50%;
    width: min(430px, calc(100% - 32px));
    transform: translateX(-50%);
}

.copy-toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 50;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #fff;
    background: #13231d;
    box-shadow: var(--shadow);
    font-weight: 800;
    opacity: 0;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 160ms ease, transform 160ms ease;
}

.copy-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.dev-reset-box {
    display: grid;
    gap: 7px;
    margin-top: 16px;
    padding: 12px;
    border: 1px solid #f5d8a8;
    border-radius: 8px;
    background: #fff8e8;
    overflow-wrap: anywhere;
}

.dev-reset-box span {
    color: #7a4400;
    font-weight: 900;
}

.dev-reset-box a {
    color: var(--accent-strong);
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        padding: 14px;
    }

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

    .nav-label {
        grid-column: 1 / -1;
    }

    .main {
        padding: 18px;
    }

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

    .wireguard-hero {
        grid-template-columns: 1fr;
    }

    .wireguard-peer-layout {
        grid-template-columns: 1fr;
    }

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

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

    .client-summary-contacts {
        grid-template-columns: 1fr;
    }

    .client-detail-contact-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .client-detail-stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .network-toolbar-grid,
    .network-builder,
    .ticket-layout,
    .whatsapp-qr-layout,
    .client-detail-overview,
    .client-detail-ticket-columns {
        grid-template-columns: 1fr;
    }

    .ticket-search-form {
        max-width: none;
    }

    .network-save-actions,
    .toolbar-actions {
        justify-content: stretch;
    }

    .network-save-actions .button,
    .toolbar-actions .button {
        flex: 1;
    }

    .toolbar-actions .inline-action-form {
        flex: 1;
    }

    .client-list-header {
        display: none;
    }

    .client-list-row {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "main actions"
            "document document"
            "email email"
            "equipment tickets";
        gap: 10px 12px;
        align-items: start;
    }

    .client-list-main {
        grid-area: main;
    }

    .client-list-copy {
        display: grid;
        max-width: 100%;
    }

    .client-list-copy:nth-of-type(2) {
        grid-area: document;
    }

    .client-list-copy:nth-of-type(3) {
        grid-area: email;
    }

    .client-list-count {
        grid-area: equipment;
    }

    .client-list-ticket-counts {
        grid-area: tickets;
        justify-content: flex-end;
    }

    .client-list-actions {
        grid-area: actions;
        justify-content: flex-end;
    }

    .client-equipment-header-actions {
        min-width: 0;
        width: 100%;
    }

    .client-equipment-search-form {
        max-width: none;
    }
}

@media (max-width: 640px) {
    .topbar,
    .toolbar,
    .panel-header,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar h1 {
        font-size: 25px;
    }

    .topbar-actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .network-chip {
        justify-content: center;
        width: 100%;
    }

    .install-app-floating {
        right: 12px;
        bottom: 12px;
        width: calc(100% - 24px);
    }

    .user-chip,
    .button,
    .search-form {
        width: 100%;
    }

    .stats-grid,
    .stats-grid-small,
    .form-grid,
    .wireguard-kpis,
    .equipment-detail-grid {
        grid-template-columns: 1fr;
    }

    .wireguard-actions {
        grid-template-columns: 1fr;
    }

    .wireguard-health > div:first-child {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .panel,
    .auth-card {
        padding: 16px;
    }

    .modal-backdrop {
        padding: 10px;
    }

    .modal-header,
    .modal-body {
        padding: 14px;
    }

    .network-button-grid,
    .network-save-actions,
    .toolbar-actions,
    .ticket-detail-header,
    .ticket-history-head,
    .client-ticket-card-header,
    .client-card-footer,
    .client-detail-page-header {
        grid-template-columns: 1fr;
        flex-direction: column;
    }

    .client-detail-contact-grid {
        grid-template-columns: 1fr;
    }

    .client-detail-stats {
        grid-template-columns: 1fr;
    }

    .client-directory {
        grid-template-columns: 1fr;
    }

    .client-card-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .client-card-footer .button {
        width: 100%;
    }

    .client-list-row {
        grid-template-columns: 1fr;
        grid-template-areas:
            "main"
            "document"
            "email"
            "equipment"
            "tickets"
            "actions";
    }

    .client-list-count,
    .client-list-ticket-counts,
    .client-list-actions {
        justify-content: flex-start;
    }

    .client-count-pill {
        flex: 1 1 auto;
        justify-content: center;
    }

    .client-equipment-header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .client-equipment-grid {
        grid-template-columns: 1fr;
    }

    .client-equipment-header-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .client-equipment-search-form {
        flex-basis: auto;
        width: 100%;
    }

    .ticket-search-form {
        grid-template-columns: 1fr;
    }

    .ticket-search-form svg {
        top: 21px;
    }

    .ticket-status-stack {
        justify-content: flex-start;
    }

    .client-ticket-badges {
        justify-content: flex-start;
    }

    .network-canvas {
        min-height: 500px;
    }
}
