/* ============================================================================
   AgriStack — Global stylesheet
   Design system per specification §66. Material-inspired: generous spacing,
   soft layered elevation, tonal states, outlined fields, pill navigation.
   Brand tokens (§66) are preserved; only spacing/elevation/derived tokens are
   refined. Every component class the app already uses is kept.
   ========================================================================== */

:root {
    /* ---- Brand tokens (§66 — do not change) ---- */
    --primary:    #377dff;
    --text:       #172033;
    --muted:      #6b7280;
    --border:     #e5e7eb;
    --surface:    #ffffff;
    --background: #f5f6f8;
    --radius:     14px;

    /* ---- Primary ramp / tones ---- */
    --primary-700: #2258c8;
    --primary-600: #2f6ae0;
    --primary-500: #377dff;
    --primary-100: #dce8ff;
    --primary-050: #eef4ff;
    --on-primary:  #ffffff;

    /* ---- Semantic ---- */
    --success: #16a34a;  --success-bg: #e7f6ee;
    --danger:  #dc2626;  --danger-bg:  #fdecec;
    --warning: #d97706;  --warning-bg: #fdf1e3;
    --info:    #0ea5e9;  --info-bg:    #e6f6fe;

    /* ---- Neutral surface tones ---- */
    --surface-1: #ffffff;
    --surface-2: #fafbfc;
    --surface-3: #f2f4f7;
    --hover:     rgba(23, 32, 51, .045);   /* state-layer overlay */
    --line:      #eef1f5;                    /* hairline inside cards */

    /* ---- Radii ---- */
    --radius-xs: 8px;
    --radius-sm: 10px;
    --radius-lg: 18px;
    --radius-pill: 999px;

    /* ---- Material elevation (layered, soft) ---- */
    --elev-0: none;
    --elev-1: 0 1px 2px rgba(23,32,51,.06), 0 1px 3px rgba(23,32,51,.05);
    --elev-2: 0 2px 6px rgba(23,32,51,.06), 0 4px 12px rgba(23,32,51,.06);
    --elev-3: 0 8px 24px rgba(23,32,51,.10), 0 2px 8px rgba(23,32,51,.06);
    /* legacy aliases kept for any inline references */
    --shadow-xs: var(--elev-1);
    --shadow-sm: var(--elev-1);
    --shadow-md: var(--elev-3);

    --focus-ring: 0 0 0 3px rgba(55, 125, 255, .20);

    --sidebar-w: 272px;
    --topbar-h:  66px;

    --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--background);
    color: var(--text);
    font-size: 14px;
    line-height: 1.55;
    letter-spacing: .002em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--primary-700); }

h1, h2, h3, h4, h5 { letter-spacing: -.012em; }

::selection { background: var(--primary-100); }

/* Refined scrollbars */
* { scrollbar-width: thin; scrollbar-color: #d3d9e3 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d8dee8; border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #c4ccd9; background-clip: content-box; }

/* =============================================================== Shell === */

.app-shell { display: flex; min-height: 100vh; align-items: stretch; }

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============================================================= Sidebar === */

.app-sidebar {
    width: var(--sidebar-w);
    --bs-offcanvas-width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 0;
}

@media (min-width: 992px) {
    .app-sidebar {
        flex: 0 0 var(--sidebar-w);
        position: sticky;
        top: 0;
        height: 100vh;
    }
}

.sidebar-brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    flex: 0 0 auto;
}
.brand-link { display: flex; align-items: center; gap: 11px; color: var(--text); font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.brand-link:hover { color: var(--text); }
.brand-mark {
    width: 36px; height: 36px; border-radius: 10px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    color: #fff; font-size: 16px; box-shadow: var(--elev-1);
}

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px 14px 18px;
}

.nav-group-label {
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: #9aa2b1;
    padding: 18px 14px 8px;
}
.sidebar-nav > .nav-group-label:first-child { padding-top: 6px; }

