:root {
    --primary: #1f8f63;
    --primary-dark: #176e4d;
    --primary-soft: #e8f5ef;
    --background: #f5f6f7;
    --surface: #ffffff;
    --text: #17211c;
    --text-secondary: #66736d;
    --border: #dfe5e2;
    --danger: #b42318;
    --danger-soft: #fef3f2;
    --shadow: 0 24px 70px rgba(15, 35, 26, 0.12);
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    color: var(--text);
    background: var(--background);
    font-family:
        Inter, ui-sans-serif, system-ui, -apple-system,
        BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
input {
    font: inherit;
}

.login-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: minmax(360px, 0.9fr) minmax(500px, 1.1fr);
}

.login-presentation {
    min-height: 100vh;
    padding: 48px;
    color: #ffffff;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(
            circle at 15% 20%,
            rgba(255, 255, 255, 0.16),
            transparent 32%
        ),
        linear-gradient(145deg, #176b4b 0%, #0d3d2b 100%);
}

.brand,
.mobile-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: #ffffff;
    background: var(--primary);
    font-size: 21px;
    font-weight: 800;
    box-shadow: 0 10px 24px rgba(9, 53, 36, 0.22);
}

.brand-light .brand-mark {
    color: #176b4b;
    background: #ffffff;
}

.brand strong,
.mobile-brand strong {
    display: block;
    font-size: 16px;
    line-height: 1.2;
}

.brand small,
.mobile-brand small {
    display: block;
    margin-top: 3px;
    opacity: 0.68;
    font-size: 12px;
}

.presentation-content {
    max-width: 520px;
    margin: auto 0;
}

.eyebrow {
    display: inline-block;
    margin-bottom: 12px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.login-presentation .eyebrow {
    color: #a9e7cd;
}

.presentation-content h1 {
    max-width: 500px;
    margin: 0;
    font-size: clamp(38px, 5vw, 64px);
    line-height: 1.03;
    letter-spacing: -0.045em;
}

.presentation-content p {
    max-width: 500px;
    margin: 24px 0 0;
    color: rgba(255, 255, 255, 0.75);
    font-size: 17px;
    line-height: 1.7;
}

.presentation-footer {
    margin: 0;
    color: rgba(255, 255, 255, 0.55);
    font-size: 13px;
}

.login-form-area {
    min-height: 100vh;
    padding: 40px;
    display: grid;
    place-items: center;
}

.login-card {
    width: min(100%, 430px);
    padding: 42px;
    border: 1px solid var(--border);
    border-radius: 26px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.mobile-brand {
    display: none;
    margin-bottom: 36px;
}

.login-heading h2 {
    margin: 0;
    font-size: 30px;
    letter-spacing: -0.025em;
}

.login-heading p {
    margin: 9px 0 0;
    color: var(--text-secondary);
    line-height: 1.5;
}

.login-form {
    margin-top: 30px;
}

.field {
    display: block;
    margin-bottom: 18px;
}

.field > span {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 700;
}

.field input {
    width: 100%;
    height: 50px;
    padding: 0 15px;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 13px;
    outline: none;
    background: #fafbfa;
    transition:
        border-color 160ms ease,
        box-shadow 160ms ease,
        background 160ms ease;
}

.field input:focus {
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(31, 143, 99, 0.12);
}

.button {
    width: 100%;
    height: 50px;
    padding: 0 18px;
    border: 0;
    border-radius: 13px;
    cursor: pointer;
    font-weight: 800;
    transition:
        transform 160ms ease,
        background 160ms ease,
        box-shadow 160ms ease;
}

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

.button-primary {
    color: #ffffff;
    background: var(--primary);
    box-shadow: 0 12px 24px rgba(31, 143, 99, 0.2);
}

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

.alert {
    margin-top: 24px;
    padding: 13px 15px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
}

.alert-danger {
    color: var(--danger);
    border: 1px solid #fecdca;
    background: var(--danger-soft);
}

.security-note {
    margin: 24px 0 0;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
    text-align: center;
}

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

    .login-presentation {
        display: none;
    }

    .login-form-area {
        min-height: 100vh;
        padding: 24px;
    }

    .mobile-brand {
        display: flex;
    }
}

@media (max-width: 520px) {
    .login-form-area {
        padding: 0;
        background: var(--surface);
    }

    .login-card {
        min-height: 100vh;
        padding: 32px 24px;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }
}

.panel-page {
    min-height: 100vh;
    background: #f4f6f5;
}

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

.sidebar {
    min-height: 100vh;
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    color: #dce8e2;
    background: #102d22;
}

.sidebar-brand {
    padding: 0 8px;
    color: #ffffff;
}

.sidebar-brand .brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
}

