:root {
  --bg: #f6f3ed;
  --ink: #27231d;
  --muted: #756f66;
  --line: #ddd5c8;
  --panel: #fffcf6;
  --field: #ffffff;
  --accent: #2f6b4f;
  --accent-strong: #24533d;
  --gold: #c9922d;
  --danger: #b6463d;
  --nav: #1f2f29;
  --nav-soft: #2a3e35;
  --shadow: 0 18px 45px rgba(55, 44, 31, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

[hidden] {
  display: none !important;
}

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

.auth-card {
  display: grid;
  width: min(100%, 430px);
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.auth-logo {
  width: min(260px, 70vw);
}

.app-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 100vh;
}

.app-body {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 0;
  transition: grid-template-columns 180ms ease;
}

.app-shell.is-collapsed .app-body {
  grid-template-columns: 86px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 96px;
  z-index: 30;
  height: calc(100vh - 96px);
  overflow: auto;
  background: var(--nav);
  color: #fff;
  transition: transform 180ms ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 96px;
  padding: 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar.collapsed .nav-children,
.sidebar.collapsed .nav-group,
.sidebar.collapsed .nav-item {
  overflow: hidden;
  color: transparent;
}

.side-nav {
  display: grid;
  gap: 8px;
  padding: 16px;
}

.nav-group,
.nav-item {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
}

.nav-group {
  background: transparent;
  color: #d9e6de;
  font-weight: 800;
}

.nav-group::after {
  content: "+";
  float: right;
}

.nav-group[aria-expanded="true"]::after {
  content: "-";
}

.nav-children {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
  padding-left: 10px;
}

.nav-item {
  background: transparent;
  color: #d9e6de;
  padding: 0 12px;
  font-weight: 750;
}

.nav-item:hover,
.nav-item.active {
  background: var(--nav-soft);
  color: #fff;
}

.main-shell {
  min-width: 0;
  min-height: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 96px;
  padding: 18px 28px 16px;
  border-bottom: 1px solid var(--line);
  background: #fffaf1;
}

.brand-zone {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
}

.topbar-logo {
  width: min(210px, 32vw);
  max-height: 62px;
  object-fit: contain;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: clamp(1.45rem, 2.4vw, 2.1rem);
}

h2 {
  font-size: 1.2rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-email {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button,
.ghost-button,
.primary-button,
.action-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  background: var(--field);
  color: var(--accent);
  font-size: 1.25rem;
  font-weight: 800;
}

.compact-button {
  width: 38px;
  height: 38px;
}

.mobile-menu {
  display: none;
}

.layout {
  display: block;
  height: calc(100vh - 96px);
  overflow: hidden;
  padding: 24px 28px 34px;
}

.panel,
.table-shell {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.entry-panel {
  align-self: start;
  max-height: 100%;
  overflow: auto;
  padding: 20px;
}

.panel-heading,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.ghost-button {
  min-height: 36px;
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}

.wide-button {
  width: 100%;
}

.lot-form,
.inline-form {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  padding: 9px 11px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(47, 107, 79, 0.22);
  outline-offset: 1px;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--accent);
  font-size: 0.86rem;
  font-weight: 750;
}

.password-rules {
  margin: -8px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.form-message.error {
  color: var(--danger);
}

.computed-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid #d8c397;
  border-radius: 8px;
  background: #fff7e4;
}

.computed-box span {
  color: var(--muted);
  font-weight: 700;
}

.computed-box strong {
  font-size: 1.25rem;
}

.primary-button {
  min-height: 46px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.summary-grid article {
  min-height: 92px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.summary-grid strong {
  display: block;
  margin-top: 10px;
  font-size: 1.45rem;
}

.toolbar {
  margin-bottom: 12px;
}

.toolbar-button {
  flex: 0 0 auto;
  min-width: 128px;
  padding: 0 16px;
}

.search-wrap {
  display: flex;
  align-items: center;
  flex: 1;
  gap: 8px;
  min-width: 210px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  padding-left: 12px;
}

.search-wrap input {
  border: 0;
  background: transparent;
}

#statusFilter {
  max-width: 230px;
}

.table-shell {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

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

th,
td {
  padding: 13px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 0.875rem;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: var(--muted);
  text-transform: uppercase;
}

.numeric-cell {
  text-align: right;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 800;
}

.status-process {
  background: #e6f1eb;
  color: #24533d;
}

.status-finished {
  background: #fff0c9;
  color: #765110;
}

.status-delivered {
  background: #e6eef8;
  color: #264d78;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.action-button {
  min-width: 34px;
  min-height: 34px;
  background: #fff;
  color: var(--accent);
  font-weight: 800;
}

.delete-button {
  color: var(--danger);
}

.empty-state {
  display: none;
  padding: 34px;
  color: var(--muted);
  text-align: center;
}

.empty-state.visible {
  display: block;
}

.settings-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 22px;
  padding: 24px 28px 34px;
}

.management-layout {
  padding: 24px 28px 34px;
}

.settings-panel {
  padding: 20px;
}

.management-table {
  margin-top: 18px;
  box-shadow: none;
}

.management-table table {
  min-width: 900px;
}

.profile-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.profile-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 750;
}

.empty-module {
  display: grid;
  min-height: calc(100vh - 96px);
  place-items: center;
  padding: 28px;
  text-align: center;
}

.empty-module h2 {
  margin-bottom: 8px;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.empty-module p:last-child {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(31, 47, 41, 0.38);
}

.modal-panel {
  width: min(100%, 780px);
  max-height: min(88vh, 760px);
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-panel .lot-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.modal-panel .computed-box,
.modal-panel .primary-button {
  grid-column: 1 / -1;
}

.checkbox-label {
  display: flex;
  align-items: center;
  min-height: 42px;
  gap: 10px;
  color: var(--ink);
}

.checkbox-label input {
  width: 18px;
  min-height: 18px;
}

.compact-empty {
  min-height: 280px;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 25;
  background: rgba(0, 0, 0, 0.28);
}

@media (max-width: 1120px) {
  .settings-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .entry-panel {
    max-height: none;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .app-body,
  .app-shell.is-collapsed .app-body {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    transform: translateX(-100%);
    width: 280px;
    height: 100vh;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar.collapsed .nav-children,
  .sidebar.collapsed .nav-group,
  .sidebar.collapsed .nav-item {
    color: #d9e6de;
  }

  .sidebar.collapsed .nav-item:hover,
  .sidebar.collapsed .nav-item.active {
    color: #fff;
  }

  .mobile-menu {
    display: grid;
  }

  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }
}

@media (max-width: 680px) {
  .topbar,
  .layout,
  .settings-layout,
  .management-layout {
    padding-left: 16px;
    padding-right: 16px;
  }

  .toolbar,
  .topbar-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  #statusFilter {
    max-width: none;
  }

  .user-email {
    max-width: none;
  }

  .topbar-logo {
    width: min(190px, 60vw);
  }

  .modal-panel .lot-form {
    grid-template-columns: 1fr;
  }
}
