/* ============================================================
   Agency / Admin workspace shell + shared design vocabulary.

   Pages that render their own full-page chrome (sidebar + main
   content) instead of the plain dashboard layout use these
   classes: /dashboard-agency, /admin/dashboard, /dashboard-sub-agency
   and /agency/worker-import.
   ============================================================ */

.agency-shell {
    --agency-accent: #0d9488;
    --agency-accent-strong: #0f766e;
    --agency-accent-soft: #5eead4;
    --agency-accent-tint: rgba(13, 148, 136, 0.18);
    --agency-accent-shadow: rgba(13, 148, 136, 0.25);
    --agency-accent-gradient: linear-gradient(to top right, #14b8a6, #0d9488);
    --agency-focus-ring: rgba(20, 184, 166, 0.2);

    display: flex;
    min-height: 100vh;
    background: #f8fafc;
    color: #1e293b;
    font-family: 'Plus Jakarta Sans', 'Segoe UI', sans-serif;
}

.agency-shell--admin {
    --agency-accent: #4f46e5;
    --agency-accent-strong: #4338ca;
    --agency-accent-soft: #a5b4fc;
    --agency-accent-tint: rgba(79, 70, 229, 0.18);
    --agency-accent-shadow: rgba(79, 70, 229, 0.25);
    --agency-accent-gradient: linear-gradient(to top right, #6366f1, #4338ca);
    --agency-focus-ring: rgba(99, 102, 241, 0.2);
}

.agency-shell--sub {
    --agency-accent: #2f7df6;
    --agency-accent-strong: #1d63d8;
    --agency-accent-soft: #93c5fd;
    --agency-accent-tint: rgba(47, 125, 246, 0.18);
    --agency-accent-shadow: rgba(47, 125, 246, 0.25);
    --agency-accent-gradient: linear-gradient(to top right, #4b8ef8, #2f7df6);
    --agency-focus-ring: rgba(47, 125, 246, 0.2);
}

/* ============ SIDEBAR ============ */
.agency-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    display: none;
    flex-direction: column;
    justify-content: space-between;
    width: 260px;
    background: #0f172a;
    color: #cbd5e1;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
}

.agency-sidebar__brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding: 0 1.5rem;
    border-bottom: 1px solid rgba(30, 41, 59, 0.8);
}

.agency-sidebar__brand > div:first-child {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.agency-sidebar__brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 12px;
    background: var(--agency-accent-gradient);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
    box-shadow: 0 4px 6px -1px var(--agency-accent-shadow);
}

.agency-sidebar__brand h1 {
    margin: 0;
    color: #fff;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.1;
}

.agency-sidebar__brand span {
    color: var(--agency-accent-soft);
    font-size: 0.68rem;
    font-weight: 500;
}

.agency-sidebar__profile {
    margin: 1rem 0.75rem 0;
    padding: 1rem;
    border: 1px solid rgba(51, 65, 85, 0.5);
    border-radius: 12px;
    background: rgba(30, 41, 59, 0.6);
}

.agency-sidebar__profile-meta {
    overflow: hidden;
}

.agency-sidebar__profile-meta p {
    margin: 0;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agency-sidebar__profile-meta span {
    color: #94a3b8;
    font-size: 0.65rem;
    white-space: nowrap;
}

.agency-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0 0.75rem;
    margin-top: 1rem;
}

.agency-sidebar__nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.agency-sidebar__nav-item i {
    width: 1rem;
    text-align: center;
    font-size: 0.85rem;
}

.agency-sidebar__nav-item:hover {
    background: rgba(30, 41, 59, 0.6);
    color: #f1f5f9;
}

.agency-sidebar__nav-item--active {
    background: var(--agency-accent);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 10px 15px -3px var(--agency-accent-shadow);
}

.agency-sidebar__group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.agency-sidebar__group-toggle {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #94a3b8;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.agency-sidebar__group-toggle > i:first-child {
    width: 1rem;
    text-align: center;
    font-size: 0.85rem;
}

.agency-sidebar__group-toggle span {
    flex: 1;
}

.agency-sidebar__group-chevron {
    font-size: 0.65rem;
    transition: transform 0.2s ease;
}

.agency-sidebar__group-toggle--expanded {
    background: rgba(30, 41, 59, 0.6);
    color: #f1f5f9;
}

.agency-sidebar__group-toggle--expanded .agency-sidebar__group-chevron {
    transform: rotate(180deg);
}

.agency-sidebar__group-toggle:hover {
    background: rgba(30, 41, 59, 0.6);
    color: #f1f5f9;
}

.agency-sidebar__subnav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.15rem 0 0.15rem 1.65rem;
}