.sidebar-nav {
    margin-top: 42px;
    display: grid;
    gap: 7px;
}

.nav-item {
    min-height: 46px;
    padding: 0 13px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #aac0b6;
    text-decoration: none;
    font-size: 14px;
    font-weight: 700;
}

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

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

.nav-symbol {
    width: 27px;
    height: 27px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: #c9ded4;
    background: rgba(255, 255, 255, 0.08);
    font-size: 11px;
    font-weight: 900;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.admin-summary {
    display: flex;
    align-items: center;
    gap: 11px;
}

.admin-avatar {
    width: 38px;
    height: 38px;
    flex: 0 0 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: #ffffff;
    background: var(--primary);
    font-size: 13px;
    font-weight: 900;
}

.admin-details {
    min-width: 0;
}

.admin-details strong,
.admin-details small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.admin-details strong {
    color: #ffffff;
    font-size: 13px;
}

.admin-details small {
    margin-top: 3px;
    color: #8fa99d;
    font-size: 11px;
}

.logout-button {
    width: 100%;
    margin-top: 14px;
    padding: 10px;
    color: #aac0b6;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    background: transparent;
    font-size: 12px;
    font-weight: 800;
}

.logout-button:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.07);
}

.panel-content {
    width: 100%;
    max-width: 1500px;
    padding: 42px;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}

.panel-header h1 {
    margin: 0;
    font-size: 32px;
    letter-spacing: -0.035em;
}

.panel-header p {
    margin: 8px 0 0;
    color: var(--text-secondary);
}

.header-date {
    padding: 10px 13px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    font-size: 12px;
    font-weight: 700;
}

.connection-card {
    margin-top: 30px;
    padding: 24px;
    border: 1px solid #cfe7dc;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    background:
        linear-gradient(135deg, #ffffff 0%, #ecf8f2 100%);
}

.connection-main {
    display: flex;
    align-items: center;
    gap: 16px;
}

.connection-indicator {
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    border: 3px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--border);
}

.connection-indicator.online {
    background: #22a06b;
    box-shadow:
        0 0 0 1px #77c9a7,
        0 0 0 6px rgba(34, 160, 107, 0.1);
}

.connection-indicator.offline {
    background: #d92d20;
}

.card-label {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
}

.connection-main h2 {
    margin: 4px 0;
    font-size: 21px;
}

.connection-main p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.connection-meta {
    text-align: right;
}

.connection-meta span,
.connection-meta strong {
    display: block;
}

.connection-meta span {
    color: var(--text-secondary);
    font-size: 11px;
}

.connection-meta strong {
    margin-top: 5px;
    font-size: 13px;
}

