/* ============================================================
   ChickenTracking — Design System & Stylesheet
   Agricultural green palette, clean professional UI
   ============================================================ */

/* ── Custom Properties ─────────────────────────────────── */
:root {
    --clr-primary:       #1a5c38;
    --clr-primary-dark:  #123f27;
    --clr-primary-light: #2d8a56;
    --clr-primary-pale:  #e8f5ee;

    --clr-accent:        #f59e0b;
    --clr-accent-dark:   #d97706;
    --clr-accent-pale:   #fef9ec;

    --clr-success:       #2d6a4f;
    --clr-success-pale:  #e6f4ea;
    --clr-warning:       #d97706;
    --clr-warning-pale:  #fef9ec;
    --clr-danger:        #dc2626;
    --clr-danger-pale:   #fee2e2;
    --clr-info:          #2563eb;
    --clr-info-pale:     #dbeafe;

    --clr-bg:            #f0f4f0;
    --clr-surface:       #ffffff;
    --clr-border:        #d4e6d9;
    --clr-border-light:  #e8f0e9;

    --clr-text:          #1a2e22;
    --clr-text-muted:    #5a7060;
    --clr-text-light:    #8ca897;

    --sidebar-width:     240px;
    --topbar-height:     60px;

    --shadow-sm:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:    0 4px 12px rgba(0,0,0,.10);
    --shadow-lg:    0 10px 30px rgba(0,0,0,.14);

    --radius-sm:    4px;
    --radius-md:    8px;
    --radius-lg:    12px;
    --radius-xl:    16px;

    --font-sans:    system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono:    "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;

    --transition:   150ms ease;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-sans); font-size: 0.9375rem; color: var(--clr-text); background: var(--clr-bg); line-height: 1.5; }
img, svg { display: block; max-width: 100%; }
input, textarea, select, button { font: inherit; }
a { color: var(--clr-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── App Shell (Sidebar + Main) ────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: var(--clr-primary-dark);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    overflow-y: auto;
    transition: transform var(--transition);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.25rem 1rem;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-logo {
    font-size: 1.6rem;
    line-height: 1;
}

.sidebar-name {
    color: #fff;
    font-weight: 700;
    font-size: .95rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    padding: .75rem 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem 1rem;
    color: rgba(255,255,255,.75);
    font-size: .9rem;
    font-weight: 500;
    border-radius: 0;
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
    text-decoration: none;
    margin: 1px 8px;
    border-radius: var(--radius-md);
}

.nav-link:hover {
    background: rgba(255,255,255,.1);
    color: #fff;
    text-decoration: none;
}

.nav-link.active {
    background: var(--clr-primary-light);
    color: #fff;
    font-weight: 600;
}

.nav-link svg {
    flex-shrink: 0;
    opacity: .9;
}

.sidebar-footer {
    padding: .75rem 0;
    border-top: 1px solid rgba(255,255,255,.1);
}

/* ── Main Content ──────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ── Top Bar ───────────────────────────────────────────── */
.top-bar {
    height: var(--topbar-height);
    background: var(--clr-surface);
    border-bottom: 1px solid var(--clr-border);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--clr-text-muted);
    padding: .25rem;
    border-radius: var(--radius-sm);
    display: none;
}

.top-bar-title {
    flex: 1;
    font-weight: 600;
    font-size: 1rem;
    color: var(--clr-text);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.top-bar-alerts {
    position: relative;
    cursor: pointer;
    color: var(--clr-text-muted);
    padding: .25rem;
}

.alert-badge {
    position: absolute;
    top: -4px; right: -4px;
    background: var(--clr-danger);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    width: 16px; height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── User Menu ─────────────────────────────────────────── */
.user-menu {
    display: flex;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
    position: relative;
    padding: .25rem .5rem;
    border-radius: var(--radius-md);
    transition: background var(--transition);
}
.user-menu:hover { background: var(--clr-bg); }

.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--clr-primary);
    color: #fff;
    font-weight: 700;
    font-size: .85rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-name {
    font-size: .875rem;
    font-weight: 500;
    color: var(--clr-text);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    display: none;
    z-index: 200;
}

.user-dropdown.open { display: block; }

.user-dropdown-header {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--clr-border);
}

.user-dropdown-header strong { display: block; font-size: .9rem; }
.user-dropdown-header small  { color: var(--clr-text-muted); font-size: .8rem; }

.user-dropdown a {
    display: block;
    padding: .6rem 1rem;
    font-size: .875rem;
    color: var(--clr-text);
    transition: background var(--transition);
}
.user-dropdown a:hover { background: var(--clr-bg); text-decoration: none; }

/* ── Page Content ──────────────────────────────────────── */
.page-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1400px;
    width: 100%;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--clr-text);
    display: flex;
    align-items: center;
    gap: .5rem;
}

