:root {
    --bg: #f4f6f8;
    --bg-soft: #e9edf1;
    --card: rgba(255, 255, 255, 0.96);
    --card-strong: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: rgba(148, 163, 184, 0.22);
    --primary: #4f9f7a;
    --primary-dark: #38775b;
    --primary-soft: rgba(79, 159, 122, 0.12);
    --danger: #c84343;
    --danger-bg: #fff0f0;
    --success: #2f7d59;
    --success-bg: #edf9f2;
    --shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", Arial, Helvetica, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(79, 159, 122, 0.10), transparent 24%),
        radial-gradient(circle at bottom right, rgba(203, 213, 225, 0.38), transparent 32%),
        linear-gradient(180deg, #f8fafc, #f4f6f8 45%, #eef2f6);
}

a {
    color: var(--primary-dark);
    text-decoration: none;
    transition: 0.2s ease;
}

img {
    max-width: 100%;
}

.app-shell {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.app-backdrop {
    position: fixed;
    inset: 0;
    pointer-events: none;
    backdrop-filter: blur(2px);
}

.sidebar {
    width: 300px;
    padding: 26px 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.98));
    border-right: 1px solid rgba(148, 163, 184, 0.14);
    backdrop-filter: blur(14px);
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, 0.7), 18px 0 40px rgba(15, 23, 42, 0.06);
}

.brand-box-horizontal {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 72px;
    padding: 0 4px 10px;
    margin-bottom: 18px;
    border-radius: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.brand-logo-horizontal {
    width: 100%;
    max-width: 200px;
    max-height: 70px;
    object-fit: contain;
}

.brand-logo-fallback {
    width: 72px;
    height: 72px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    font-weight: 800;
    font-size: 24px;
}

.sidebar-company {
    display: grid;
    gap: 4px;
    margin-bottom: 18px;
    padding: 14px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--text);
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.sidebar-company span {
    color: var(--muted);
    font-size: 13px;
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.menu a {
    padding: 12px 14px;
    color: #334155;
    border-radius: 14px;
    border: 1px solid transparent;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.menu a:hover {
    transform: translateX(4px);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(79, 159, 122, 0.10));
    border-color: rgba(148, 163, 184, 0.14);
}

.menu a.active {
    background: linear-gradient(135deg, rgba(255, 255, 255, 1), rgba(79, 159, 122, 0.14));
    border-color: rgba(79, 159, 122, 0.18);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 10px 24px rgba(15, 23, 42, 0.08);
}

.menu a::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: linear-gradient(180deg, var(--primary), #9ff0b8);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.menu a:hover::after {
    opacity: 1;
}

.menu a.active::after {
    opacity: 1;
}

.menu-group {
    display: grid;
    gap: 8px;
    padding: 10px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid rgba(148, 163, 184, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.menu-collapsible summary {
    list-style: none;
    cursor: pointer;
}

.menu-collapsible summary::-webkit-details-marker {
    display: none;
}

.menu-group-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 4px;
    color: #64748b;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.menu-group-toggle {
    justify-content: space-between;
}

.menu-group-toggle span:nth-child(2) {
    flex: 1;
}

.menu-caret {
    transition: transform 0.18s ease;
    width: 18px;
    height: 18px;
}

.menu-collapsible[open] .menu-caret {
    transform: rotate(180deg);
}

.menu-group-icon,
.menu-icon,
.inline-icon,
.title-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.menu-group-icon svg,
.menu-icon svg,
.inline-icon svg,
.title-icon svg,
.menu-caret svg {
    width: 18px;
    height: 18px;
    display: block;
}

.menu-icon {
    width: 28px;
    min-width: 28px;
    height: 28px;
    border-radius: 10px;
    background: rgba(79, 159, 122, 0.12);
    color: var(--primary-dark);
    font-size: 14px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.70);
}

.inline-icon {
    margin-right: 6px;
    vertical-align: middle;
}

.title-icon svg {
    width: 22px;
    height: 22px;
}

.inline-icon {
    margin-right: 6px;
}

.title-icon {
    width: 42px;
    height: 42px;
    margin-right: 10px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 1), rgba(79, 159, 122, 0.14));
    color: var(--primary-dark);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.main-content {
    flex: 1;
    padding: 32px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 16px;
    margin-bottom: 24px;
}

.page-eyebrow {
    display: inline-block;
    margin-bottom: 6px;
    color: #64748b;
    text-shadow: none;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.page-header h2 {
    margin: 0;
    font-size: clamp(28px, 4vw, 40px);
    color: #1f2937;
    text-shadow: none;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.header-chip {
    padding: 12px 16px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.74);
    color: #32523e;
    font-weight: 700;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    gap: 6px;
}

.card,
.hero-card {
    background: var(--card);
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: 24px;
    padding: 22px;
    margin-bottom: 22px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(14px);
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.card:hover,
.hero-card:hover {
    transform: translateY(-1px);
    border-color: rgba(79, 159, 122, 0.16);
    box-shadow: 0 22px 48px rgba(15, 23, 42, 0.10);
}

.card.narrow {
    max-width: 700px;
    margin-inline: auto;
}

.hero-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(246, 248, 250, 0.95)),
        radial-gradient(circle at top right, rgba(79, 159, 122, 0.10), transparent 30%);
}

.hero-card h3 {
    margin: 6px 0;
    font-size: 28px;
}

.hero-badge,
.dev-badge {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(79, 159, 122, 0.14);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 800;
}

.hero-meta {
    min-width: 120px;
    padding: 18px;
    border-radius: 20px;
    text-align: center;
    background: linear-gradient(135deg, rgba(79, 159, 122, 0.14), rgba(255, 255, 255, 0.94));
}

.hero-meta strong {
    display: block;
    font-size: 26px;
}

.card-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.card-title-row h3 {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 22px;
}

.metric-card {
    position: relative;
    overflow: hidden;
}

.metric-card::after {
    content: "";
    position: absolute;
    right: -46px;
    bottom: -46px;
    width: 130px;
    height: 130px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(43, 192, 105, 0.14), transparent 68%);
}

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

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

