:root {
  --bg: #f1efed;
  --bg-2: #e4ded8;
  --panel: #fffdfb;
  --panel-warm: #f4efe9;
  --ink: #2a2523;
  --muted: #776f69;
  --line: #ddd5cd;
  --line-strong: #c9bbb0;
  --accent: #8f4a43;
  --accent-dark: #763832;
  --accent-soft: #f4e7e3;
  --danger: #8c3a35;
  --shadow: 0 16px 34px rgba(73, 58, 51, .09);
  --shadow-soft: 0 8px 20px rgba(73, 58, 51, .055);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(143, 74, 67, .035), transparent 260px),
    var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}

button, input, select { font: inherit; }

button {
  border: 1px solid transparent;
  background: var(--accent);
  color: #fff;
  padding: 10px 15px;
  border-radius: 6px;
  cursor: pointer;
  min-height: 40px;
  font-weight: 600;
  transition: background .15s ease, border-color .15s ease, transform .15s ease, box-shadow .15s ease;
  box-shadow: 0 5px 12px rgba(143, 74, 67, .14);
}

button:hover { background: var(--accent-dark); transform: translateY(-1px); }
button.secondary {
  background: var(--panel-warm);
  color: var(--ink);
  border-color: var(--line);
  box-shadow: none;
}
button.secondary:hover { background: #e6ded5; border-color: var(--line-strong); }
button.danger { background: var(--danger); box-shadow: 0 5px 12px rgba(140, 58, 53, .13); }
button.icon { width: 38px; min-height: 38px; padding: 0; font-size: 18px; line-height: 1; }

input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  background: #fff;
  min-height: 40px;
  color: var(--ink);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(143, 74, 67, .12);
}

label {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

h2, h3 { margin: 0; letter-spacing: 0; }
h2 { font-size: 24px; line-height: 1.2; }
h3 { font-size: 15px; text-transform: uppercase; color: #584f49; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-page {
  background:
    linear-gradient(135deg, rgba(42, 37, 35, .04), transparent 34%),
    linear-gradient(180deg, rgba(143, 74, 67, .045), transparent 280px),
    var(--bg);
}

.login-shell {
  width: min(1120px, 100%);
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(0, 1fr);
  align-items: stretch;
  min-height: min(720px, calc(100vh - 48px));
  background: rgba(255, 253, 251, .9);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.login-panel {
  display: grid;
  align-content: center;
  gap: 24px;
  padding: clamp(26px, 4vw, 48px);
  background: rgba(255, 253, 251, .96);
  border-right: 1px solid var(--line);
}

.login-brand {
  align-self: start;
}

.login-copy {
  display: grid;
  gap: 10px;
}

.eyebrow {
  margin: 0;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.login-copy h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(27px, 3vw, 39px);
  line-height: 1.08;
  font-weight: 700;
  letter-spacing: 0;
}

.login-copy p:not(.eyebrow) {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.login-form {
  display: grid;
  gap: 14px;
  width: 100%;
}

.login-form button {
  width: 100%;
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  color: var(--danger);
  background: #f6e7e4;
  border: 1px solid rgba(140, 58, 53, .18);
  border-radius: 6px;
  font-size: 13px;
}

.login-visual {
  position: relative;
  min-height: 520px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background:
    linear-gradient(180deg, rgba(255, 253, 251, .78), rgba(244, 239, 233, .96)),
    #f4efe9;
}

.login-visual::before {
  content: "";
  position: absolute;
  inset: 22px;
  border: 1px solid rgba(201, 187, 176, .7);
  border-radius: 8px;
  pointer-events: none;
}

.login-visual img {
  position: relative;
  width: min(100%, 760px);
  height: 100%;
  object-fit: cover;
  object-position: center bottom;
  display: block;
}

.login-visual.compact img {
  object-position: center center;
}

.modal form {
  width: min(430px, 100%);
  display: grid;
  gap: 15px;
  background: rgba(251, 250, 248, .96);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 26px;
  box-shadow: var(--shadow);
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 248, .92);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar > .row {
  justify-content: flex-end;
}

.brand {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  font-weight: 700;
  min-width: 0;
}

.brand .muted {
  font-weight: 400;
  overflow-wrap: anywhere;
}

.mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  box-shadow: 0 7px 16px rgba(143, 74, 67, .18);
  flex: 0 0 auto;
}

.workspace {
  display: block;
  min-height: 0;
}

.content {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 24px;
  overflow: auto;
}

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; min-width: 0; }
.between { justify-content: space-between; }
.stack { display: grid; gap: 14px; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(170px, 1fr)); gap: 12px; }

.object, .tree-card, .rate-row {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow-soft);
}

.object {
  cursor: pointer;
  display: grid;
  gap: 6px;
  box-shadow: none;
  border-color: transparent;
}

.object:hover { border-color: var(--line-strong); background: #fff; }
.object.active {
  border-color: rgba(143, 74, 67, .32);
  background: var(--accent-soft);
  box-shadow: inset 4px 0 0 var(--accent);
}

.objects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}

.object-large {
  min-height: 150px;
  padding: 14px;
  border-color: var(--line);
  box-shadow: var(--shadow-soft);
}

.object-large h3 {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.25;
  text-transform: none;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.object-large > .row strong {
  color: var(--accent-dark);
  font-size: 18px;
  font-weight: 700;
}

.object-stats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: auto;
}

.object-stats span {
  padding: 5px 7px;
  border-radius: 6px;
  background: var(--panel-warm);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.users-grid {
  display: grid;
  gap: 10px;
}

.user-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) minmax(86px, auto) minmax(104px, auto);
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.user-avatar {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--panel-warm);
  border: 1px solid var(--line);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.user-info {
  min-width: 0;
}