/* MD3-style pill navigation items */
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 10px 14px;
    margin: 2px 0;
    border-radius: var(--radius-pill);
    color: #454e5e;
    font-weight: 500;
    font-size: 13.5px;
    position: relative;
    transition: background-color .16s ease, color .16s ease;
}
.sidebar-nav .nav-link i {
    width: 20px; text-align: center; font-size: 15px;
    color: #9aa2b1; transition: color .16s ease;
}
.sidebar-nav .nav-link:hover { background: var(--surface-3); color: var(--text); }
.sidebar-nav .nav-link:hover i { color: #5b6472; }
.sidebar-nav .nav-link.active { background: var(--primary-050); color: var(--primary-700); font-weight: 600; }
.sidebar-nav .nav-link.active i { color: var(--primary); }
.sidebar-nav .nav-link:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.sidebar-footer { padding: 14px 20px 20px; border-top: 1px solid var(--border); flex: 0 0 auto; }
.badge-module {
    display: inline-block; font-size: 11px; font-weight: 600; color: var(--muted);
    background: var(--surface-3); border: 1px solid var(--border);
    padding: 5px 12px; border-radius: var(--radius-pill);
}

/* ============================================================== Topbar === */

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 22px;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: saturate(180%) blur(10px);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--border);
}

.btn-icon {
    width: 42px; height: 42px; padding: 0;
    display: inline-grid; place-items: center;
    border: 0; border-radius: var(--radius-pill);
    color: #566072; background: transparent;
    transition: background-color .15s ease, color .15s ease;
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); }
.btn-icon:active { background: var(--primary-050); }

/* Topbar search — filled, pill, elevates on focus */
.topbar-search {
    position: relative;
    flex: 1 1 auto;
    max-width: 540px;
}
.topbar-search i {
    position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
    color: #9aa2b1; font-size: 14px; pointer-events: none; transition: color .15s ease;
}
.topbar-search .form-control {
    height: 44px;
    padding-left: 42px;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    background: var(--surface-3);
    font-size: 13.5px;
    transition: background-color .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.topbar-search .form-control::placeholder { color: #98a1b0; }
.topbar-search .form-control:focus {
    background: #fff;
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
}
.topbar-search .form-control:focus + i,
.topbar-search:focus-within i { color: var(--primary); }

.topbar-actions .notif-badge {
    position: absolute; top: 3px; right: 3px;
    min-width: 18px; height: 18px; padding: 0 5px;
    background: var(--danger); color: #fff;
    font-size: 10px; font-weight: 700; line-height: 18px;
    border-radius: var(--radius-pill); text-align: center;
    box-shadow: 0 0 0 2px #fff;
}

.user-menu-btn {
    display: flex; align-items: center; gap: 9px;
    padding: 5px 10px 5px 6px; border-radius: var(--radius-pill);
    border: 0; background: transparent; color: var(--text);
    transition: background-color .15s ease;
}
.user-menu-btn:hover { background: var(--surface-3); }
.user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    display: inline-grid; place-items: center; overflow: hidden;
    background: var(--primary-050); color: var(--primary); font-size: 13px; font-weight: 600;
}
.user-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-name { font-size: 13.5px; font-weight: 600; }

/* Notification dropdown */
.notif-menu { width: 356px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--elev-3); overflow: hidden; }
.notif-menu-head { padding: 14px 18px; font-weight: 600; border-bottom: 1px solid var(--line); }
.notif-menu-body { max-height: 360px; overflow-y: auto; }
.notif-item { display: block; padding: 12px 18px; border-bottom: 1px solid var(--line); color: var(--text); transition: background-color .12s ease; }
.notif-item:hover { background: var(--surface-2); color: var(--text); }
.notif-item.unread { background: var(--primary-050); }
.notif-title { display: block; font-weight: 600; font-size: 13px; }
.notif-text { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.notif-time { display: block; font-size: 11.5px; color: #9aa2b1; margin-top: 3px; }
.notif-empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.notif-empty i { font-size: 24px; color: #c8ced9; }
.notif-empty p { margin: 8px 0 0; font-size: 13px; }
.notif-menu-foot { padding: 12px 16px; text-align: center; border-top: 1px solid var(--line); }
.notif-menu-foot a { font-size: 13px; font-weight: 600; }

/* ============================================================= Content === */

.app-content { flex: 1 1 auto; padding: 28px; }
.content-container { max-width: 1360px; margin: 0 auto; }

.app-breadcrumb { margin-bottom: 10px; }
.app-breadcrumb .breadcrumb { font-size: 12.5px; margin: 0; }
.app-breadcrumb .breadcrumb-item + .breadcrumb-item::before { content: "›"; color: #b8c0cd; padding: 0 2px; }
.app-breadcrumb .breadcrumb-item.active { color: var(--muted); }

.page-header { margin-bottom: 24px; }
.page-title { font-size: 24px; font-weight: 700; margin: 0; letter-spacing: -.02em; }
.page-description { color: var(--muted); margin: 5px 0 0; font-size: 14px; }

/* Demo banner */
.demo-banner {
    display: flex; gap: 12px; align-items: flex-start;
    background: var(--primary-050); border: 1px solid var(--primary-100);
    border-radius: var(--radius); padding: 15px 18px; margin-bottom: 22px;
    font-size: 13.5px; color: #3a4557;
}
.demo-banner i { color: var(--primary); margin-top: 2px; }
.demo-banner strong { color: var(--text); }

/* ============================================================== Panels === */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--elev-1);
    margin-bottom: 22px;
    overflow: hidden;
    transition: box-shadow .18s ease;
}
.panel.h-100 { margin-bottom: 0; }
.panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 16px 22px; border-bottom: 1px solid var(--line);
}
.panel-title { font-size: 15.5px; font-weight: 600; margin: 0; letter-spacing: -.01em; }
.panel-body { padding: 22px; }

.badge-demo {
    font-size: 11px; font-weight: 600; color: var(--warning);
    background: var(--warning-bg); padding: 4px 10px; border-radius: var(--radius-pill);
}

/* ================================================================ KPIs === */

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 22px;
}
.kpi-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--elev-1); padding: 18px 20px; display: flex; gap: 16px; align-items: center;
    color: var(--text);
    transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}
