@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    color: #333;
    background: #f0f2f5;
}

a {
    color: #4a90e2;
    text-decoration: none;
}

    a:hover {
        text-decoration: underline;
    }

/* ── Shell layout ─────────────────────────────────────────────────────────── */
.ca-shell {
    display: flex;
    min-height: 100vh;
}

.ca-main {
    flex: 1;
    padding: 20px 24px;
    overflow-y: auto;
    min-width: 0;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.ca-sidebar {
    width: 220px;
    background: #1e2a3a;
    color: #c8d6e5;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.ca-sidebar-brand {
    padding: 24px 20px 16px;
    border-bottom: 1px solid #2d3f54;
}

.ca-brand-name {
    display: block;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

.ca-brand-sub {
    display: block;
    font-size: 11px;
    color: #7a9ab8;
    margin-top: 2px;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.ca-site-pill {
    margin: 12px 16px 4px;
    padding: 6px 10px;
    background: #2d3f54;
    border-radius: 6px;
    font-size: 12px;
    color: #a8bfd6;
    display: flex;
    align-items: center;
    gap: 6px;
    word-break: break-all;
}

.ca-nav-list {
    list-style: none;
    flex: 1;
    padding: 8px 0;
}

.ca-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: #c8d6e5;
    font-size: 13px;
    transition: background .15s;
    text-decoration: none;
}

    .ca-nav-link:hover,
    .ca-nav-link.active {
        background: #2d3f54;
        color: #fff;
        text-decoration: none;
    }

    .ca-nav-link i {
        font-size: 16px;
    }

.ca-sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid #2d3f54;
}

.ca-user-info {
    margin-bottom: 10px;
}

.ca-user-email {
    display: block;
    font-size: 12px;
    color: #7a9ab8;
    word-break: break-all;
}

.ca-user-role {
    display: block;
    font-size: 11px;
    color: #4a6a8a;
    margin-top: 2px;
}

.ca-logout-btn {
    background: none;
    border: 1px solid #2d3f54;
    color: #7a9ab8;
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    width: 100%;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background .15s;
}

    .ca-logout-btn:hover {
        background: #2d3f54;
        color: #c8d6e5;
    }

/* ── Page layout ──────────────────────────────────────────────────────────── */
.ca-page {
    max-width: 100%;
}

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

    .ca-page-header h1 {
        font-size: 22px;
        font-weight: 600;
        color: #1e2a3a;
    }

.ca-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* ── Cards ────────────────────────────────────────────────────────────────── */
.ca-card {
    background: #fff;
    border: 1px solid #e0e4ea;
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

    .ca-card h2 {
        font-size: 15px;
        font-weight: 600;
        color: #1e2a3a;
        margin-bottom: 16px;
    }

.ca-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

    .ca-card-header h2 {
        margin-bottom: 0;
    }

.ca-card-form {
    border-left: 3px solid #4a90e2;
}

.ca-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

@media (max-width: 768px) {
    .ca-two-col {
        grid-template-columns: 1fr;
    }
}

/* ── Metric grid ──────────────────────────────────────────────────────────── */
.ca-metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.ca-metric-card {
    background: #fff;
    border: 1px solid #e0e4ea;
    border-radius: 8px;
    padding: 16px 20px;
    text-align: center;
}

    .ca-metric-card i {
        font-size: 24px;
        color: #4a90e2;
        display: block;
        margin-bottom: 8px;
    }

.ca-metric-value {
    font-size: 24px;
    font-weight: 700;
    color: #1e2a3a;
}

.ca-metric-label {
    font-size: 12px;
    color: #7a9ab8;
    margin-top: 4px;
}

/* ── Bar chart ────────────────────────────────────────────────────────────── */
.ca-bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 160px;
    padding-bottom: 24px;
    position: relative;
}

.ca-bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    cursor: default;
}

.ca-bar {
    width: 100%;
    background: #4a90e2;
    border-radius: 3px 3px 0 0;
    min-height: 2px;
    transition: background .15s;
}

.ca-bar-col:hover .ca-bar {
    background: #2d78d6;
}

.ca-bar-label {
    font-size: 10px;
    color: #7a9ab8;
    margin-top: 4px;
    white-space: nowrap;
}