.agency-sidebar__subnav-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    color: #94a3b8;
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1.3;
    text-decoration: none;
    transition: all 0.2s ease;
}

.agency-sidebar__subnav-item i {
    width: 0.9rem;
    text-align: center;
    font-size: 0.7rem;
}

.agency-sidebar__subnav-item:hover {
    background: var(--agency-accent-tint);
    color: var(--agency-accent-soft);
}

.agency-sidebar__subnav-item--active {
    background: var(--agency-accent-tint);
    color: var(--agency-accent-soft);
    font-weight: 700;
}

.agency-sidebar__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-top: 1px solid rgba(30, 41, 59, 0.8);
}

.agency-sidebar__footer-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #94a3b8;
    font-size: 0.68rem;
}

.agency-sidebar__footer-status i {
    color: #34d399;
    font-size: 0.7rem;
}

.agency-sidebar__logout {
    border: 0;
    background: transparent;
    color: #94a3b8;
    font-size: 0.8rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.agency-sidebar__logout:hover {
    color: #fb7185;
}

/* ============ MAIN CONTENT ============ */
.agency-main {
    width: 100%;
    min-width: 0;
}

.agency-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 80rem;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* Compact header shown while the sidebar is collapsed (below 1024px). */
.agency-mobilebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: #0f172a;
    color: #fff;
}

.agency-mobilebar__brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.agency-mobilebar__brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 10px;
    background: var(--agency-accent-gradient);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
}

.agency-mobilebar__brand h1 {
    margin: 0;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.1;
}

.agency-mobilebar__brand span {
    color: var(--agency-accent-soft);
    font-size: 0.62rem;
}

.agency-mobilebar__actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

/* ============ PAGE HEAD ============ */
.agency-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 1.25rem 1.5rem;
    border: 1px solid #e2e8f0;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.agency-page-head__eyebrow {
    display: inline-block;
    margin-bottom: 0.4rem;
    color: var(--agency-accent);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.agency-page-head h1 {
    margin: 0 0 0.35rem;
    color: #0f172a;
    font-size: 1.35rem;
    font-weight: 800;
    line-height: 1.2;
}

.agency-page-head p {
    margin: 0;
    color: #64748b;
    font-size: 0.82rem;
}

.agency-page-head__actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ============ PANELS ============ */
.agency-panel,
.agency-state-card {
    padding: 1.25rem;
    border-radius: 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.agency-panel__header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.agency-panel__header h2 {
    margin: 0 0 0.35rem;
    color: #0f172a;
    font-size: 1.05rem;
    font-weight: 700;
}

.agency-panel__header p {
    margin: 0;
    color: #64748b;
    font-size: 0.8rem;
}

.agency-panel__actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* Nested panel used for the sections inside a larger card. */
.agency-subpanel {
    padding: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #fbfdff;
}

.agency-subpanel__header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.9rem;
    color: #0f172a;
}

.agency-subpanel__header i {
    color: var(--agency-accent);
    font-size: 0.85rem;
}

.agency-subpanel__header h3 {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 700;
}

/* ============ BUTTONS ============ */
.agency-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    color: #334155;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.agency-btn:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.agency-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.agency-btn--primary {
    border-color: var(--agency-accent);
    background: var(--agency-accent);
    color: #fff;
    box-shadow: 0 4px 6px -1px var(--agency-accent-shadow);
}

.agency-btn--primary:hover {
    background: var(--agency-accent-strong);
    border-color: var(--agency-accent-strong);
}

.agency-btn--ghost {
    border-color: transparent;
    background: transparent;
    color: #64748b;
}

.agency-btn--ghost:hover {
    background: #f1f5f9;
    border-color: transparent;
    color: #0f172a;
}

