:root {
  color-scheme: light;
  --bg: #f3f6fa;
  --panel: #ffffff;
  --panel-strong: #effaf8;
  --surface: #f7f9fc;
  --text: #172436;
  --muted: #64748b;
  --primary: #087f75;
  --primary-strong: #06665f;
  --accent: #e7a33e;
  --danger: #c2413b;
  --success: #12805c;
  --border: #dce4ec;
  --shadow: 0 18px 48px rgba(27, 45, 70, 0.08);
  --shadow-soft: 0 5px 18px rgba(27, 45, 70, 0.05);
  --radius: 20px;
}

* { box-sizing: border-box; }

html {
  min-width: 320px;
  font-family: "Noto Sans Bengali", "Noto Sans Bengali UI", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 12% 0%, rgba(12, 151, 137, 0.08), transparent 34rem),
    var(--bg);
  color: var(--text);
  line-height: 1.55;
}

button, input, select, textarea { font: inherit; }
button, input, select, textarea { min-height: 46px; }
button { width: 100%; cursor: pointer; }

.app-shell {
  width: min(100%, 1380px);
  margin: 0 auto;
  padding: 22px clamp(14px, 3vw, 36px) 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 17px;
  background: linear-gradient(145deg, #0b9487, #075e61);
  box-shadow: 0 8px 18px rgba(8, 127, 117, 0.2);
  color: #fff;
  font-size: 1.6rem;
  font-weight: 800;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.35rem, 2vw, 1.8rem); line-height: 1.3; }
h2 { font-size: 1.3rem; line-height: 1.4; }
h3 { font-size: 1.05rem; line-height: 1.45; }

.lang-switch {
  display: inline-flex;
  gap: 3px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #e9eef4;
}