/* ── Tables ───────────────────────────────────────────────────────────────── */
.ca-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

    .ca-table th {
        text-align: left;
        padding: 10px 12px;
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .06em;
        color: #4a6080;
        background: #f0f4f8;
        border-bottom: 2px solid #dbe4ed;
        white-space: nowrap;
        position: sticky;
        top: 0;
        z-index: 1;
        cursor: pointer;
        user-select: none;
    }

        .ca-table th:hover {
            background: #e4eaf2;
        }

    .ca-table td {
        padding: 8px 12px;
        border-bottom: 1px solid #edf0f4;
        vertical-align: middle;
        max-width: 260px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .ca-table tbody tr:nth-child(even) td {
        background: #f8fafc;
    }

    .ca-table tbody tr:nth-child(odd) td {
        background: #ffffff;
    }

    .ca-table tbody tr:hover td {
        background: #e8f0fe !important;
        transition: background 0.1s;
    }

    .ca-table tr:last-child td {
        border-bottom: none;
    }

.ca-muted {
    color: #7a9ab8;
}

.ca-mono {
    font-family: monospace;
    font-size: 12px;
}

.ca-code {
    color: #7a9ab8;
    font-size: 12px;
}

.ca-actions {
    text-align: right;
    white-space: nowrap;
}

.ca-table-footer {
    font-size: 12px;
    color: #7a9ab8;
    padding: 8px 0;
}

/* ── Forms ────────────────────────────────────────────────────────────────── */
.ca-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.ca-form-group-wide {
    flex: 2;
}

.ca-form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

    .ca-form-row .ca-form-group {
        flex: 1;
        min-width: 160px;
    }

.ca-form-inline {
    background: #f8fafc;
    border: 1px solid #e0e4ea;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}

.ca-form-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.ca-label {
    font-size: 12px;
    font-weight: 600;
    color: #4a6a8a;
}

.ca-input {
    padding: 8px 10px;
    border: 1px solid #d0d8e4;
    border-radius: 5px;
    font-size: 13px;
    color: #333;
    background: #fff;
    outline: none;
    transition: border-color .15s;
    width: 100%;
}

    .ca-input:focus {
        border-color: #4a90e2;
    }

.ca-input-code {
    letter-spacing: .2em;
    font-size: 18px;
    text-align: center;
    font-family: monospace;
}

.ca-select {
    padding: 8px 10px;
    border: 1px solid #d0d8e4;
    border-radius: 5px;
    font-size: 13px;
    color: #333;
    background: #fff;
    outline: none;
    cursor: pointer;
    width: 100%;
}

.ca-search {
    max-width: 300px;
}

.ca-hint {
    font-size: 12px;
    color: #7a9ab8;
    margin-bottom: 16px;
    line-height: 1.5;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.ca-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
    text-decoration: none;
}

    .ca-btn:disabled {
        opacity: .55;
        cursor: not-allowed;
    }

.ca-btn-primary {
    background: #4a90e2;
    color: #fff;
    border-color: #3a7fd2;
}

    .ca-btn-primary:hover:not(:disabled) {
        background: #3a7fd2;
    }

.ca-btn-secondary {
    background: #fff;
    color: #4a6a8a;
    border-color: #d0d8e4;
}

    .ca-btn-secondary:hover:not(:disabled) {
        background: #f0f2f5;
    }

.ca-btn-link {
    background: none;
    border: none;
    color: #4a90e2;
    padding: 6px 0;
    font-size: 13px;
    cursor: pointer;
    display: block;
    text-align: center;
    width: 100%;
}

.ca-btn-full {
    width: 100%;
    justify-content: center;
}

.ca-btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    color: #4a6a8a;
    font-size: 16px;
    transition: background .15s;
}

    .ca-btn-icon:hover {
        background: #f0f2f5;
        color: #1e2a3a;
    }

.ca-btn-icon-danger:hover {
    background: #fef2f2;
    color: #e24b4a;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.ca-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

.ca-badge-green {
    background: #e6f4ea;
    color: #2d7a3a;
}

.ca-badge-red {
    background: #fef2f2;
    color: #a32d2d;
}

.ca-badge-gray {
    background: #f0f2f5;
    color: #4a6a8a;
}

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.ca-alert {
    padding: 10px 14px;
    border-radius: 5px;
    font-size: 13px;
    margin-bottom: 16px;
}

.ca-alert-error {
    background: #fef2f2;
    color: #a32d2d;
    border: 1px solid #f5c6cb;
}

.ca-alert-success {
    background: #e6f4ea;
    color: #2d7a3a;
    border: 1px solid #b7dfbe;
}

/* ── Login page ───────────────────────────────────────────────────────────── */
.ca-login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f0f2f5;
}

.ca-login-card {
    background: #fff;
    border: 1px solid #e0e4ea;
    border-radius: 10px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
}

.ca-login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.ca-login-hint {
    font-size: 13px;
    color: #4a6a8a;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* ── Pin dot ──────────────────────────────────────────────────────────────── */
.ca-pin-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,.15);
}

/* ── Empty and loading states ─────────────────────────────────────────────── */
.ca-empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #7a9ab8;
}

    .ca-empty-state i {
        font-size: 40px;
        display: block;
        margin-bottom: 12px;
    }

    .ca-empty-state p {
        margin-bottom: 16px;
    }

.ca-empty-inline {
    text-align: center;
    padding: 24px;
    color: #7a9ab8;
    font-size: 13px;
}

.ca-loading {
    text-align: center;
    padding: 48px 24px;
    color: #7a9ab8;
    font-size: 14px;
}

/* ── Connection string helper ─────────────────────────────────────────────── */
.ca-input-error {
    border-color: #e24b4a !important;
    background: #fff8f8;
}

.ca-field-error {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #a32d2d;
    font-size: 12px;
    margin-top: 4px;
}