a.kpi-card:hover { box-shadow: var(--elev-2); transform: translateY(-2px); border-color: #d7deea; color: var(--text); }
.kpi-icon {
    width: 48px; height: 48px; border-radius: 14px; flex: 0 0 auto;
    display: grid; place-items: center; font-size: 18px;
    background: var(--primary-050); color: var(--primary);
}
.kpi-label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 700; line-height: 1.1; letter-spacing: -.02em; }
.kpi-hint { font-size: 11px; color: #9aa2b1; margin-top: 2px; }

/* ====================================================== Quick actions === */

.quick-actions { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 14px; }
.quick-action {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    padding: 20px 12px; border: 1px solid var(--border); border-radius: var(--radius);
    color: #414b5a; background: #fff; text-align: center; font-size: 12.5px; font-weight: 600;
    transition: border-color .16s ease, box-shadow .16s ease, color .16s ease, transform .16s ease;
}
.quick-action i { font-size: 20px; color: var(--primary); }
.quick-action:hover { border-color: transparent; box-shadow: var(--elev-2); color: var(--text); transform: translateY(-2px); }

/* ============================================== Forms, fields & search === */

.form-label { font-size: 13px; font-weight: 600; color: #3a4557; margin-bottom: 6px; }
.form-text { font-size: 12px; color: var(--muted); }

.form-control,
.form-select {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 13px;
    font-size: 13.5px;
    color: var(--text);
    background-color: #fff;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.form-control::placeholder { color: #9aa1af; }
.form-control:hover:not(:focus),
.form-select:hover:not(:focus) { border-color: #cfd6e2; }
.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: var(--focus-ring);
    background-color: #fff;
}
.form-control-sm, .form-select-sm { padding: 7px 11px; font-size: 13px; border-radius: var(--radius-sm); }
.form-control-lg { padding: 12px 16px; font-size: 15px; }
textarea.form-control { line-height: 1.5; }
.form-check-input:focus { border-color: var(--primary); box-shadow: var(--focus-ring); }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }

/* Input groups (search rows across listings) — unified, rounded */
.input-group { border-radius: var(--radius-sm); }
.input-group > .form-control,
.input-group > .form-select { box-shadow: none; }
.input-group .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.input-group > .form-control:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group .input-group-text {
    background: var(--surface-3); border-color: var(--border); color: var(--muted); font-size: 13px;
}
.input-group:focus-within { box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }
.input-group:focus-within > .form-control { box-shadow: none; border-color: var(--primary); }
.input-group:focus-within .btn-outline-secondary { border-color: var(--primary); color: var(--primary); }

/* A search input using type=search gets a subtle filled look */
.form-control[type="search"] { background-color: var(--surface-2); }
.form-control[type="search"]:focus { background-color: #fff; }

.invalid-feedback { font-size: 12px; }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(220,38,38,.16); }

/* =============================================================== Tables === */

.table { margin-bottom: 0; }
table.dataTable { border-collapse: collapse !important; }
.table > :not(caption) > * > * { padding: 13px 14px; }
.table thead th {
    font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
    color: #8a93a3; font-weight: 700; border-bottom: 1px solid var(--border);
    background: transparent; white-space: nowrap;
}
.table tbody td { border-bottom: 1px solid var(--line); vertical-align: middle; color: #2b3444; }
.table tbody tr:last-child td { border-bottom: 0; }
.table-hover tbody tr { transition: background-color .12s ease; }
.table-hover tbody tr:hover td { background: var(--surface-2); }
.table code { background: var(--surface-3); padding: 2px 7px; border-radius: 6px; font-size: 12px; color: #3a4557; }

.status-pill {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11.5px; font-weight: 600;
    padding: 4px 11px; border-radius: var(--radius-pill); line-height: 1.3;
}
.status-ok   { color: var(--success); background: var(--success-bg); }
.status-warn { color: var(--warning); background: var(--warning-bg); }
.status-off  { color: var(--danger);  background: var(--danger-bg); }

/* DataTables controls */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 8px 12px; font-size: 13px; background: #fff;
}
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
    outline: none; border-color: var(--primary); box-shadow: var(--focus-ring);
}
.dataTables_wrapper .dataTables_info { color: var(--muted); font-size: 12.5px; padding-top: 14px; }
.dataTables_wrapper .dataTables_paginate { padding-top: 10px; }
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border-radius: var(--radius-sm) !important; font-size: 13px; border: 0 !important; margin: 0 2px; color: var(--muted) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--surface-3) !important; color: var(--text) !important; border: 0 !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--primary) !important; color: #fff !important; box-shadow: var(--elev-1);
}