.page-subtitle {
    color: var(--clr-text-muted);
    font-size: .875rem;
    margin-top: .2rem;
}

/* ── Cards ─────────────────────────────────────────────── */
.card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--clr-border-light);
}

.card-header h3 {
    font-size: .95rem;
    font-weight: 600;
    color: var(--clr-text);
}

.card-body {
    padding: 1.25rem;
}

.card-actions {
    display: flex;
    gap: .5rem;
}

/* ── KPI Cards ─────────────────────────────────────────── */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.kpi-card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}
.kpi-card:hover { box-shadow: var(--shadow-md); }

.kpi-icon {
    font-size: 1.8rem;
    line-height: 1;
    flex-shrink: 0;
}

.kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--clr-text);
    line-height: 1.1;
}

.kpi-label {
    font-size: .78rem;
    color: var(--clr-text-muted);
    font-weight: 500;
    margin-top: .1rem;
}

.kpi-income  { border-left: 4px solid var(--clr-success); }
.kpi-expense { border-left: 4px solid var(--clr-danger); }
.kpi-profit  { border-left: 4px solid var(--clr-accent); }

.kpi-profit  .kpi-value { color: var(--clr-primary); }
.kpi-income  .kpi-value { color: var(--clr-success); }
.kpi-expense .kpi-value { color: var(--clr-danger); }

.kpi-loading { opacity: .6; }

/* ── Charts ─────────────────────────────────────────────── */
.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.chart-card { overflow: visible; }

.chart-wide { grid-column: span 1; }

canvas { width: 100% !important; }

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    padding: .75rem 1.25rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .78rem;
    color: var(--clr-text-muted);
}

.legend-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── Species Chart (bar-style) ───────────────────────────── */
.species-chart-container {
    padding: 1rem 1.25rem;
}

.species-bar-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    margin-bottom: .75rem;
}

.species-bar-label {
    width: 120px;
    font-size: .85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.species-bar-track {
    flex: 1;
    height: 18px;
    background: var(--clr-bg);
    border-radius: 9px;
    overflow: hidden;
}

.species-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--clr-primary-light), var(--clr-primary));
    border-radius: 9px;
    transition: width .5s ease;
}

.species-bar-count {
    font-size: .8rem;
    font-weight: 600;
    color: var(--clr-text-muted);
    min-width: 30px;
    text-align: right;
}

/* ── Tables ─────────────────────────────────────────────── */
.table-responsive { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .875rem;
}

.data-table th {
    background: var(--clr-primary-pale);
    color: var(--clr-primary-dark);
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: .75rem 1rem;
    text-align: left;
    white-space: nowrap;
    border-bottom: 2px solid var(--clr-border);
}

.data-table td {
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--clr-border-light);
    vertical-align: middle;
    color: var(--clr-text);
}

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

.data-table tbody tr:hover { background: var(--clr-primary-pale); }

.table-loading {
    text-align: center;
    padding: 2rem !important;
    color: var(--clr-text-muted);
    font-style: italic;
}

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1rem;
    border-top: 1px solid var(--clr-border-light);
    font-size: .85rem;
    color: var(--clr-text-muted);
}

