:root {
    --bg-main: #f3f6fb;
    --bg-sidebar: #ffffff;
    --bg-topbar: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #eef3fb;

    --color-primary: #145da0;
    --color-gold: #bf8b1d;
    --color-gold-light: #f6be4f;

    --color-success: #16a34a;
    --color-danger: #dc2626;
    --color-info: #0284c7;
    --color-warning: #d97706;

    --color-text: #122033;
    --color-muted: #5e6f85;
    --color-text-soft: #7a879a;

    --border-soft: #dbe4f1;
    --border-color: #d4dfef;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;

    --container-pad-desktop: 24px;
    --container-pad-tablet: 14px;
    --container-pad-mobile: 10px;
    --touch-target: 44px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    overflow-x: hidden;
}

body {
    background: radial-gradient(circle at 0 0, #e8f0fb, #f3f6fb 45%, #f8faff);
    color: var(--color-text);
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: #0f1a2a;
}

p {
    color: #2f425c;
}

small,
.subtitle,
.text-muted {
    color: var(--color-text-soft) !important;
}

.mobile-only {
    display: none !important;
}

.desktop-only {
    display: inherit !important;
}

.btn,
.btn-system,
.btn-sys,
.btn-public,
.btn-login,
.btn-hero-primary,
.btn-hero-secondary {
    min-height: var(--touch-target);
}

.form-control,
.form-select,
input[type="date"],
input[type="time"],
input[type="tel"],
input[type="email"],
input[type="password"],
textarea {
    min-height: var(--touch-target);
    font-size: 16px;
}

input[type="file"].form-control {
    padding-block: 8px;
    line-height: 1.35;
}

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

.sidebar {
    width: 270px;
    background: linear-gradient(180deg, #ffffff, #f9fbff);
    border-right: 1px solid var(--border-color);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-mobile-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 8px 2px 14px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-header h5 {
    color: #0f1a2a;
    margin: 0;
}

.sidebar-subtitle {
    color: var(--color-text-soft);
    font-size: 12px;
}

.sidebar-section {
    margin-top: 8px;
}

.sidebar-title {
    display: block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: #91a1b8;
    margin: 2px 8px 8px;
}

.sidebar-link,
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 6px;
    color: #2f425c;
    text-decoration: none;
    border: 1px solid transparent;
    transition: .2s ease;
}

.sidebar-link:hover,
.sidebar nav a:hover {
    background: var(--bg-hover);
    color: #0f1a2a;
    border-color: #d9e4f5;
}

.sidebar-link.active,
.sidebar nav a.active {
    background: #e9f2ff;
    color: #0d467d;
    border-color: #bed6f5;
    font-weight: 600;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    min-height: 70px;
    background: rgba(255, 255, 255, .95);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    position: sticky;
    top: 0;
    backdrop-filter: blur(8px);
    z-index: 20;
}

.mobile-menu-btn {
    display: none;
    width: 38px;
    height: 38px;
    border: 1px solid #cfdbec;
    background: #f5f9ff;
    color: #1d3f63;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.mobile-sidebar-overlay {
    display: none;
}

body.mobile-nav-open {
    overflow: hidden;
}

.topbar h4 {
    margin: 0;
    color: #0f1a2a;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.topbar-heading {
    min-width: 0;
}

.topbar-subtitle {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-tenant-name {
    font-weight: 700;
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.topbar .btn-outline-light {
    border-color: #bed0e6;
    color: #24405f;
}

.topbar .btn-outline-light:hover {
    background: #edf3fc;
    border-color: #a7c2e6;
    color: #163554;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.info {
    background: #d9efff;
    color: #0369a1;
}

.content-wrapper {
    flex: 1;
    padding: 20px;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    box-shadow: 0 6px 24px rgba(12, 31, 55, .05);
}

.card-dark {
    background: #ffffff;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 26px rgba(15, 37, 66, .06);
    padding: 24px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
    gap: 10px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: #0e243f;
    margin: 0;
}

.btn-system,
.btn-sys {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 600;
    cursor: pointer;
    transition: .2s ease;
}

.btn-system {
    padding: 9px 18px;
    font-size: 14px;
}

.btn-sys {
    padding: 6px 12px;
    font-size: 13px;
    border: 1px solid var(--border-color);
}

.btn-mini {
    border: none;
    border-radius: 8px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 600;
    min-height: 34px;
}

.btn-mini.btn-success,
.btn-mini.btn-danger {
    color: #fff;
}

.btn-gold {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch-target);
    border-radius: 999px;
    border: 1px solid #145da0;
    background: linear-gradient(135deg, #1f75c2, #145da0);
    color: #ffffff;
    font-weight: 600;
    padding: 8px 18px;
    text-decoration: none;
}

.btn-gold:hover {
    color: #ffffff;
    background: linear-gradient(135deg, #1b6db8, #124f88);
}

.btn-system-primary,
.btn-sys-primary {
    background: linear-gradient(135deg, #1f75c2, #145da0);
    color: #ffffff;
}

.btn-system-primary:hover,
.btn-sys-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(20, 93, 160, .2);
}

.btn-system-neutral,
.btn-sys-neutral,
.btn-action {
    background: #f2f6fd;
    border: 1px solid #d3e1f3;
    color: #1f3b5c;
}

.btn-system-neutral:hover,
.btn-sys-neutral:hover,
.btn-action:hover {
    background: #e7effb;
    color: #163554;
}

.btn-sys-danger {
    background: #fff1f2;
    color: #b91c1c;
    border: 1px solid #fecdd3;
}

.btn-sys-danger:hover {
    background: #ffe4e8;
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: #415a77;
    margin-bottom: 6px;
}

.form-control,
.form-select {
    background: #ffffff;
    border: 1px solid #ccd9ea;
    color: #132238;
    border-radius: 11px;
    padding: 10px 12px;
}

.form-control::placeholder {
    color: #8da0b8;
}

.form-control:focus,
.form-select:focus {
    border-color: #7cb0e7;
    box-shadow: 0 0 0 3px rgba(20, 93, 160, .14);
}

.form-control:disabled,
.form-control[readonly] {
    background-color: #f1f5fb !important;
    color: #61748f !important;
    border: 1px solid #cfddf0;
    opacity: 1;
}

.text-muted-small {
    display: inline-block;
    color: #6f839d;
    font-size: 12px;
}

.table-dark-custom {
    width: 100%;
    border-collapse: collapse;
}

.table-dark-custom th,
.table-dark-custom td {
    padding: 12px;
    border-bottom: 1px solid #e2eaf5;
    font-size: 14px;
    color: #1d3550;
}

.table-dark-custom th {
    color: #5a708d;
    font-weight: 700;
    background: #f8fbff;
}

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

.table-custom th,
.table-custom td {
    padding: 12px;
    border-bottom: 1px solid #e2eaf5;
    font-size: 14px;
    color: #1d3550;
}

.table-custom th {
    color: #5a708d;
    font-weight: 700;
    background: #f8fbff;
}

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

.table-clean th,
.table-clean td {
    padding: 12px;
    border-bottom: 1px solid #e2eaf5;
    font-size: 14px;
    color: #1d3550;
    vertical-align: middle;
}

.table-clean th {
    color: #5a708d;
    font-weight: 700;
    background: #f8fbff;
}

.table-clean tbody tr:hover {
    background: #f7fbff;
}

.badge-ui {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.2;
}

.badge-ativo {
    color: #0f766e;
    background: #ccfbf1;
}

.badge-inativo {
    color: #b91c1c;
    background: #fee2e2;
}

.badge-configurado {
    color: #1d4ed8;
    background: #dbeafe;
}

.badge-ui-info {
    color: #0369a1;
    background: #d9efff;
}

.link-domain {
    color: #145da0;
    text-decoration: none;
    font-weight: 600;
}

.link-domain:hover {
    color: #0f4b81;
    text-decoration: underline;
}

.actions-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.inline-form {
    display: inline;
}

.card-module {
    background: #ffffff;
    border: 1px solid #dbe7f6;
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 8px 20px rgba(15, 37, 66, .05);
}

.card-module h5 {
    margin-bottom: 14px;
    color: #11385f;
    font-weight: 700;
}

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

.dashboard-container {
    display: grid;
    gap: 14px;
}

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

.chart-wrapper {
    height: 250px;
    min-height: 250px;
}

.chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

.kpi-card,
.card-kpi {
    background: #ffffff;
    border: 1px solid #dde8f6;
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 5px 20px rgba(14, 36, 63, .05);
}

.kpi-title,
.kpi-label {
    color: #6d819a;
    font-size: 13px;
}

.kpi-value {
    margin-top: 8px;
    font-size: 30px;
    font-weight: 700;
    color: #123a64;
}

.card-kpi.highlight {
    border-color: #f5d9a4;
    background: #fffaf1;
}

.metric-success,
.text-success {
    color: var(--color-success) !important;
}

.metric-info,
.text-info {
    color: var(--color-info) !important;
}

.logs-card {
    padding: 24px;
}

.logs-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 18px;
    gap: 12px;
    flex-wrap: wrap;
}

.logs-filters {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 12px;
    color: #5f7591;
    font-weight: 600;
}

.input-filter,
.logs-filters input,
.logs-filters select {
    background: #fff;
    border: 1px solid #cfddf1;
    color: #193450;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
}

.btn-filter,
.logs-filters button {
    background: #145da0;
    border: none;
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: 600;
}

.btn-log-detail {
    width: 34px;
    height: 34px;
    border-radius: 9px;
    border: 1px solid #cad9ec;
    background: #f7fbff;
    color: #1a476f;
}

.btn-log-detail:hover {
    background: #eaf3ff;
}

.log-detail-row td {
    background: #fbfdff;
}

.log-detail-box {
    border: 1px solid #dbe7f6;
    border-radius: 10px;
    padding: 10px;
    background: #f5f9ff;
}

.log-detail-box pre {
    margin: 0;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
    color: #2b4664;
}

.pagination {
    margin-top: 14px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.pagination a {
    min-width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #c8d9ee;
    border-radius: 8px;
    text-decoration: none;
    color: #1b456c;
    background: #ffffff;
}

.logs-table-wrapper {
    max-height: 520px;
    overflow-y: auto;
    border: 1px solid #dce7f6;
    border-radius: 10px;
}

.table-logs {
    width: 100%;
}

.table-logs tbody tr {
    border-bottom: 1px solid #ebf1f9;
}

.table-logs td {
    padding: 10px;
    font-size: 14px;
    color: #223a58;
}

.log-detail-text {
    margin: 0;
    white-space: pre-line;
    color: #3f5671;
    font-size: 13px;
}

.badge-blue {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-green {
    background: #dcfce7;
    color: #15803d;
}

.badge-yellow {
    background: #fef3c7;
    color: #92400e;
}

.badge-red {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-gray {
    background: #e5e7eb;
    color: #374151;
}

.empty-state {
    max-width: 560px;
    margin: 0 auto;
    text-align: center;
    padding: 36px 20px;
    color: #60748e;
}

.desktop-table-wrap {
    display: block;
}

.mobile-list-cards {
    display: none;
}

.mobile-list-card {
    background: #ffffff;
    border: 1px solid #dbe7f6;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 14px rgba(15, 37, 66, .05);
}

.mobile-list-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.mobile-list-title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: #123a64;
}

.mobile-list-meta {
    display: grid;
    gap: 6px;
}

.mobile-list-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    font-size: 13px;
    align-items: flex-start;
}

.mobile-list-label {
    color: #6a819b;
}

.mobile-list-value {
    color: #1f3c5c;
    text-align: right;
    font-weight: 500;
    word-break: break-word;
}

.mobile-list-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mobile-list-actions .btn-sys,
.mobile-list-actions form {
    flex: 1 1 calc(50% - 4px);
}

.mobile-list-actions form .btn-sys {
    width: 100%;
}

.form-action-bar {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}

.form-action-bar.form-action-bar-start {
    justify-content: flex-start;
}

.agenda-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    background: #ffffff;
    border: 1px solid #dbe6f5;
    border-radius: 12px;
    padding: 12px 14px;
}

.agenda-item + .agenda-item {
    margin-top: 8px;
}

.agenda-hoje {
    border-left: 4px solid #1f75c2;
}

.agenda-hora {
    font-weight: 700;
    color: #0f3f70;
    min-width: 62px;
}

.agenda-cliente {
    flex: 1;
}

.agenda-servico {
    color: #6f8198;
    font-size: 13px;
}

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

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

@media (max-width: 920px) {
    .admin-layout {
        min-height: 100vh;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1040;
        width: min(84vw, 320px);
        height: 100vh;
        border-right: 1px solid var(--border-color);
        transform: translateX(-100%);
        transition: transform .22s ease;
        overflow-y: auto;
        padding-top: 16px;
    }

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

    .sidebar-mobile-header {
        display: flex;
    }

    .mobile-sidebar-overlay {
        position: fixed;
        inset: 0;
        z-index: 1030;
        background: rgba(9, 20, 33, .45);
        opacity: 0;
        pointer-events: none;
        transition: opacity .22s ease;
    }

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

    .topbar {
        padding: 10px var(--container-pad-tablet);
        min-height: 60px;
        gap: 8px;
    }

    .mobile-menu-btn {
        display: inline-flex;
        margin-right: 10px;
    }

    .topbar-left {
        align-items: flex-start;
        min-width: 0;
        flex: 1;
    }

    .topbar-left h4 {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .topbar-heading {
        display: flex;
        flex-direction: column;
        min-width: 0;
    }

    .topbar-subtitle {
        margin-top: 1px;
        font-size: 11px;
        line-height: 1.25;
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .topbar-tenant-label {
        display: none;
    }

    .topbar-right {
        margin-left: 8px;
        gap: 8px !important;
        flex-shrink: 0;
    }

    .status-badge {
        display: none;
    }

    .topbar .btn-outline-light {
        padding: 6px 10px;
        font-size: 12px;
    }

    .content-wrapper {
        padding: var(--container-pad-tablet);
    }

    .container-fluid {
        padding-inline: var(--container-pad-tablet) !important;
    }

    .table-responsive,
    .mobile-table-scroll,
    .logs-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table-dark-custom,
    .table-custom,
    .table-clean,
    .table-logs {
        min-width: 680px;
        font-size: 13px;
    }

    .table-actions {
        min-width: 190px;
    }

    .logs-filters {
        width: 100%;
    }

    .filter-group {
        min-width: 130px;
        flex: 1 1 150px;
    }

    .btn-filter {
        min-height: var(--touch-target);
        align-self: flex-end;
    }
}

@media (max-width: 720px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .kpi-card,
    .card-kpi {
        padding: 14px;
    }

    .kpi-title,
    .kpi-label {
        font-size: 12px;
    }

    .kpi-value {
        margin-top: 6px;
        font-size: 34px;
    }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .page-header .btn-system,
    .page-header .btn-sys {
        width: 100%;
        white-space: normal;
        text-align: center;
    }

    .desktop-table-wrap {
        display: none;
    }

    .mobile-list-cards {
        display: grid;
        gap: 10px;
    }
}

@media (max-width: 576px) {
    .mobile-only {
        display: block !important;
    }

    .desktop-only {
        display: none !important;
    }

    .topbar {
        padding: 8px var(--container-pad-mobile);
    }

    .mobile-menu-btn {
        margin-right: 4px;
    }

    .topbar-right {
        justify-content: flex-end;
    }

    .btn-logout {
        width: 34px;
        height: 34px;
        padding: 0;
        border-radius: 9px;
        justify-content: center;
    }

    .btn-logout .logout-label {
        display: none;
    }

    .topbar .btn-outline-light i {
        margin: 0;
    }

    .topbar-subtitle {
        -webkit-line-clamp: 1;
        font-size: 10px;
    }

    .content-wrapper {
        padding: var(--container-pad-mobile);
    }

    .container-fluid {
        padding-inline: var(--container-pad-mobile) !important;
        padding-top: 6px !important;
    }

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

    .kpi-card,
    .card-kpi {
        padding: 12px;
    }

    .kpi-value {
        font-size: 30px;
    }

    .chart-wrapper {
        height: 180px;
        min-height: 180px;
    }

    .card,
    .card-dark {
        border-radius: 12px;
    }

    .card-dark {
        padding: 14px;
    }

    .page-title {
        font-size: 1.08rem;
    }

    .table-dark-custom,
    .table-custom,
    .table-clean,
    .table-logs {
        min-width: 600px;
    }

    .actions-inline {
        width: 100%;
    }

    .actions-inline .btn-sys,
    .actions-inline .btn-system,
    .actions-inline form,
    .actions-inline a {
        width: 100%;
    }

    .actions-inline form .btn-sys,
    .actions-inline form .btn-system {
        width: 100%;
    }

    .logs-header {
        align-items: stretch;
    }

    .logs-filters {
        gap: 10px;
    }

    .filter-group,
    .btn-filter {
        width: 100%;
    }

    .card-module {
        padding: 14px;
        border-radius: 12px;
    }

    .mobile-list-actions .btn-sys,
    .mobile-list-actions form {
        flex-basis: 100%;
    }

    .form-action-bar {
        position: sticky;
        bottom: 0;
        background: rgba(243, 246, 251, .96);
        border-top: 1px solid #d7e4f4;
        margin: 16px -10px -10px;
        padding: 10px;
        z-index: 8;
    }

    .form-action-bar .btn-sys,
    .form-action-bar .btn-system {
        width: 100%;
    }

    .btn-system,
    .btn-sys {
        min-height: 40px;
    }

    .mobile-action-group,
    .mobile-action-group form,
    .mobile-action-group a,
    .mobile-action-group button {
        width: 100%;
    }

    .mobile-stack-2 .col-6 {
        width: 100%;
    }

    .checkbox-group {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
    }

    .agenda-item {
        align-items: flex-start;
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 12px;
    }

    .agenda-hora {
        min-width: auto;
        font-size: 14px;
    }

    .agenda-status {
        min-width: 100%;
        text-align: left;
    }
}

@media (max-width: 420px) {
    .topbar h4 {
        font-size: .95rem;
    }

    .topbar-subtitle {
        display: none;
    }
}
