:root {
  --ink: #17201d;
  --muted: #66716d;
  --paper: #f4f2ec;
  --card: #fffefa;
  --line: #d9d8d0;
  --accent: #15735a;
  --accent-dark: #0d5944;
  --accent-soft: #dceee7;
  --danger: #a53a32;
  --shadow: 0 18px 50px rgba(31, 46, 40, .08);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--paper); font: 15px/1.45 "Segoe UI", Arial, sans-serif; }
button, input, select { font: inherit; }
.hero { max-width: 1440px; margin: 0 auto; padding: 50px 42px 34px; display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; }
.eyebrow, .step { margin: 0 0 7px; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; max-width: 800px; font-size: clamp(34px, 5vw, 67px); line-height: .98; letter-spacing: -.045em; font-weight: 680; }
.lead { max-width: 650px; margin: 20px 0 0; color: var(--muted); font-size: 17px; }
.local-badge { flex: 0 0 auto; padding: 10px 14px; border: 1px solid #bed6cd; border-radius: 30px; color: var(--accent-dark); background: var(--accent-soft); font-weight: 650; }
.local-badge span { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #25a474; box-shadow: 0 0 0 4px rgba(37,164,116,.14); }
main { max-width: 1440px; margin: 0 auto; padding: 0 42px 60px; }
.panel, .table-panel { background: var(--card); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.input-panel { padding: 30px; }
.panel-heading, .action-bar, .table-heading, .section-title { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
h2, h3 { margin: 0; letter-spacing: -.025em; }
h2 { font-size: 27px; }
h3 { font-size: 20px; }
.quiet-button { border: 0; padding: 8px; color: var(--muted); background: transparent; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-top: 26px; }
.step-upload-card { display: grid; grid-template-columns: minmax(250px, .8fr) minmax(330px, 1.2fr); gap: 24px; align-items: center; margin-top: 26px; padding: 22px; border: 1px solid #bdd5cb; border-radius: 16px; background: linear-gradient(120deg, #f3faf7, #edf4f1); }
.upload-copy h3 { margin: 4px 0 7px; font-size: 20px; }
.upload-copy p { margin: 0; color: var(--muted); }
.upload-kicker { color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.drop-zone { min-height: 92px; margin: 0; padding: 17px; display: flex; align-items: center; gap: 15px; border: 1.5px dashed #77a996; border-radius: 13px; color: var(--ink); background: rgba(255,255,255,.75); cursor: pointer; transition: border-color .15s, background .15s, transform .15s; }
.drop-zone:hover, .drop-zone.dragging { border-color: var(--accent); background: white; transform: translateY(-1px); }
.drop-zone.busy { cursor: wait; opacity: .7; }
.drop-zone strong, .drop-zone small { display: block; }
.drop-zone small { margin-top: 4px; color: var(--muted); font-weight: 500; }
.drop-icon { width: 55px; height: 55px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; color: white; background: var(--accent); font-size: 12px; font-weight: 850; letter-spacing: .06em; }
.upload-result { grid-column: 1 / -1; padding: 12px 15px; border-radius: 10px; background: white; color: var(--accent-dark); }
.upload-result.error { color: var(--danger); background: #fff4f2; }
.part-preview { grid-column: 1 / -1; margin: 0; padding: 16px; display: grid; grid-template-columns: minmax(220px, 420px) 1fr; gap: 20px; align-items: center; border-radius: 14px; background: white; }
.part-preview[hidden] { display: none; }
.part-preview img { width: 100%; max-height: 420px; object-fit: contain; border: 1px solid var(--line); border-radius: 11px; background: #fff; }
.part-preview figcaption { color: var(--muted); line-height: 1.65; }
fieldset { min-width: 0; margin: 0; padding: 21px; border: 1px solid var(--line); border-radius: 15px; }
legend { padding: 0 8px; font-size: 16px; font-weight: 750; }
legend small { color: var(--muted); font-weight: 500; }
label { display: grid; gap: 6px; margin: 0 0 13px; color: #4c5753; font-size: 13px; font-weight: 650; }
input, select { width: 100%; min-height: 42px; padding: 9px 11px; color: var(--ink); border: 1px solid #c9ccc6; border-radius: 9px; background: #fff; outline: none; }
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(21,115,90,.11); }
.checkbox-label { grid-template-columns: auto 1fr; align-items: center; gap: 10px; margin-top: 17px; padding: 12px; border-radius: 10px; color: var(--ink); background: var(--accent-soft); cursor: pointer; }
.checkbox-label input { width: 18px; min-height: 18px; height: 18px; accent-color: var(--accent); }
.dimensions-fieldset { grid-column: 1 / -1; }
.dimensions-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.hint { margin: 0 0 15px; color: var(--muted); }
.action-bar { margin-top: 24px; }
#form-status { margin: 0; color: var(--danger); }
.primary-button { min-width: 230px; padding: 13px 18px; display: flex; justify-content: space-between; gap: 28px; border: 0; border-radius: 11px; color: white; background: var(--accent); font-weight: 750; cursor: pointer; box-shadow: 0 8px 20px rgba(21,115,90,.22); }
.primary-button:hover { background: var(--accent-dark); }
.primary-button:disabled { opacity: .6; cursor: wait; }
.results-section { margin-top: 44px; }
.section-title { justify-content: flex-start; margin-bottom: 18px; }
.optimal-card { display: grid; grid-template-columns: 1.2fr repeat(5, 1fr); gap: 1px; overflow: hidden; margin-bottom: 18px; border: 1px solid #b9d7cc; border-radius: 18px; background: #b9d7cc; box-shadow: var(--shadow); }
.optimal-card > div { min-height: 112px; padding: 20px; background: var(--accent-soft); }
.optimal-card .optimal-main { color: white; background: var(--accent-dark); }
.metric-label { display: block; margin-bottom: 9px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.optimal-main .metric-label { color: #bde0d3; }
.metric-value { font-size: 25px; font-weight: 760; letter-spacing: -.025em; }
.table-panel { overflow: hidden; }
.table-heading { padding: 22px 24px; border-bottom: 1px solid var(--line); }
.table-heading p { margin: 0; color: var(--muted); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th, td { padding: 14px 17px; border-bottom: 1px solid #ebeae4; text-align: right; }
th { color: var(--muted); background: #faf9f5; font-size: 12px; letter-spacing: .03em; text-transform: uppercase; }
th:first-child, td:first-child { text-align: left; }
tbody tr.valid { background: #f1faf6; }
.status-ok { color: var(--accent); font-weight: 800; }
.status-fail { color: var(--danger); font-weight: 700; }
.limit-fail { color: var(--danger); background: #fff0ee; box-shadow: inset 0 0 0 1px #efc4bf; }
.limit-fail strong, .limit-fail small { display: block; }
.limit-fail strong { font-size: 15px; }
.limit-fail small { margin-top: 3px; font-size: 11px; font-weight: 700; }
.empty-optimal { grid-column: 1 / -1; background: #fff5e6 !important; }
footer { padding: 26px 20px 38px; color: var(--muted); text-align: center; }
.login-shell { max-width: 480px; margin: 12vh auto 0; padding: 20px; }
.login-title { font-size: 36px; margin-bottom: 28px; }
.user-main { max-width: 850px; }
.user-preview { margin: 20px 0; text-align: center; }
.user-preview img { width: 100%; max-width: 520px; border-radius: 12px; }
.admin-user-settings { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.admin-user-settings .hint { margin-top: 12px; }
.designation-field { margin-top: 24px; max-width: 620px; }
.export-panel { margin-top: 24px; padding: 30px; }
.export-panel .hint { margin-top: 14px; }
.export-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.secondary-button { padding: 12px 18px; border: 1px solid var(--accent); border-radius: 11px; color: var(--accent-dark); background: var(--accent-soft); font-weight: 700; cursor: pointer; }
button:disabled { opacity: .55; cursor: default; }
.record-count { padding: 7px 12px; border-radius: 20px; background: var(--accent-soft); font-weight: 700; white-space: nowrap; }
.excel-records, .batch-log { max-height: 250px; overflow-y: auto; padding-left: 28px; }
.excel-records li, .batch-log li { padding: 7px 0; overflow-wrap: anywhere; }
.excel-records li button { margin-left: 10px; }
.batch-panel { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
#batch-progress { width: 100%; height: 16px; margin-top: 20px; accent-color: var(--accent); }
#excel-status, #batch-status { overflow-wrap: anywhere; }
.error { color: var(--danger); }
.history-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin: 22px 0; }
.history-filters label { flex: 1 1 200px; margin: 0; }
.history-table td { text-align: left; white-space: normal; min-width: 130px; overflow-wrap: anywhere; }
.history-pagination { margin-top: 16px; }
.history-download { display: inline-block; padding: 8px; color: var(--accent-dark); }
.history-preview { width: 120px; height: 90px; object-fit: contain; }
[hidden] { display: none !important; }

@media (max-width: 1100px) { .form-grid { grid-template-columns: repeat(2, 1fr); } .optimal-card { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 680px) {
  .hero { padding: 30px 18px 24px; align-items: flex-start; flex-direction: column; }
  main { padding: 0 12px 40px; }
  .input-panel, .export-panel { padding: 18px; }
  .form-grid, .dimensions-row, .optimal-card, .step-upload-card, .part-preview { grid-template-columns: 1fr; }
  .dimensions-fieldset { grid-column: auto; }
  .panel-heading, .action-bar, .table-heading { align-items: stretch; flex-direction: column; }
  .primary-button { width: 100%; }
}