.user-info strong {
  display: block;
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.user-count {
  min-width: 76px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8f5f1;
  text-align: center;
}

.user-count span {
  display: block;
  color: var(--accent-dark);
  font-size: 17px;
  font-weight: 700;
  line-height: 1;
}

.user-count small,
.locked-user {
  color: var(--muted);
  font-size: 12px;
}

.user-actions {
  display: flex;
  justify-content: flex-end;
}

.user-actions button {
  min-height: 34px;
  padding: 7px 11px;
}

.muted { color: var(--muted); }
.total {
  margin-top: 6px;
  font-size: 27px;
  font-weight: 700;
  color: var(--accent-dark);
}

.tree-list {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.tree-card {
  border-left: 3px solid var(--accent);
  display: grid;
  gap: 7px;
  padding: 10px 12px;
  box-shadow: none;
}

.tree-card strong { font-size: 14px; font-weight: 600; }

.tree-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tree-head > .row:first-child {
  flex: 1 1 auto;
  min-width: 0;
}

.tree-head > .row:first-child > div {
  min-width: 0;
}

.tree-total {
  color: var(--accent-dark);
  font-size: 16px;
  font-weight: 700;
}

.photo {
  width: 46px;
  height: 46px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg-2);
}

.species-icon {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  padding: 5px;
  border-radius: 7px;
  background: var(--panel-warm);
  border: 1px solid var(--line);
}

.tree-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(92px, 1fr));
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8f5f1;
}

.tree-metrics span {
  min-height: 22px;
  display: flex;
  align-items: center;
  padding: 4px 0;
  border-radius: 6px;
  background: transparent;
  border: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.line-items {
  display: grid;
  gap: 2px;
  padding-top: 0;
}

.line-items div {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(110px, auto) minmax(90px, auto);
  gap: 8px;
  align-items: center;
  padding: 5px 2px;
  border-radius: 0;
  background: transparent;
  border: 0;
  border-bottom: 1px solid rgba(211, 204, 196, .72);
  font-size: 12px;
  min-width: 0;
}

.line-items span,
.line-items b,
.line-items strong {
  overflow-wrap: anywhere;
}

.line-items div:last-child {
  border-bottom: 0;
}

.line-items b {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.line-items strong {
  text-align: right;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 600;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(48, 40, 36, .42);
  padding: 18px;
  z-index: 20;
}

.modal form {
  width: min(940px, 100%);
  max-height: 92vh;
  overflow: auto;
}

.checks {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 11px;
  color: var(--ink);
  background: #fff;
}

.checks label:has(input:checked) {
  border-color: rgba(143, 74, 67, .38);
  background: var(--accent-soft);
}

.checks input { width: auto; min-height: auto; accent-color: var(--accent); }

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.stack > table {
  display: block;
  overflow-x: auto;
}

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

tr:last-child td { border-bottom: 0; }
th {
  color: #5f554e;
  font-size: 12px;
  background: var(--panel-warm);
}

td input { min-width: 120px; }

.empty {
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: rgba(251, 250, 248, .68);
  color: var(--muted);
}

@media (max-width: 900px) {
  .grid { grid-template-columns: 1fr; }
  .login { padding: 16px; }
  .login-shell {
    grid-template-columns: 1fr;
    min-height: auto;
  }
  .login-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .login-visual {
    min-height: 360px;
  }
  .login-visual img {
    height: 360px;
  }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar > .row { width: 100%; justify-content: flex-start; }
  .content { padding: 16px; }
  .tree-head { flex-direction: column; }
  .tree-metrics { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .line-items div { grid-template-columns: 1fr; }
  .line-items strong { text-align: left; }
  .user-card { grid-template-columns: 42px minmax(0, 1fr) minmax(86px, auto); }
  .user-actions {
    grid-column: 2 / -1;
    justify-content: flex-start;
  }
}

@media (max-width: 520px) {
  body { font-size: 13px; }
  button { min-height: 36px; padding: 8px 10px; }
  button.icon { width: 34px; min-height: 34px; }
  h2 { font-size: 20px; }
  .login { padding: 10px; }
  .login-panel { gap: 18px; padding: 20px; }
  .login-copy h1 { font-size: 25px; }
  .login-copy p:not(.eyebrow) { font-size: 14px; }
  .login-visual { min-height: 250px; }
  .login-visual::before { inset: 10px; }
  .login-visual img { height: 260px; }
  .modal form { padding: 18px; }
  .topbar { padding: 12px; }
  .topbar > .row { gap: 7px; }
  .topbar > .row button { flex: 1 1 calc(50% - 7px); }
  .content { padding: 12px; }
  .objects-grid { grid-template-columns: 1fr; }
  .object-large { min-height: 128px; }
  .tree-card { padding: 9px 10px; }
  .tree-head > .row:last-child { width: 100%; justify-content: space-between; }
  .tree-metrics { grid-template-columns: 1fr 1fr; padding: 7px 8px; }
  .photo { width: 40px; height: 40px; }
  .species-icon { width: 34px; height: 34px; flex-basis: 34px; }
  th, td { padding: 8px; }
  .user-card {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 9px;
    padding: 10px;
  }
  .user-avatar {
    width: 36px;
    height: 36px;
    font-size: 11px;
  }
  .user-count,
  .user-actions {
    grid-column: 1 / -1;
  }
  .user-count {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
  }
  .user-actions button {
    width: 100%;
  }
}