.ca-conn-format {
    margin-top: 8px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e0e4ea;
    border-radius: 5px;
    font-size: 12px;
    color: #4a6a8a;
    line-height: 1.6;
}

    .ca-conn-format code {
        display: block;
        margin-top: 4px;
        font-family: monospace;
        font-size: 11px;
        color: #1e2a3a;
        word-break: break-all;
    }

.ca-conn-example {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    color: #7a9ab8;
    word-break: break-all;
}

.ca-conn-success {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #2d7a3a;
    font-size: 13px;
    font-weight: 600;
    margin-top: 8px;
    padding: 8px 12px;
    background: #e6f4ea;
    border-radius: 5px;
    width: 100%;
}

    .ca-conn-success i {
        font-size: 16px;
    }


/* ── Data grid (Listings page) ────────────────────────────────────────────── */
.dg-wrapper {
    border-radius: 8px;
    border: 1px solid #dbe4ed;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    margin-bottom: 12px;
}

.dg-scroll {
    overflow-x: auto;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
}

.dg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

.dg-table thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.dg-table th {
    background: #1e2a3a;
    color: #c8d6e5;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    border-right: 1px solid #2d3f54;
}

    .dg-table th:hover {
        background: #273649;
        color: #e8f0fe;
    }

    .dg-table th:last-child {
        border-right: none;
    }

.dg-table td {
    padding: 7px 14px;
    border-bottom: 1px solid #edf0f4;
    border-right: 1px solid #f3f5f7;
    vertical-align: middle;
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12.5px;
    color: #2d3748;
}

    .dg-table td:last-child {
        border-right: none;
    }

.dg-table tbody tr:nth-child(odd) td  { background: #ffffff; }
.dg-table tbody tr:nth-child(even) td { background: #f7f9fb; }

.dg-table tbody tr:hover td {
    background: #e8f0fe !important;
    cursor: default;
}

.dg-table .dg-id {
    color: #9aabbd;
    font-size: 11px;
    font-family: monospace;
    width: 50px;
    text-align: right;
}

.dg-table .dg-latlong {
    font-size: 11px;
    font-family: monospace;
    color: #7a9ab8;
}

.dg-table .dg-actions {
    text-align: center;
    width: 70px;
    padding: 4px 8px;
}

/* ── Data grid toolbar ────────────────────────────────────────────────────── */
.dg-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #dbe4ed;
}

.dg-toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dg-toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dg-search {
    width: 260px;
    padding: 7px 12px 7px 32px;
    border: 1px solid #cdd5de;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239aabbd' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 10px center;
}

    .dg-search:focus {
        outline: none;
        border-color: #4a90e2;
        box-shadow: 0 0 0 3px rgba(74,144,226,0.12);
    }

.dg-count {
    font-size: 12px;
    color: #7a9ab8;
    white-space: nowrap;
}

/* ── Edit form ────────────────────────────────────────────────────────────── */
.dg-edit-form {
    background: #f0f4f8;
    border: 1px solid #dbe4ed;
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.dg-edit-title {
    font-size: 14px;
    font-weight: 600;
    color: #1e2a3a;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dbe4ed;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.dg-edit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.dg-edit-field label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #4a6080;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 4px;
}

.dg-edit-field input,
.dg-edit-field select {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #cdd5de;
    border-radius: 5px;
    font-size: 13px;
    font-family: inherit;
    background: #fff;
    transition: border-color .15s;
}

    .dg-edit-field input:focus,
    .dg-edit-field select:focus {
        outline: none;
        border-color: #4a90e2;
        box-shadow: 0 0 0 3px rgba(74,144,226,0.12);
    }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.dg-pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #f8fafc;
    border-top: 1px solid #edf0f4;
    font-size: 12px;
    color: #7a9ab8;
}

.dg-page-btns {
    display: flex;
    gap: 3px;
}

.dg-page-btn {
    padding: 4px 10px;
    border: 1px solid #dbe4ed;
    background: #fff;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    color: #4a6080;
    transition: all .15s;
}

    .dg-page-btn:hover:not(:disabled) {
        background: #e8f0fe;
        border-color: #4a90e2;
        color: #1a56db;
    }

    .dg-page-btn.active {
        background: #4a90e2;
        border-color: #4a90e2;
        color: #fff;
        font-weight: 600;
    }

    .dg-page-btn:disabled {
        opacity: .4;
        cursor: not-allowed;
    }

/* ── Action buttons in grid ───────────────────────────────────────────────── */
.dg-btn-edit,
.dg-btn-delete {
    border: none;
    background: none;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 13px;
    transition: background .12s;
}

.dg-btn-edit:hover   { background: #e8f0fe; }
.dg-btn-delete:hover { background: #fde8e8; }

/* ── Pin dot ──────────────────────────────────────────────────────────────── */
.dg-pin {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,.15);
    vertical-align: middle;
}

/* ── Modal ────────────────────────────────────────────────────────────────── */
.dg-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

.dg-modal {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    max-width: 420px;
    width: calc(100% - 32px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.dg-modal h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1e2a3a;
    margin-bottom: 8px;
}

.dg-modal p {
    font-size: 13px;
    color: #555;
    margin-bottom: 20px;
}
