:root {
  --green: #1b5e20;
  --green-dark: #184f1b;
  --green-light: #2b7f31;
  --header-h: 52px;
  --side-w: 56px;
}

html, body { height: 100%; margin: 0; }
body { font-family: system-ui, sans-serif; background: #f4f6f4; color: #1f2937; }

.app-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.app-header {
  height: var(--header-h);
  background: linear-gradient(90deg, var(--green-dark), var(--green-light));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.header-right { display: flex; align-items: center; gap: 8px; }
.header-user { font-size: 0.8rem; opacity: 0.9; }

.btn-icon {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
}

.app-body {
  flex: 1;
  min-height: 0;
  display: flex;
}

.app-sidebar {
  width: var(--side-w);
  background: #eceff1;
  border-right: 1px solid #cfd8dc;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 0;
  gap: 8px;
  flex-shrink: 0;
}

.side-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  text-decoration: none;
  font-size: 1.25rem;
  color: #546e7a;
}

.side-icon.active, .side-icon:hover {
  background: #fff;
  box-shadow: 0 2px 8px rgba(27,94,32,0.15);
}

.app-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px;
}

/* Formularios: permitir scroll hasta los botones de acción */
.app-main:has(.form-card) {
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.app-main:has(.form-card) .form-card {
  margin-bottom: 8px;
}

.panel-title {
  margin: 0 0 12px;
  font-size: 1.1rem;
  color: var(--green);
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.toolbar input[type="search"] {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid #cfd8dc;
  border-radius: 8px;
}

.btn {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary { background: var(--green-light); color: #fff; }
.btn-secondary { background: #fff; border: 1px solid #cfd8dc; color: #37474f; }

.table-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #e0e0e0;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

table.data th {
  position: sticky;
  top: 0;
  background: #eef6ef;
  color: var(--green);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #c8e6c9;
  white-space: nowrap;
}

table.data td {
  padding: 10px 12px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}

table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: rgba(43,127,49,0.06); }

.stock-warn { color: #c62828; }
.stock-ok { color: #2e7d32; }

.form-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  max-width: 520px;
  border: 1px solid #e0e0e0;
}

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.8rem; font-weight: 700; color: #546e7a; margin-bottom: 4px; }
.field input, .field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cfd8dc;
  border-radius: 8px;
  font: inherit;
}

.estatus-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.estatus-btn {
  padding: 12px;
  border: 2px solid #cfd8dc;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.estatus-btn.selected {
  border-color: var(--green-light);
  background: #e8f5e9;
  color: var(--green);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.badge-estatus {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-solicitado { background: #fff3e0; color: #e65100; }
.badge-entregado { background: #e8f5e9; color: #2e7d32; }

.colab-list {
  position: absolute;
  z-index: 10;
  background: #fff;
  border: 1px solid #cfd8dc;
  border-radius: 8px;
  max-height: 200px;
  overflow: auto;
  width: 100%;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.colab-list button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 8px 12px;
  cursor: pointer;
}
.colab-list button:hover { background: #f1f8e9; }
.field-rel { position: relative; }