.stats div {
    padding: 16px;
    border-radius: 18px;
    border: 1px solid rgba(97, 137, 111, 0.18);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(243, 251, 246, 0.92));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.74);
}

.stats strong {
    display: block;
    margin-bottom: 4px;
    font-size: 24px;
}

.muted {
    color: var(--muted);
}

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

.grid-form.two-columns {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.grid-form label,
.filters-toolbar label {
    display: grid;
    gap: 6px;
    font-weight: 600;
}

.grid-form input,
.grid-form select,
.grid-form textarea,
.filters-toolbar input,
.filters-toolbar select {
    width: 100%;
    padding: 13px 15px;
    border: 1px solid rgba(97, 137, 111, 0.25);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.94);
    font: inherit;
    transition: 0.2s ease;
}

.grid-form input:focus,
.grid-form select:focus,
.grid-form textarea:focus,
.filters-toolbar input:focus,
.filters-toolbar select:focus {
    outline: none;
    border-color: rgba(43, 192, 105, 0.48);
    box-shadow: 0 0 0 4px rgba(43, 192, 105, 0.12);
}

.checkbox-row {
    display: flex !important;
    align-items: center;
    gap: 10px;
}

.checkbox-row input {
    width: auto;
}

.btn-primary,
.btn-secondary,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border: 0;
    border-radius: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.18s ease;
}

.btn-primary,
button.btn-primary,
button {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    box-shadow: 0 12px 24px rgba(79, 159, 122, 0.20);
}

.btn-primary:hover,
button:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 28px rgba(79, 159, 122, 0.24);
}

.btn-secondary {
    color: var(--text);
    background: rgba(248, 250, 252, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.18);
}

.btn-secondary:hover {
    transform: translateY(-1px);
    background: #ffffff;
}

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

.actions-inline-icons {
    justify-content: center;
    gap: 8px;
}

.icon-action {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.16);
    color: #475569;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.06);
}

.icon-action:hover {
    transform: translateY(-1px);
    border-color: rgba(79, 159, 122, 0.22);
    color: var(--primary-dark);
}

.icon-action svg {
    width: 16px;
    height: 16px;
    display: block;
}

.icon-action-danger:hover,
.link-danger {
    color: var(--danger);
}

.icon-action-warning:hover {
    color: #b7791f;
}

.icon-action-success:hover {
    color: var(--success);
}

.table-wrap {
    overflow-x: auto;
    border-radius: 18px;
    border: 1px solid rgba(97, 137, 111, 0.14);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.76);
}

th,
td {
    padding: 14px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(97, 137, 111, 0.12);
}

th {
    background: rgba(241, 247, 243, 0.96);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 12px;
    color: #4b6959;
}