/* Bootstrap pagination (partials/pagination.php) */
.pagination { --bs-pagination-color: var(--muted); --bs-pagination-hover-color: var(--text);
    --bs-pagination-hover-bg: var(--surface-3); --bs-pagination-border-color: var(--border);
    --bs-pagination-active-bg: var(--primary); --bs-pagination-active-border-color: var(--primary);
    --bs-pagination-border-radius: var(--radius-sm); --bs-pagination-focus-box-shadow: var(--focus-ring); gap: 4px; }
.page-link { border-radius: var(--radius-sm); }

/* ========================================================= Activity feed === */

.activity-feed { list-style: none; margin: 0; padding: 0; }
.activity-feed li { display: flex; gap: 13px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.activity-feed li:last-child { border-bottom: 0; }
.activity-feed .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); margin-top: 6px; flex: 0 0 auto; box-shadow: 0 0 0 3px var(--primary-050); }
.act-text { display: block; font-size: 13px; }
.act-time { display: block; font-size: 11.5px; color: #9aa2b1; margin-top: 3px; }

/* ========================================================== Empty states === */

.empty-state { text-align: center; padding: 44px 16px; color: var(--muted); }
.empty-state i { font-size: 34px; color: #ccd3df; }
.empty-state p { margin: 14px 0 4px; font-weight: 600; color: var(--text); font-size: 14.5px; }
.empty-state span { font-size: 12.5px; color: var(--muted); display: block; max-width: 380px; margin: 0 auto; }

/* =================================================== Notifications (page) === */

.notif-list { list-style: none; margin: 0; padding: 0; }
.notif-list li { border-bottom: 1px solid var(--line); }
.notif-list li:last-child { border-bottom: 0; }
.notif-list li a { display: flex; align-items: flex-start; gap: 14px; padding: 15px 10px; color: var(--text); transition: background-color .12s ease; }
.notif-list li a:hover { background: var(--surface-2); }
.notif-list li.unread a { background: var(--primary-050); }
.notif-list-icon { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-050); color: var(--primary); flex: 0 0 auto; }
.notif-list-main { flex: 1 1 auto; min-width: 0; }
.notif-list-title { display: block; font-weight: 600; font-size: 13.5px; }
.notif-list-text { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.notif-list-time { font-size: 11.5px; color: #9aa2b1; white-space: nowrap; }

/* =============================================================== Toasts === */

.app-toast {
    min-width: 300px; max-width: 380px;
    border: 1px solid var(--border); border-left-width: 4px;
    border-radius: var(--radius-sm); background: #fff; box-shadow: var(--elev-3);
}
.app-toast .toast-line { display: flex; align-items: flex-start; gap: 11px; padding: 13px 16px; }
.app-toast .toast-ico { font-size: 16px; margin-top: 1px; }
.app-toast .toast-msg { font-size: 13.5px; color: var(--text); flex: 1 1 auto; }
.app-toast.t-success { border-left-color: var(--success); } .app-toast.t-success .toast-ico { color: var(--success); }
.app-toast.t-error   { border-left-color: var(--danger); }  .app-toast.t-error .toast-ico { color: var(--danger); }
.app-toast.t-info    { border-left-color: var(--info); }    .app-toast.t-info .toast-ico { color: var(--info); }
.app-toast.t-warning { border-left-color: var(--warning); } .app-toast.t-warning .toast-ico { color: var(--warning); }

/* ============================================================== Buttons === */

.btn {
    font-size: 13.5px; font-weight: 600; border-radius: var(--radius-sm);
    padding: 9px 18px; letter-spacing: .005em;
    transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease, color .15s ease, transform .05s ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { box-shadow: var(--focus-ring); }
.btn-sm { padding: 6px 13px; font-size: 12.5px; border-radius: var(--radius-xs); }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: var(--elev-1); }
.btn-primary:hover { background: var(--primary-600); border-color: var(--primary-600); color: #fff; box-shadow: var(--elev-2); }
.btn-primary:active, .btn-primary:focus { background: var(--primary-700); border-color: var(--primary-700); color: #fff; }

.btn-outline-secondary { color: #4b5563; border-color: var(--border); background: #fff; }
.btn-outline-secondary:hover { background: var(--surface-3); color: var(--text); border-color: #d3dae5; }
.btn-outline-primary { color: var(--primary); border-color: var(--primary-100); background: var(--primary-050); }
.btn-outline-primary:hover { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-success:hover { background: #138a3f; border-color: #138a3f; }
.btn-outline-danger { color: var(--danger); border-color: #f3c9c9; }
.btn-outline-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-outline-warning { color: var(--warning); border-color: #f3ddba; }
.btn-outline-warning:hover { background: var(--warning); border-color: var(--warning); color: #fff; }

/* Dropdown menus */
.dropdown-menu { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--elev-3); padding: 6px; font-size: 13.5px; }
.dropdown-item { border-radius: var(--radius-xs); padding: 8px 12px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-3); color: var(--text); }
.dropdown-item.active, .dropdown-item:active { background: var(--primary); color: #fff; }
.dropdown-divider { border-color: var(--line); }

/* =============================================================== Cards === */

.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--elev-1); }

/* Generic Bootstrap alerts, softened */
.alert { border-radius: var(--radius); border: 1px solid transparent; font-size: 13.5px; padding: 13px 16px; }
.alert-success { background: var(--success-bg); border-color: #cdecd9; color: #14683a; }
.alert-danger  { background: var(--danger-bg);  border-color: #f4cccc; color: #a12020; }
.alert-warning { background: var(--warning-bg); border-color: #f2dcbb; color: #8a5410; }
.alert-info    { background: var(--info-bg);    border-color: #c8ebfb; color: #0b6a92; }

/* ============================================================== Modals === */

.modal-content { border: 0; border-radius: var(--radius-lg); box-shadow: var(--elev-3); }
.modal-header, .modal-footer { border-color: var(--line); padding: 16px 20px; }
.modal-body { padding: 20px; }
.modal-title { font-size: 16.5px; font-weight: 700; }

/* ============================================================ Utilities === */

.text-muted { color: var(--muted) !important; }
hr { border-color: var(--line); opacity: 1; }
dl.row dt { font-weight: 600; color: #3a4557; }
dl.row dd { color: #2b3444; }
.badge.text-bg-light { background: var(--surface-3) !important; color: #4b5563 !important; border-color: var(--border) !important; font-weight: 600; }

/* ========================================================== Responsive === */

@media (max-width: 1199px) {
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .quick-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 767px) {
    .app-content { padding: 18px; }
    .page-title { font-size: 21px; }
    .panel-body { padding: 18px; }
}
@media (max-width: 575px) {
    .app-content { padding: 14px; }
    .kpi-grid { grid-template-columns: 1fr; }
    .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .topbar-search { max-width: none; }
    .user-name { display: none; }
}

/* Accessibility: respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ============================== Animal icon system (shared everywhere) === */
.animal-icon { display: inline-block; vertical-align: middle; color: #7a8794; }
.animal-icon.gender-female  { color: #d6336c; }
.animal-icon.gender-male    { color: #1c7ed6; }
.animal-icon.gender-unknown { color: #7a8794; }
.animal-avatar { display: inline-flex; align-items: center; justify-content: center; background: var(--surface-3); border-radius: 12px; overflow: hidden; flex: 0 0 auto; }
.animal-avatar img { width: 100%; height: 100%; object-fit: cover; }
