*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #f8f7f4;
    --fg: #2c2c2c;
    --accent: #3a6b35;
    --accent-light: #e8f0e7;
    --border: #d4d0c8;
    --header-bg: #3a6b35;
    --header-fg: #fff;
    --row-hover: #f0ede6;
    --edit-bg: #fffde7;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.5;
    font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header {
    background: var(--header-bg);
    color: var(--header-fg);
    padding: 0.75rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

header h1 { font-size: 1.2rem; font-weight: 600; }
header h1 a { color: inherit; }

nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.inline { display: inline; }
.hidden { display: none; }

.btn {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--accent);
    color: #fff;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s;
}
.btn:hover { opacity: 0.85; text-decoration: none; }
.btn-outline { background: transparent; color: var(--header-fg); border-color: rgba(255,255,255,0.4); }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn.disabled { opacity: 0.4; pointer-events: none; }
.btn.active { background: #fff; color: var(--accent); font-weight: 600; }

#login-form input[type="password"] {
    padding: 0.25rem 0.5rem;
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 4px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 0.85rem;
    width: 140px;
}
#login-form input::placeholder { color: rgba(255,255,255,0.6); }

main {
    max-width: 1600px;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

.controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: #666;
}

.per-page select {
    padding: 0.2rem 0.4rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 0.85rem;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
}

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

thead th {
    background: var(--accent-light);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
}

tbody td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #eee;
    vertical-align: top;
    max-width: 350px;
    overflow-wrap: break-word;
}

tbody tr:hover { background: var(--row-hover); }

td[contenteditable="true"] {
    cursor: text;
    border: 1px solid transparent;
    border-radius: 3px;
    transition: background 0.15s, border-color 0.15s;
}
td[contenteditable="true"]:hover { border-color: var(--border); }
td[contenteditable="true"]:focus {
    background: var(--edit-bg);
    border-color: var(--accent);
    outline: none;
}

.col-cultivar { min-width: 120px; font-weight: 600; }
.col-epithet { min-width: 180px; }
.col-category { min-width: 50px; text-align: center; }
.col-color { min-width: 140px; }
.col-desc { min-width: 250px; font-size: 0.85rem; }
.col-notes { min-width: 200px; font-size: 0.85rem; }
.col-img { min-width: 150px; font-size: 0.75rem; word-break: break-all; }
.col-img .url-text { color: #888; }
.img-url-input {
    width: 100%;
    margin-top: 0.3rem;
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    box-sizing: border-box;
}

.pagination {
    margin-top: 1rem;
    display: flex;
    gap: 0.3rem;
    justify-content: center;
    flex-wrap: wrap;
}

.save-indicator {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    background: var(--accent);
    color: #fff;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.save-indicator.show { opacity: 1; }
.save-indicator.error { background: #c0392b; }

@media (max-width: 768px) {
    header h1 { font-size: 1rem; }
    main { padding: 0 0.5rem; margin-top: 1rem; }
    tbody td { font-size: 0.8rem; padding: 0.4rem; }
}
