:root {
    --bg: #f4f7f6;
    --card: #ffffff;
    --text: #17211c;
    --muted: #65736b;
    --border: #dce5e0;
    --primary: #16835f;
    --primary-dark: #0e684a;
    --danger: #b73737;
    --shadow: 0 12px 30px rgba(20, 52, 39, .08);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
label { display: block; font-size: .9rem; font-weight: 650; margin-bottom: .45rem; }
input[type="text"], input[type="password"], textarea, select { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: .75rem .85rem; background: #fff; color: var(--text); outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,131,95,.12); }
textarea { resize: vertical; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow); }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.2rem max(1.2rem, calc((100vw - 1440px)/2)); background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topbar h1 { margin: 0; font-size: 1.35rem; }
.topbar p { margin: .25rem 0 0; color: var(--muted); }
.top-actions, .export-actions, .template-controls { display: flex; gap: .55rem; align-items: center; flex-wrap: wrap; }
.app-shell { width: min(1440px, calc(100% - 2rem)); margin: 1.25rem auto 3rem; display: grid; gap: 1rem; }
.controls-card, .input-card, .table-card { padding: 1.15rem; }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
h2 { margin: 0; font-size: 1.05rem; }
.muted { color: var(--muted); margin: .3rem 0 0; font-size: .9rem; }
.btn { border: 0; border-radius: 10px; padding: .68rem .9rem; cursor: pointer; font-weight: 700; text-decoration: none; display: inline-flex; justify-content: center; align-items: center; white-space: nowrap; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.secondary { background: #e9f4ef; color: #126849; }
.btn.ghost { color: var(--text); background: #f3f5f4; }
.btn.danger-outline { color: var(--danger); background: #fff; border: 1px solid #e9bdbd; }
.column-builder { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .6rem; }
.column-item { border: 1px solid var(--border); border-radius: 10px; padding: .6rem .7rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; background: #fbfcfb; }
.column-item label { margin: 0; display: flex; gap: .55rem; align-items: center; cursor: pointer; }
.order-buttons { display: flex; gap: .25rem; }
.icon-btn { border: 1px solid var(--border); border-radius: 7px; background: #fff; width: 30px; height: 30px; cursor: pointer; }
.input-grid { display: grid; grid-template-columns: minmax(280px, .8fr) minmax(360px, 1.2fr); gap: 1rem; }
.inline-input { display: flex; gap: .55rem; }
.progress-wrap { display: flex; align-items: center; gap: .75rem; margin-top: 1rem; }
.progress { height: 10px; background: #e8eeeb; border-radius: 99px; overflow: hidden; flex: 1; }
.progress > div { height: 100%; width: 0; background: var(--primary); transition: width .2s; }
.table-wrap { overflow: auto; max-height: 62vh; border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 900px; }
th, td { padding: .62rem; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); text-align: left; vertical-align: top; font-size: .88rem; }
th { position: sticky; top: 0; background: #eff6f2; z-index: 5; white-space: nowrap; }
th:last-child, td:last-child { border-right: 0; }
td input, td textarea { min-width: 140px; border: 1px solid transparent; background: transparent; padding: .35rem; border-radius: 6px; }
td input:focus, td textarea:focus { background: #fff; border-color: var(--primary); }
.status-found { color: #0b7551; font-weight: 700; }
.status-not-found { color: #b73737; font-weight: 700; }
.remove-row { border: 0; background: #fdecec; color: var(--danger); border-radius: 7px; width: 30px; height: 30px; cursor: pointer; }
.toast { position: fixed; right: 1rem; bottom: 1rem; max-width: min(420px, calc(100% - 2rem)); padding: .85rem 1rem; border-radius: 10px; color: #fff; background: #263b32; box-shadow: var(--shadow); z-index: 50; }
.toast.error { background: #9c3030; }
.hidden { display: none !important; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(420px, 100%); padding: 2rem; }
.login-card h1 { margin: .8rem 0 0; }
.login-card .btn { width: 100%; margin-top: 1rem; }
.brand-mark { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; background: var(--primary); color: #fff; font-size: 1.35rem; font-weight: 800; }
.alert { padding: .75rem; border-radius: 8px; margin: 1rem 0; }
.alert.error { background: #fdeaea; color: #922f2f; }
@media (max-width: 820px) {
    .topbar, .section-head { flex-direction: column; align-items: stretch; }
    .input-grid { grid-template-columns: 1fr; }
    .top-actions, .export-actions, .template-controls { width: 100%; }
    .top-actions .btn, .export-actions .btn { flex: 1; }
}