/* ── Badges ─────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .6rem;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.badge-success { background: var(--clr-success-pale);  color: var(--clr-success); }
.badge-warning { background: var(--clr-warning-pale);  color: var(--clr-warning); }
.badge-danger  { background: var(--clr-danger-pale);   color: var(--clr-danger);  }
.badge-info    { background: var(--clr-info-pale);     color: var(--clr-info);    }
.badge-neutral { background: var(--clr-bg);            color: var(--clr-text-muted); }
.badge-primary { background: var(--clr-primary-pale);  color: var(--clr-primary); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .55rem 1.1rem;
    border: 1.5px solid transparent;
    border-radius: var(--radius-md);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition), opacity var(--transition);
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
    min-height: 36px;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary        { background: var(--clr-primary); color: #fff; border-color: var(--clr-primary); }
.btn-primary:hover  { background: var(--clr-primary-light); }

.btn-secondary      { background: var(--clr-surface); color: var(--clr-text); border-color: var(--clr-border); }
.btn-secondary:hover{ background: var(--clr-bg); }

.btn-success        { background: var(--clr-success); color: #fff; border-color: var(--clr-success); }
.btn-success:hover  { opacity: .88; }

.btn-warning        { background: var(--clr-warning); color: #fff; border-color: var(--clr-warning); }

.btn-danger         { background: var(--clr-danger); color: #fff; border-color: var(--clr-danger); }
.btn-danger:hover   { opacity: .88; }

.btn-danger-outline { background: transparent; color: var(--clr-danger); border-color: var(--clr-danger); }
.btn-danger-outline:hover { background: var(--clr-danger-pale); }

.btn-ghost          { background: transparent; color: var(--clr-text-muted); border-color: transparent; }
.btn-ghost:hover    { background: var(--clr-bg); color: var(--clr-text); }

.btn-sm   { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg   { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-block { width: 100%; justify-content: center; }

/* ── Forms ─────────────────────────────────────────────── */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: .875rem;
    font-weight: 500;
    color: var(--clr-text);
    margin-bottom: .35rem;
}

.form-control {
    width: 100%;
    padding: .55rem .8rem;
    border: 1.5px solid var(--clr-border);
    border-radius: var(--radius-md);
    background: var(--clr-surface);
    color: var(--clr-text);
    font-size: .9rem;
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
    min-height: 36px;
}

.form-control:focus {
    outline: none;
    border-color: var(--clr-primary-light);
    box-shadow: 0 0 0 3px rgba(26, 92, 56, .15);
}

.form-control::placeholder { color: var(--clr-text-light); }

textarea.form-control { resize: vertical; min-height: 80px; }

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a7060' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    padding-right: 2.2rem;
}

.form-select-sm { height: 36px; font-size: .85rem; padding: .3rem .7rem; padding-right: 2rem; }
.form-input-sm  { height: 36px; font-size: .85rem; padding: .3rem .7rem; width: auto; }

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.col-span-2 { grid-column: span 2; }

.input-prefix {
    display: flex;
    border: 1.5px solid var(--clr-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--clr-surface);
}