.lang-btn {
  width: auto;
  min-width: 52px;
  min-height: 38px;
  padding: 7px 13px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

.lang-btn.active {
  background: var(--primary);
  box-shadow: 0 2px 6px rgba(8, 127, 117, 0.2);
  color: #fff;
}

.card {
  min-width: 0;
  padding: clamp(18px, 2vw, 26px);
  border: 1px solid rgba(214, 224, 234, 0.95);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.card-header h2, .card-header h3 { margin-bottom: 0; }
.card-header > span { color: var(--muted); font-size: 0.88rem; }
.card-header h2, .card-header h3 { line-height: 1.4; }

.screen { display: none; }
.screen.active { display: block; }

.auth-card {
  position: relative;
  max-width: 500px;
  margin: clamp(26px, 6vh, 68px) auto 0;
  overflow: hidden;
  padding: clamp(24px, 4vw, 34px);
}

.auth-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: linear-gradient(90deg, var(--primary), #4bb7a7 58%, #b9e8dc);
  content: "";
}

.login-options {
  display: flex;
  gap: 10px;
  margin: 4px 0 22px;
}

.pill-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 0;
  padding: 8px 15px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.pill-option:has(input:checked) {
  border-color: rgba(8, 127, 117, 0.4);
  background: #eaf7f5;
  color: var(--primary-strong);
}

.pill-option input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  flex: 0 0 18px;
  margin: 0;
  accent-color: var(--primary);
}

label {
  display: block;
  margin-bottom: 15px;
  color: #3e4c60;
  font-size: 0.93rem;
  font-weight: 650;
}

label > input, label > select, label > textarea, label > button { margin-top: 7px; }

input, select, textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid #d5dee8;
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input::placeholder, textarea::placeholder { color: #94a3b8; }
input:hover, select:hover, textarea:hover { border-color: #b6c5d3; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 4px rgba(8, 127, 117, 0.12);
}

textarea { min-height: 88px; resize: vertical; }

button {
  border: 1px solid transparent;
  border-radius: 12px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

button:hover { transform: translateY(-1px); }
button:active { transform: translateY(0); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(8, 127, 117, 0.32);
  outline-offset: 2px;
}

button.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  box-shadow: 0 5px 12px rgba(8, 127, 117, 0.15);
  color: #fff;
  font-weight: 750;
}

button.primary:hover { box-shadow: 0 7px 16px rgba(8, 127, 117, 0.22); }
button.secondary { border-color: #e0e7ef; background: #edf2f7; color: #26364a; }
button.secondary:hover { background: #e3ebf3; }
button.ghost { border-color: var(--border); background: rgba(255, 255, 255, 0.55); color: var(--text); }
button.ghost:hover { border-color: #b7c5d3; background: #fff; }
button.small { min-height: 42px; padding: 9px 13px; font-size: 0.9rem; }
.hidden { display: none !important; }

.demo-box {
  margin-top: 22px;
  padding: 15px 16px;
  border: 1px solid #f1dfbd;
  border-radius: 14px;
  background: #fffaf0;
  color: #56452c;
  font-size: 0.89rem;
}

.demo-box strong { display: block; margin-bottom: 6px; color: #47391f; }
.demo-box p { margin-bottom: 5px; }
.demo-box p:last-child { margin-bottom: 0; }
.demo-warning { padding-top: 9px; border-top: 1px solid #f1dfbd; line-height: 1.55; }

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(270px, 1fr) minmax(0, 2fr);
  align-items: start;
  gap: 20px;
}

.admin-grid { grid-template-columns: minmax(260px, 1fr) minmax(0, 2fr); }
.form-card { max-width: 100%; }
.sidebar-card { position: sticky; top: 18px; }
.admin-stack { display: grid; gap: 0; }

.inline-card {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid #cfe9e4;
  border-radius: 15px;
  background: var(--panel-strong);
}

.inline-card h3 { margin: 0 0 12px; }

fieldset {
  min-width: 0;
  margin: 0 0 18px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: #fcfdff;
}

legend { padding: 0 8px; color: var(--text); font-weight: 750; }
.field-row { display: grid; gap: 15px; }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.action-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 18px;
}

.action-row > * { width: auto; min-width: 120px; }
#entryForm > label { margin-bottom: 17px; }
#entryForm .field-row { gap: 15px; }
#entryForm button[type="submit"] { min-width: 190px; }

.needs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.need-item {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #fff;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.need-item:hover { border-color: #a9c8c3; }
.need-item.selected { border-color: #58a69c; background: #effaf8; box-shadow: inset 0 0 0 1px rgba(8, 127, 117, 0.08); }
.need-label { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; color: var(--text); }
.need-label input { width: 19px; height: 19px; min-height: 19px; margin: 0; accent-color: var(--primary); }
.need-level { min-height: 40px; padding: 8px 10px; }

.panel-block { padding-top: 20px; border-top: 1px solid #e8edf2; }
.panel-block:first-child { padding-top: 0; border-top: 0; }
.stacked-form { margin-bottom: 18px; }
.list-block { display: grid; gap: 10px; }
.list-item {
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.list-item small { display: block; margin-top: 4px; color: var(--muted); }
.table-wrap { width: 100%; overflow: auto; border: 1px solid var(--border); border-radius: 14px; }
table { width: 100%; min-width: 760px; border-collapse: collapse; background: #fff; }
th, td { padding: 12px 13px; border-bottom: 1px solid #e8edf2; text-align: left; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; background: #f1f5f9; color: #334155; font-size: 0.86rem; font-weight: 750; }
td { font-size: 0.91rem; }
tbody tr:hover { background: #f8fbfc; }
tbody tr:last-child td { border-bottom: 0; }

.kv-grid { display: grid; gap: 9px; }
.stat-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 13px;
  border: 1px solid #e3eaf1;
  border-radius: 13px;
  background: #f6f8fb;
}

.stat-pill strong { color: var(--primary-strong); font-size: 1.08rem; }
.badge {
  display: inline-block;
  padding: 4px 9px;
  border: 1px solid rgba(8, 127, 117, 0.12);
  border-radius: 999px;
  background: #eaf7f5;
  color: var(--primary-strong);
  font-size: 0.76rem;
  font-weight: 750;
}

.modal {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 29, 47, 0.54);
  backdrop-filter: blur(3px);
}

.modal-card {
  width: min(620px, 100%);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(13, 30, 48, 0.25);
}

.modal-actions { justify-content: flex-end; }
button:disabled, .lang-switch button:disabled { cursor: not-allowed; opacity: 0.55; transform: none; }

.toast {
  z-index: 30;
  max-width: min(440px, calc(100vw - 32px));
  padding: 13px 17px !important;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px !important;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.22);
  color: #fff;
  font-size: 0.93rem;
  line-height: 1.5;
}

@media (max-width: 900px) {
  .workspace-grid, .admin-grid { grid-template-columns: minmax(240px, 1fr) minmax(0, 1.8fr); gap: 14px; }
  .card { padding: 18px; }
  .needs-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
  .app-shell { padding: 14px 14px 30px; }
  .topbar { align-items: flex-start; margin-bottom: 16px; }
  .workspace-grid, .admin-grid { display: flex; flex-direction: column; gap: 14px; }
  #workerScreen .form-card { order: -1; }
  .sidebar-card { position: static; width: 100%; }
  .form-card, .sidebar-card { width: 100%; }
  .two-col { grid-template-columns: 1fr; gap: 0; }
  .field-row.two-col { gap: 0; }
  .card { padding: 17px; border-radius: 17px; }
  .auth-card { margin-top: 20px; padding: 24px 20px; }
  .action-row > * { min-width: 0; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions > * { width: 100%; }
  .admin-stack { display: block; }
}

@media (max-width: 440px) {
  .app-shell { padding: 11px 11px 24px; }
  .topbar { flex-wrap: wrap; align-items: center; gap: 12px; }
  .brand-wrap { gap: 10px; }
  .brand-mark { width: 45px; height: 45px; flex-basis: 45px; border-radius: 14px; font-size: 1.4rem; }
  .topbar-actions { width: 100%; justify-content: space-between; gap: 8px; }
  .card { padding: 15px; border-radius: 16px; }
  .card-header { align-items: flex-start; margin-bottom: 14px; }
  .needs-grid { grid-template-columns: 1fr; }
  .card-header:has(#exportCsvBtn) { align-items: flex-start; flex-direction: column; }
  .card-header:has(#exportCsvBtn) button { width: 100%; }
  #entryForm .action-row { position: sticky; bottom: 8px; z-index: 2; padding: 9px; border: 1px solid var(--border); border-radius: 15px; background: rgba(255, 255, 255, 0.96); box-shadow: var(--shadow); }
  #entryForm button[type="submit"] { flex: 1; }
}

.topbar-actions > button { width: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
