:root {
    --green: #123d32;
    --green-2: #1e6754;
    --cream: #f7f3e8;
    --paper: #fffdf8;
    --line: #e5e1d6;
    --muted: #6f7c77;
    --gold: #d7a449;
    --red: #b84a42;
    --blue: #315c75;
    --shadow: 0 18px 45px rgba(18, 61, 50, .09);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--cream);
    color: #17322d;
    font-family: "Leelawadee UI", Tahoma, sans-serif;
}

a { color: var(--green-2); text-decoration: none; }

.app {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: var(--green);
    color: white;
    padding: 26px 18px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
}

.brand-logo {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    color: var(--gold);
    border: 1px solid rgba(255,255,255,.35);
    font: 700 26px Georgia, serif;
}

.brand strong { display: block; font-size: 22px; }
.brand small { color: #b8cec7; }

.sidebar nav {
    display: grid;
    gap: 8px;
}

.sidebar a {
    color: #d4e2de;
    padding: 13px 15px;
    border-radius: 12px;
}

.sidebar a:hover,
.sidebar a.active {
    color: white;
    background: rgba(255,255,255,.11);
}

main {
    padding: 0 34px 44px;
    min-width: 0;
}

.topbar {
    min-height: 105px;
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar p { margin: 0 0 4px; color: var(--muted); font-size: 13px; }
.topbar h1 { margin: 0; font-size: 30px; font-family: Georgia, "Leelawadee UI", serif; }

.menu-btn {
    display: none;
    border: 0;
    background: transparent;
    font-size: 28px;
    color: var(--green);
}

.flash {
    margin-bottom: 18px;
    padding: 13px 16px;
    border-radius: 14px;
    background: #e4f2ec;
    color: #18533f;
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    min-height: 230px;
    color: white;
    background: linear-gradient(120deg, #17483d, #0f2b25);
    border-radius: 26px;
    padding: 36px;
    box-shadow: var(--shadow);
}

.hero span { color: var(--gold); letter-spacing: 1.4px; text-transform: uppercase; font-size: 12px; }
.hero h2 { margin: 10px 0; font: 700 34px/1.22 Georgia, "Leelawadee UI", serif; }
.hero p { margin: 0; color: #c6d8d2; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: white;
    color: var(--green);
    font: 700 14px inherit;
    cursor: pointer;
}

.btn.primary {
    background: var(--green);
    border-color: var(--green);
    color: white;
}

.btn.light {
    background: white;
    color: var(--green);
    border-color: white;
}

.btn.blue {
    background: var(--blue);
    border-color: var(--blue);
    color: white;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin: 18px 0;
}

.stat-card,
.card {
    background: var(--paper);
    border: 1px solid rgba(18,61,50,.08);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(18,61,50,.05);
}

.stat-card {
    padding: 22px;
}

.stat-card small {
    display: block;
    color: var(--muted);
    margin-bottom: 8px;
}

.stat-card strong {
    font: 700 28px Georgia, serif;
}

.stat-card.warning strong,
.stat-card.expense strong { color: var(--red); }
.stat-card.income strong { color: #1d7d5c; }

.two-col {
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    gap: 18px;
    margin-bottom: 18px;
}

.card {
    padding: 22px;
}

.card-head,
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.card h3,
.card-head h3 {
    margin: 0;
    font-size: 20px;
}

.list-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.list-row:last-child { border-bottom: 0; }
.list-row small { display: block; color: var(--muted); margin-top: 3px; }

.badge {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    padding: 5px 9px;
    border-radius: 999px;
    background: #e5eee9;
    color: var(--green);
    font-size: 12px;
}

.badge.red {
    background: #f4ddd9;
    color: var(--red);
}

.money-box {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.money-box:last-child { border-bottom: 0; }
.money-box span { color: var(--muted); }
.money-box.income strong { color: #1d7d5c; }
.money-box.expense strong { color: var(--red); }

.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }

table {
    width: 100%;
    min-width: 760px;
    border-collapse: collapse;
}

th,
td {
    padding: 15px 16px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    color: var(--muted);
    background: #fbf8ef;
    font-size: 12px;
}

.actions {
    white-space: nowrap;
    display: flex;
    gap: 10px;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
}

.pagination div {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    min-height: 36px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: white;
    color: var(--green);
    font-weight: 700;
}

.page-link.active {
    background: var(--green);
    border-color: var(--green);
    color: white;
}

.danger { color: var(--red); }
.empty { text-align: center; color: var(--muted); padding: 30px; }

.search-form {
    display: flex;
    gap: 8px;
    width: min(520px, 100%);
}

.breeding-command {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.breeding-search {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 180px auto auto;
    gap: 8px;
    width: min(820px, 100%);
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 13px;
    font: inherit;
    color: #17322d;
    background: white;
}

textarea { min-height: 92px; resize: vertical; }

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-grid label {
    display: grid;
    gap: 7px;
    font-weight: 700;
    font-size: 13px;
}

.full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }

.grid-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.breeding-grid {
    align-items: start;
}

.compact-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.compact-stats article {
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--paper);
    border: 1px solid rgba(18,61,50,.08);
}

.compact-stats span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}

.compact-stats strong {
    font: 700 24px Georgia, serif;
}

.pair-card p { margin: 8px 0; }

.compact-pair-card {
    padding: 18px;
}

.compact-pair-card .card-head {
    margin-bottom: 12px;
}

.pair-birds {
    min-height: 58px;
}

.form-note {
    display: grid;
    gap: 4px;
    padding: 14px 16px;
    margin-bottom: 18px;
    border-radius: 14px;
    background: #f3f1e9;
}

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

.clutch-list {
    display: grid;
    gap: 10px;
    margin: 14px 0 18px;
}

.clutch-summary {
    display: grid;
    gap: 5px;
    padding: 12px 14px;
    margin: 14px 0 18px;
    border-radius: 14px;
    background: #f3f1e9;
    color: var(--muted);
    font-size: 13px;
}

.clutch-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fffaf0;
}

.clutch-row small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}

.clutch-numbers {
    display: flex;
    gap: 7px;
    align-items: flex-start;
}

.clutch-numbers span {
    padding: 5px 8px;
    border-radius: 999px;
    background: #e5eee9;
    color: var(--green);
    font-size: 12px;
}

.clutch-row .actions {
    grid-column: 1 / -1;
    justify-content: flex-end;
}

.pair-actions {
    align-items: center;
    flex-wrap: wrap;
}

.mini-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 15px 0;
}