.input-prefix .prefix {
    background: var(--clr-bg);
    border-right: 1.5px solid var(--clr-border);
    padding: .55rem .75rem;
    font-size: .9rem;
    color: var(--clr-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.input-prefix .form-control {
    border: none;
    border-radius: 0;
    box-shadow: none;
}

.input-prefix:focus-within {
    border-color: var(--clr-primary-light);
    box-shadow: 0 0 0 3px rgba(26, 92, 56, .15);
}

.req { color: var(--clr-danger); }

.label-section {
    font-weight: 600;
    color: var(--clr-text);
    padding: .5rem 0 .25rem;
    border-bottom: 1px solid var(--clr-border-light);
    margin-bottom: .25rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .875rem;
    cursor: pointer;
    white-space: nowrap;
}

/* ── Filters Row ─────────────────────────────────────────── */
.filter-card { padding: .75rem 1rem; margin-bottom: 1rem; }
.filter-card .card-header, .filter-card .card-body { display: none; }
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
    align-items: center;
}

.search-box {
    display: flex;
    align-items: center;
    gap: .4rem;
    background: var(--clr-bg);
    border: 1.5px solid var(--clr-border);
    border-radius: var(--radius-md);
    padding: 0 .7rem;
    flex: 1;
    min-width: 180px;
}

.search-box svg { color: var(--clr-text-muted); flex-shrink: 0; }

.search-box .form-control {
    border: none;
    background: transparent;
    box-shadow: none;
    padding: .4rem 0;
}

/* ── Modals ─────────────────────────────────────────────── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 300;
    display: none;
}

.modal-backdrop.open { display: block; }

.modal {
    position: fixed;
    inset: 0;
    z-index: 400;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem;
    overflow-y: auto;
    pointer-events: none;
}

.modal.open {
    display: flex;
    pointer-events: all;
}

.modal-dialog {
    background: var(--clr-surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 640px;
    margin: auto;
    animation: modalIn .2s ease;
}

.modal-sm .modal-dialog { max-width: 400px; }

@keyframes modalIn {
    from { opacity: 0; transform: translateY(-16px) scale(.98); }
    to   { opacity: 1; transform: none; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--clr-border);
}

.modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--clr-text);
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--clr-text-muted);
    padding: .25rem;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.modal-close:hover { background: var(--clr-bg); }

.modal-body {
    padding: 1.5rem;
    max-height: 70vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--clr-border);
    display: flex;
    justify-content: flex-end;
    gap: .75rem;
}

/* ── Toasts ─────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 70px;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    max-width: 360px;
    pointer-events: none;
}

.toast {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-left: 4px solid var(--clr-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: .85rem 1rem;
    font-size: .875rem;
    display: flex;
    align-items: flex-start;
    gap: .6rem;
    animation: toastIn .25s ease;
    pointer-events: all;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: none; }
}

.toast-success { border-left-color: var(--clr-success); }
.toast-error   { border-left-color: var(--clr-danger); }
.toast-warning { border-left-color: var(--clr-warning); }

.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-msg  { flex: 1; line-height: 1.4; }
.toast-close { background: none; border: none; cursor: pointer; color: var(--clr-text-light); padding: 0; margin-left: .25rem; line-height: 1; }

/* ── Alerts ─────────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .85rem 1rem;
    border-radius: var(--radius-md);
    font-size: .875rem;
    margin-bottom: 1rem;
}
.alert-success  { background: var(--clr-success-pale); color: var(--clr-success); border: 1px solid #b7dfca; }
.alert-warning  { background: var(--clr-warning-pale); color: var(--clr-warning); border: 1px solid #f3cc85; }
.alert-danger   { background: var(--clr-danger-pale);  color: var(--clr-danger);  border: 1px solid #fca5a5; }
.alert-info     { background: var(--clr-info-pale);    color: var(--clr-info);    border: 1px solid #93c5fd; }

/* ── Pagination ─────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: .3rem;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px; height: 32px;
    border: 1.5px solid var(--clr-border);
    border-radius: var(--radius-sm);
    background: var(--clr-surface);
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--clr-text-muted);
    transition: background var(--transition), border-color var(--transition);
}

.page-btn:hover { background: var(--clr-primary-pale); border-color: var(--clr-primary); color: var(--clr-primary); }
.page-btn.active { background: var(--clr-primary); border-color: var(--clr-primary); color: #fff; }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Activity Feed ─────────────────────────────────────── */
.activity-feed, .reminders-list, .withdrawal-list {
    list-style: none;
    padding: 0;
}

.activity-feed li {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .75rem 1.25rem;
    border-bottom: 1px solid var(--clr-border-light);
    font-size: .875rem;
}

.activity-feed li:last-child { border-bottom: none; }

.activity-icon {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--clr-primary-pale);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.activity-text { flex: 1; }
.activity-text strong { font-weight: 600; }
.activity-date { font-size: .75rem; color: var(--clr-text-muted); margin-top: .1rem; }
.activity-loading { padding: 1.5rem; text-align: center; color: var(--clr-text-muted); }

/* ── Reminders list ─────────────────────────────────────── */
.reminders-list li {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .75rem 1.25rem;
    border-bottom: 1px solid var(--clr-border-light);
    font-size: .875rem;
}

.reminders-list li:last-child { border-bottom: none; }

.reminder-priority-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.prio-critical { background: var(--clr-danger); }
.prio-high     { background: var(--clr-warning); }
.prio-medium   { background: var(--clr-info); }
.prio-low      { background: var(--clr-text-light); }

/* ── Dashboard Bottom ────────────────────────────────────── */
.dashboard-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

/* ── Top Expenses Grid ───────────────────────────────────── */
.top-expenses-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    padding: 1.25rem;
}

.expense-cat-card {
    background: var(--clr-bg);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
    padding: 1rem;
    text-align: center;
}