.stats-grid {
    margin-top: 22px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.stat-card {
    padding: 21px;
    border: 1px solid var(--border);
    border-radius: 17px;
    background: var(--surface);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 700;
}

.stat-card strong {
    display: block;
    margin-top: 14px;
    font-size: 30px;
    letter-spacing: -0.04em;
}

.stat-card small {
    display: block;
    margin-top: 5px;
    color: #8b9691;
    font-size: 11px;
}

.content-card {
    margin-top: 22px;
    border: 1px solid var(--border);
    border-radius: 19px;
    background: var(--surface);
    overflow: hidden;
}

.section-heading {
    padding: 22px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid var(--border);
}

.section-heading h2 {
    margin: 0;
    font-size: 17px;
}

.section-heading p {
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.section-count {
    padding: 7px 10px;
    color: var(--text-secondary);
    border-radius: 9px;
    background: #f1f4f2;
    font-size: 11px;
    font-weight: 700;
}

.empty-state {
    padding: 54px 24px;
    text-align: center;
}

.empty-icon {
    width: 46px;
    height: 46px;
    margin: 0 auto;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: var(--primary);
    background: var(--primary-soft);
    font-weight: 900;
}

.empty-state h3 {
    margin: 16px 0 0;
    font-size: 15px;
}

.empty-state p {
    margin: 7px 0 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.table-wrapper {
    overflow-x: auto;
}

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

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

th {
    color: var(--text-secondary);
    background: #fafbfa;
    font-size: 10px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.status-badge {
    display: inline-flex;
    padding: 5px 8px;
    border-radius: 8px;
    color: #52605a;
    background: #eff2f0;
    font-size: 10px;
    font-weight: 800;
}

.status-delivered,
.status-read,
.status-played {
    color: #176e4d;
    background: #e8f5ef;
}

.status-failed {
    color: var(--danger);
    background: var(--danger-soft);
}

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

@media (max-width: 760px) {
    .panel-shell {
        display: block;
    }

    .sidebar {
        min-height: auto;
        padding: 16px;
    }

    .sidebar-nav,
    .sidebar-footer {
        display: none;
    }

    .panel-content {
        padding: 24px 16px;
    }

    .panel-header {
        align-items: center;
    }

    .connection-card {
        align-items: flex-start;
        flex-direction: column;
    }

    .connection-meta {
        text-align: left;
    }

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

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

    .header-date {
        display: none;
    }
}


.alert-success {
    color: #176e4d;
    border: 1px solid #a9ddc5;
    background: #e8f5ef;
}

.live-indicator {
    padding: 9px 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--surface);
    font-size: 11px;
    font-weight: 800;
}

.live-indicator i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d92d20;
}

.live-indicator i.online {
    background: #22a06b;
    box-shadow: 0 0 0 4px rgba(34, 160, 107, 0.12);
}

.whatsapp-grid {
    margin-top: 30px;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
    gap: 20px;
}

.connection-detail-card,
.qr-card {
    margin-top: 0;
}

.connection-detail-body {
    min-height: 300px;
    padding: 34px;
    display: flex;
    align-items: center;
    gap: 28px;
}

.phone-illustration {
    width: 108px;
    height: 176px;
    flex: 0 0 108px;
    padding: 8px;
    border: 5px solid #173c2e;
    border-radius: 25px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #e8f5ef, #cde9dc);
    box-shadow: 0 20px 38px rgba(21, 60, 44, 0.15);
}

.phone-illustration span {
    width: 52px;
    height: 52px;
    border-radius: 17px;
    display: grid;
    place-items: center;
    color: #ffffff;
    background: var(--primary);
    font-size: 22px;
    font-weight: 900;
}

.detail-label {
    display: block;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.connection-information strong {
    display: block;
    margin-top: 8px;
    font-size: 23px;
    letter-spacing: -0.025em;
}

.connection-information p {
    max-width: 340px;
    margin: 10px 0 0;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.6;
}

.connection-status {
    padding: 7px 10px;
    border-radius: 9px;
    font-size: 10px;
    font-weight: 900;
}

.connection-status.success {
    color: #176e4d;
    background: #e8f5ef;
}

.connection-status.warning {
    color: #9a6700;
    background: #fff4ce;
}

.connection-status.danger {
    color: var(--danger);
    background: var(--danger-soft);
}

.qr-card-body {
    min-height: 300px;
    padding: 28px;
    display: grid;
    place-items: center;
}

.qr-frame {
    width: min(100%, 260px);
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 14px 32px rgba(15, 35, 26, 0.09);
}

.qr-frame img {
    width: 100%;
    display: block;
}

.qr-instructions {
    margin: 24px 0 0;
    padding-left: 22px;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.8;
}

.qr-empty {
    max-width: 300px;
    text-align: center;
}

.qr-empty > span {
    width: 58px;
    height: 58px;
    margin: 0 auto;
    border-radius: 18px;
    display: grid;
    place-items: center;
    color: var(--text-secondary);
    background: #eff2f0;
    font-size: 24px;
    font-weight: 900;
}

.qr-empty.success > span {
    color: #ffffff;
    background: var(--primary);
}

.qr-empty h3 {
    margin: 16px 0 0;
    font-size: 16px;
}

.qr-empty p {
    margin: 7px 0 0;
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
}

.danger-zone {
    margin-top: 20px;
    padding: 22px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    border-color: #f3c7c3;
}

.danger-zone h2 {
    margin: 0;
    font-size: 16px;
}

.danger-zone p {
    margin: 7px 0 0;
    color: var(--text-secondary);
    font-size: 12px;
}

.button-inline {
    width: auto;
    white-space: nowrap;
}

.button-danger {
    color: #ffffff;
    background: var(--danger);
}

.button-danger:hover {
    background: #912018;
}

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

@media (max-width: 600px) {
    .connection-detail-body {
        padding: 28px 22px;
        align-items: flex-start;
        flex-direction: column;
    }

    .phone-illustration {
        width: 80px;
        height: 120px;
        flex-basis: 120px;
        border-radius: 20px;
    }

    .danger-zone {
        align-items: stretch;
        flex-direction: column;
    }

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

.new-key-card {
    margin-top: 26px;
    padding: 24px;
    color: #ffffff;
    border-radius: 18px;
    background: linear-gradient(135deg, #176e4d, #0d3d2b);
    box-shadow: 0 18px 40px rgba(13, 61, 43, 0.18);
}

.new-key-card .eyebrow {
    color: #a9e7cd;
}

.new-key-card h2 {
    margin: 0;
    font-size: 20px;
}

.new-key-card p {
    margin: 7px 0 0;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
}

.key-copy-row {
    margin-top: 20px;
    padding: 10px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.1);
}

.key-copy-row code {
    min-width: 0;
    flex: 1;
    overflow-x: auto;
    color: #ffffff;
    font-size: 12px;
    white-space: nowrap;
}

.copy-button {
    padding: 9px 13px;
    color: #176e4d;
    border: 0;
    border-radius: 9px;
    cursor: pointer;
    background: #ffffff;
    font-size: 11px;
    font-weight: 900;
}

.form-grid {
    margin: 22px 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-card {
    margin-top: 0;
}

.panel-form {
    padding: 24px;
}

.field select {
    width: 100%;
    height: 50px;
    padding: 0 15px;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 13px;
    outline: none;
    background: #fafbfa;
}

.field select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(31, 143, 99, 0.12);
}

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

.table-secondary {
    display: block;
    margin-top: 4px;
    color: var(--text-secondary);
    font-size: 10px;
}

.key-prefix {
    padding: 5px 7px;
    border-radius: 7px;
    color: #425049;
    background: #eff2f0;
    font-size: 10px;
}

.table-action {
    padding: 7px 9px;
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    background: #eff2f0;
    font-size: 10px;
    font-weight: 800;
}

.table-action.danger {
    color: var(--danger);
    background: var(--danger-soft);
}

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

    .key-copy-row {
        align-items: stretch;
        flex-direction: column;
    }
}

.message-filter-card {
    margin-top: 30px;
}

.message-filter-form {
    padding: 22px 24px 6px;
    display: grid;
    grid-template-columns:
        minmax(180px, 1.1fr)
        minmax(150px, 0.8fr)
        minmax(190px, 1fr)
        minmax(145px, 0.75fr)
        minmax(145px, 0.75fr)
        auto;
    align-items: end;
    gap: 14px;
}

.message-filter-form .field {
    margin-bottom: 16px;
}

.filter-actions {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-actions .button {
    height: 50px;
}

.filter-clear {
    height: 50px;
    padding: 0 15px;
    border: 1px solid var(--border);
    border-radius: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    background: #fafbfa;
    text-decoration: none;
    font-size: 12px;
    font-weight: 800;
}

.filter-clear:hover {
    color: var(--text);
    background: #f1f4f2;
}

.recipient-number {
    display: block;
    white-space: nowrap;
}

.message-id {
    max-width: 190px;
    margin-top: 5px;
    display: block;
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-error {
    max-width: 170px;
    margin-top: 6px;
    display: block;
    overflow: hidden;
    color: var(--danger);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.messages-table td {
    vertical-align: middle;
}

.pagination {
    padding: 18px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
}

.pagination a,
.pagination > span:not(.pagination-current) {
    min-width: 78px;
    padding: 8px 11px;
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text-secondary);
    background: #ffffff;
    text-align: center;
    text-decoration: none;
    font-size: 11px;
    font-weight: 800;
}

.pagination a:hover {
    color: var(--primary-dark);
    border-color: #a9ddc5;
    background: var(--primary-soft);
}

.pagination .disabled {
    cursor: default;
    opacity: 0.45;
}

.pagination-current {
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 700;
}

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

.status-sent {
    color: #175cd3;
    background: #eff8ff;
}

.status-unknown {
    color: #52605a;
    background: #eff2f0;
}

@media (max-width: 1350px) {
    .message-filter-form {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .filter-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 760px) {
    .message-filter-form {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .filter-actions .button,
    .filter-clear {
        width: 100%;
    }

    .pagination {
        justify-content: center;
    }
}

.accounts-form-grid {
    grid-template-columns: minmax(320px, 560px);
}

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

.user-actions .table-action {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    white-space: nowrap;
}