.mini-stats span {
    padding: 10px;
    border-radius: 12px;
    background: #f3f1e9;
    color: var(--muted);
    text-align: center;
    font-size: 12px;
}

.mini-stats b { display: block; color: #17322d; margin-top: 4px; }

.error-card {
    max-width: 720px;
    border-left: 5px solid var(--red);
}

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

.setup-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
}

.setup-card {
    width: min(540px, 100%);
    background: var(--paper);
    border-radius: 24px;
    padding: 30px;
    box-shadow: var(--shadow);
}

.setup-info {
    padding: 14px;
    background: #f3f1e9;
    border-radius: 14px;
    margin: 16px 0;
}

@media (max-width: 1050px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .two-col { grid-template-columns: 1fr; }
    .grid-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .breeding-search { grid-template-columns: 1fr 170px; }
    .compact-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
    .app { display: block; }
    .sidebar {
        position: fixed;
        left: -270px;
        width: 250px;
        z-index: 20;
        transition: .2s;
        box-shadow: 20px 0 50px rgba(0,0,0,.18);
    }
    .sidebar.open { left: 0; }
    main { padding: 0 16px 34px; }
    .topbar { min-height: 86px; }
    .topbar h1 { font-size: 24px; }
    .menu-btn { display: block; }
    .hero { display: block; padding: 26px; }
    .hero h2 { font-size: 28px; }
    .hero .btn { margin-top: 20px; }
    .toolbar,
    .search-form { flex-direction: column; align-items: stretch; }
    .pagination { flex-direction: column; align-items: stretch; }
    .pagination div { justify-content: flex-start; }
    .breeding-command { flex-direction: column; align-items: stretch; }
    .breeding-search { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .full { grid-column: auto; }
    .grid-cards { grid-template-columns: 1fr; }
}

@media (max-width: 460px) {
    .stats-grid { grid-template-columns: 1fr; }
    .compact-stats { grid-template-columns: 1fr 1fr; }
    .card { padding: 18px; }
}