.expense-cat-icon { font-size: 1.5rem; margin-bottom: .35rem; }
.expense-cat-name { font-size: .8rem; color: var(--clr-text-muted); font-weight: 500; margin-bottom: .25rem; }
.expense-cat-amount { font-size: 1.1rem; font-weight: 700; color: var(--clr-text); }

/* ── Animal Detail ──────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.detail-card .card-header h3 { font-size: .9rem; }

.detail-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: .4rem 1rem;
    padding: 1rem 1.25rem;
    font-size: .875rem;
}

.detail-list dt {
    font-weight: 500;
    color: var(--clr-text-muted);
    white-space: nowrap;
}

.detail-list dd { color: var(--clr-text); }

.detail-notes {
    padding: .75rem 1.25rem;
    border-top: 1px solid var(--clr-border-light);
    font-size: .875rem;
    color: var(--clr-text-muted);
}

/* ── Tab Bar ─────────────────────────────────────────────── */
.tab-bar {
    display: flex;
    gap: .25rem;
    border-bottom: 2px solid var(--clr-border);
    padding: 0 1rem;
    overflow-x: auto;
    background: var(--clr-surface);
}

.tab-btn {
    background: none;
    border: none;
    padding: .75rem 1rem;
    font-size: .875rem;
    font-weight: 500;
    color: var(--clr-text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color var(--transition), border-color var(--transition);
}

.tab-btn:hover { color: var(--clr-primary); }
.tab-btn.active { color: var(--clr-primary); border-bottom-color: var(--clr-primary); font-weight: 600; }

.tab-content { padding: 1.25rem; }

/* ── Species Tabs ────────────────────────────────────────── */
.species-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    margin-bottom: 1.25rem;
}

.species-tab {
    background: var(--clr-surface);
    border: 1.5px solid var(--clr-border);
    border-radius: 999px;
    padding: .35rem .85rem;
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--clr-text-muted);
    transition: all var(--transition);
}

.species-tab:hover  { border-color: var(--clr-primary); color: var(--clr-primary); background: var(--clr-primary-pale); }
.species-tab.active { background: var(--clr-primary); border-color: var(--clr-primary); color: #fff; }

/* ── Groups Grid ─────────────────────────────────────────── */
.groups-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
}

.group-card {
    background: var(--clr-surface);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}

.group-card:hover { box-shadow: var(--shadow-md); }

.group-card-header {
    background: linear-gradient(135deg, var(--clr-primary-dark), var(--clr-primary-light));
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
}

.group-card-icon { font-size: 2rem; }

.group-card-title {
    color: #fff;
    font-weight: 700;
    font-size: .95rem;
}

.group-card-species {
    color: rgba(255,255,255,.75);
    font-size: .8rem;
    margin-top: .15rem;
}

.group-card-body {
    padding: 1rem 1.25rem;
}

.group-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .35rem 0;
    border-bottom: 1px solid var(--clr-border-light);
    font-size: .85rem;
}

.group-stat-row:last-child { border-bottom: none; }

.group-stat-label { color: var(--clr-text-muted); }
.group-stat-value { font-weight: 600; color: var(--clr-text); }

.group-card-actions {
    padding: .75rem 1.25rem;
    border-top: 1px solid var(--clr-border-light);
    display: flex;
    gap: .5rem;
}

/* ── Financial styles ────────────────────────────────────── */
.financial-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.year-selector {
    display: flex;
    gap: .5rem;
}

.year-selector .form-control { width: auto; }

/* ── Reports ─────────────────────────────────────────────── */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

.report-card {
    text-align: center;
    padding: 2rem 1.5rem;
}

.report-icon { font-size: 2.5rem; margin-bottom: 1rem; }

.report-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: .5rem;
}

.report-card p {
    font-size: .85rem;
    color: var(--clr-text-muted);
    margin-bottom: 1rem;
}

.report-params {
    display: flex;
    justify-content: center;
    gap: .5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.report-content { padding: 1.25rem; overflow-x: auto; }

.report-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--clr-border);
}

.report-stat {
    display: flex;
    flex-direction: column;
    gap: .15rem;
}

.report-stat strong {
    font-size: .75rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--clr-text-muted);
}

.report-stat span {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--clr-text);
}

.report-table { margin: 0; }