tbody tr:hover {
    background: rgba(43, 192, 105, 0.05);
}

.badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}

.badge-alive,
.alert-success {
    color: var(--success);
    background: var(--success-bg);
}

.badge-dead,
.alert-error {
    color: var(--danger);
    background: var(--danger-bg);
}

.alert {
    padding: 15px 16px;
    margin-bottom: 18px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.06);
}

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

.animal-photo-wrap {
    margin-bottom: 16px;
}

.animal-photo,
.animal-photo-preview {
    display: block;
    width: 100%;
    max-width: 300px;
    border-radius: 18px;
    border: 1px solid rgba(97, 137, 111, 0.18);
    box-shadow: 0 18px 36px rgba(0, 0, 0, 0.08);
    object-fit: cover;
}

.photo-preview-block,
.logo-preview-box {
    display: grid;
    gap: 10px;
    font-weight: 600;
}

.inline-note {
    padding: 14px 16px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(242, 245, 248, 0.96));
    border: 1px solid rgba(148, 163, 184, 0.14);
    color: var(--muted);
}

.brand-logo-preview {
    width: 140px;
    height: 140px;
    object-fit: contain;
    padding: 12px;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 22px;
    border: 1px solid rgba(97, 137, 111, 0.18);
}

.brand-logo-preview.horizontal {
    width: 240px;
    height: 100px;
}

.permissions-box {
    display: grid;
    gap: 10px;
    padding: 16px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(245, 247, 250, 0.98));
}

.table-photo {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid rgba(97, 137, 111, 0.18);
}

.settings-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 22px;
}

.settings-tabs {
    position: sticky;
    top: 20px;
    display: grid;
    gap: 12px;
}

.settings-tab {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 16px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.06);
}

.settings-tab.active,
.settings-tab:hover {
    background: linear-gradient(135deg, rgba(79, 159, 122, 0.14), rgba(255, 255, 255, 0.94));
}

.settings-tab-link {
    opacity: 0.95;
}

.settings-panel {
    min-height: 320px;
}

.dev-state {
    display: grid;
    gap: 16px;
    padding: 24px;
    border-radius: 18px;
    border: 1px dashed rgba(43, 192, 105, 0.34);
    background: linear-gradient(135deg, rgba(43, 192, 105, 0.08), rgba(255, 255, 255, 0.78));
}

.filter-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(245, 251, 247, 0.92));
}

.filter-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.filters-toolbar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 14px;
    align-items: end;
}

.filters-toolbar label {
    padding: 12px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.58);
    border: 1px solid rgba(97, 137, 111, 0.12);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.section-divider {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-top: 10px;
    border-top: 1px solid rgba(97, 137, 111, 0.16);
}

.install-page .app-shell {
    display: block;
}

.install-page .main-content {
    max-width: 900px;
    margin: 0 auto;
    padding-top: 48px;
}

.modal-page .page-header {
    display: none;
}

.modal-page .main-content {
    position: relative;
    padding: 28px;
}

.modal-page-overlay {
    min-height: calc(100vh - 56px);
    display: grid;
    place-items: center;
}

.modal-page-shell {
    width: min(760px, 100%);
    position: relative;
    padding-top: 18px;
}

.modal-page-shell-confirm {
    width: min(460px, calc(100% - 24px));
}

.modal-page-shell .card,
.modal-page-shell .hero-card {
    margin-bottom: 0;
}

.modal-page-close {
    position: absolute;
    top: -6px;
    right: 10px;
    width: 42px;
    height: 42px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(148, 163, 184, 0.18);
    color: #475569;
    font-size: 28px;
    line-height: 1;
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.10);
    z-index: 2;
}

.modal-page-close:hover {
    color: var(--primary-dark);
    border-color: rgba(79, 159, 122, 0.18);
}

.confirm-card {
    padding: 24px;
}

.confirm-card .card-title-row {
    margin-bottom: 20px;
}

.confirm-actions {
    justify-content: flex-end;
    flex-wrap: nowrap;
}

.confirm-form {
    margin: 0;
}

.inline-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(248, 250, 252, 0.32);
    backdrop-filter: blur(4px);
}

.inline-modal-shell {
    width: min(460px, calc(100% - 24px));
    position: relative;
}

@media (max-width: 960px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .page-header,
    .hero-card,
    .settings-layout {
        grid-template-columns: 1fr;
        display: grid;
    }

    .settings-tabs {
        position: static;
    }
}