.agency-btn--danger {
    border-color: #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}

.agency-btn--danger:hover {
    background: #fee2e2;
    border-color: #fca5a5;
}

.agency-btn--sm {
    padding: 0.35rem 0.65rem;
    font-size: 0.7rem;
    border-radius: 10px;
}

/* ============ FORMS ============ */
.agency-form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.agency-form-field {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.agency-form-field--full {
    grid-column: 1 / -1;
}

.agency-form-field label {
    color: #475569;
    font-size: 0.8rem;
    font-weight: 600;
}

.agency-form-field input,
.agency-form-field select,
.agency-form-field textarea {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
    color: #0f172a;
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.agency-form-field textarea {
    min-height: 90px;
    resize: vertical;
}

.agency-form-field input:focus,
.agency-form-field select:focus,
.agency-form-field textarea:focus {
    outline: none;
    border-color: var(--agency-accent);
    box-shadow: 0 0 0 3px var(--agency-focus-ring);
    background: #fff;
}

.agency-form-field input:disabled,
.agency-form-field textarea:disabled,
.agency-form-field select:disabled {
    background: #f1f5f9;
    color: #94a3b8;
}

.agency-form-field input[readonly] {
    background: #f1f5f9;
    color: #64748b;
}

.agency-check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.4rem 1rem;
}

.agency-check-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-radius: 10px;
    background: #f8fafc;
    color: #334155;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
}

.agency-check-item input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    margin: 0;
    accent-color: var(--agency-accent);
    cursor: pointer;
}

/* ============ BADGES ============ */
.agency-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    background: #f0fdfa;
    color: var(--agency-accent-strong);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
}

.agency-badge--owned {
    background: #ecfdf5;
    color: #15803d;
}

.agency-badge--inactive {
    background: rgba(100, 116, 139, 0.12);
    color: #64748b;
}

.agency-badge--attention {
    background: #fef2f2;
    color: #b91c1c;
}

/* ============ FEEDBACK / EMPTY / STATE ============ */
.agency-feedback {
    padding: 0.9rem 1rem;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 600;
}

.agency-feedback--success {
    border: 1px solid #a7f3d0;
    background: #ecfdf5;
    color: #065f46;
}

.agency-feedback--error,
.agency-state-card--error {
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}

.agency-feedback--warning {
    border: 1px solid #fde68a;
    background: #fffbeb;
    color: #92400e;
}

.agency-feedback--info {
    border: 1px solid #bfdbfe;
    background: #eff6ff;
    color: #1d4ed8;
}

.agency-empty-state {
    padding: 0.9rem 1rem;
    border-radius: 14px;
    background: #f8fafc;
    color: #5c6d89;
    font-size: 0.85rem;
}

.agency-state-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 120px;
}

/* ============ MODAL ============ */
.agency-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
}

.agency-modal {
    width: min(460px, 100%);
    padding: 1.5rem;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.35);
}

.agency-modal__head {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.agency-modal__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: #ecfdf5;
    color: #059669;
    font-size: 1rem;
}

.agency-modal h2 {
    margin: 0 0 0.25rem;
    color: #0f172a;
    font-size: 1.05rem;
    font-weight: 700;
}

.agency-modal p {
    margin: 0;
    color: #64748b;
    font-size: 0.82rem;
    line-height: 1.5;
}

.agency-modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.25rem;
}

/* ============ LISTS ============ */
.agency-list-plain {
    margin: 0;
    padding-left: 1.1rem;
    color: #475569;
    font-size: 0.8rem;
    line-height: 1.7;
}

.agency-list-plain li {
    word-break: break-word;
}

/* ============ RESPONSIVE ============ */
@media (min-width: 1024px) {
    .agency-sidebar {
        display: flex;
    }

    .agency-main {
        width: calc(100% - 260px);
        margin-left: 260px;
    }

    .agency-content {
        padding: 2rem;
    }

    .agency-mobilebar {
        display: none;
    }
}

@media (max-width: 960px) {
    .agency-panel__header {
        flex-direction: column;
    }

    .agency-panel__actions {
        align-items: stretch;
        width: 100%;
    }

    .agency-form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .agency-panel,
    .agency-state-card {
        padding: 1rem;
    }

    .agency-page-head {
        padding: 1rem;
    }

    .agency-page-head h1 {
        font-size: 1.15rem;
    }

    .agency-modal__actions {
        flex-direction: column-reverse;
    }

    .agency-modal__actions .agency-btn {
        width: 100%;
    }
}