/* ── Login Page ─────────────────────────────────────────── */
.login-page {
    background: linear-gradient(135deg, var(--clr-primary-dark) 0%, var(--clr-primary-light) 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--clr-surface);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
}

.login-brand {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo { font-size: 3rem; display: block; margin-bottom: .5rem; }

.login-brand h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--clr-primary-dark);
}

.login-brand p {
    color: var(--clr-text-muted);
    font-size: .875rem;
    margin-top: .25rem;
}

.login-form .form-group { margin-bottom: 1.25rem; }

.login-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: .8rem;
    color: var(--clr-text-light);
}

/* ── Loading Spinners ────────────────────────────────────── */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.loading-spinner::after {
    content: '';
    width: 36px; height: 36px;
    border: 3px solid var(--clr-border);
    border-top-color: var(--clr-primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.loading-spinner-sm::after {
    width: 20px; height: 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Utilities ───────────────────────────────────────────── */
.mt-4  { margin-top: 1.25rem; }
.mb-4  { margin-bottom: 1.25rem; }
.ml-auto { margin-left: auto; }
.gap-2 { gap: .5rem; }
.flex-start { display: flex; align-items: center; }
.text-muted  { color: var(--clr-text-muted); }
.text-strong { font-weight: 700; font-size: 1rem; }
.text-danger  { color: var(--clr-danger); }
.text-success { color: var(--clr-success); }
.small  { font-size: .8rem; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    color: var(--clr-text-muted);
}

.empty-state-icon { font-size: 3rem; margin-bottom: 1rem; opacity: .5; }
.empty-state h3 { font-size: 1.1rem; font-weight: 600; color: var(--clr-text); margin-bottom: .5rem; }
.empty-state p  { font-size: .875rem; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(calc(-1 * var(--sidebar-width)));
    }

    .sidebar.open {
        transform: none;
    }

    .main-content {
        margin-left: 0;
    }

    .sidebar-toggle { display: flex; }

    .charts-row {
        grid-template-columns: 1fr;
    }

    .dashboard-bottom {
        grid-template-columns: 1fr;
    }

    .form-grid-2 {
        grid-template-columns: 1fr;
    }

    .col-span-2 { grid-column: span 1; }

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

    .kpi-row { grid-template-columns: repeat(2, 1fr); }

    .user-name { display: none; }

    .modal { padding: 1rem; }
    .modal-dialog { max-width: calc(100% - 1rem); }
}

@media (max-width: 600px) {
    :root {
        --sidebar-width: 100%;
    }

    .page-content { padding: 1rem; }
    .kpi-row { grid-template-columns: 1fr; }
    
    .modal { padding: 0.5rem; }
    .modal-dialog { 
        max-width: calc(100% - 1rem); 
        border-radius: var(--radius-lg);
        margin: 0.5rem auto;
    }

    .modal-body { max-height: 60vh; }

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

    .search-box { min-width: 0; }

    .top-bar {
        padding: 0 1rem;
        gap: 0.5rem;
        height: var(--topbar-height);
    }

    .top-bar-title {
        font-size: 0.9rem;
    }

    .user-dropdown {
        right: -0.5rem;
        min-width: 160px;
        max-width: calc(100vw - 1rem);
        left: auto;
    }

    .form-grid-2 {
        grid-template-columns: 1fr;
    }

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

    .groups-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }

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

    .financial-header {
        flex-direction: column;
        align-items: stretch;
    }

    .year-selector {
        flex-direction: column;
    }

    .year-selector .form-control { 
        width: 100%; 
    }

    .top-expenses-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .tab-bar {
        padding: 0 0.75rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .page-header {
        flex-direction: column;
    }

    .page-header .btn {
        width: 100%;
        justify-content: center;
    }

    .toast-container {
        left: 0.5rem;
        right: 0.5rem;
        top: 65px;
        max-width: none;
    }

    .toast {
        font-size: 0.8rem;
        padding: 0.75rem 0.85rem;
    }

    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .sidebar-toggle {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .top-bar-alerts {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .data-table {
        font-size: 0.8rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem 0.75rem;
    }
}

/* ── Print ───────────────────────────────────────────────── */
@media print {
    .sidebar, .top-bar, .btn, .filter-card, .tab-bar { display: none !important; }
    .main-content { margin-left: 0; }
    .page-content { padding: 0; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}
