:root {
  --bg: #f6f8f8;
  --surface: #ffffff;
  --surface-soft: #eef5f2;
  --text: #17211d;
  --muted: #66736d;
  --border: #d9e2de;
  --green: #16724f;
  --green-dark: #0f563b;
  --blue: #1f5f86;
  --amber: #b56b12;
  --red: #a13f36;
  --shadow: 0 18px 44px rgba(23, 33, 29, 0.09);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  background: #10251d;
  color: #f7fbf9;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand,
.profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand strong,
.profile strong {
  display: block;
  font-size: 15px;
}

.brand span:not(.brand-mark),
.profile span {
  color: #b8cac2;
  font-size: 13px;
}

.brand-mark,
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #d6f2e6;
  color: #0f563b;
  font-weight: 800;
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  border: 0;
  color: #d9e7e1;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 12px;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.11);
  color: #ffffff;
}

.nav-badge {
  margin-left: auto;
  min-width: 24px;
  height: 22px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #f4c06a;
  color: #3a2307;
  font-size: 12px;
  font-weight: 800;
}

.profile {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 18px;
}

.avatar {
  background: #23453a;
  color: #ffffff;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  min-height: 70px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

h1,
h2,
p {
  margin: 0;
}

.topbar h1 {
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: 0;
}

.topbar p {
  color: var(--muted);
  margin-top: 6px;
}

.topbar h1 small {
  color: var(--amber);
  font-size: 13px;
  font-weight: 800;
}

.demo-banner {
  margin: 10px 0 18px;
  border: 1px solid #efcf95;
  border-radius: var(--radius);
  padding: 12px 14px;
  background: #fff7e7;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.demo-banner strong,
.demo-banner span {
  display: block;
}

.demo-banner span {
  color: #73501a;
  font-size: 13px;
  margin-top: 3px;
}

.demo-actions {
  display: flex;
  gap: 8px;
  flex: none;
}

.demo-actions a {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.topbar-actions,
.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  min-width: 0;
}

.role-control {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  color: var(--muted);
  font-size: 13px;
  min-width: 0;
}

.role-control select {
  max-width: 150px;
}

select,
input,
textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 9px 10px;
  min-height: 38px;
}

textarea {
  resize: vertical;
}

.sync-status {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 13px;
  background: #e3f5ec;
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 700;
}

.maintenance-setting input {
  width: 76px;
  min-height: 30px;
  padding: 5px 8px;
  text-align: center;
}

.sync-status.readonly {
  background: #eef1f3;
  color: #536067;
}

.sync-status.save-error {
  background: #fde8e5;
  color: var(--red);
}

.stats-band {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  gap: 12px;
  align-items: center;
  box-shadow: 0 8px 24px rgba(23, 33, 29, 0.04);
}

.stat strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.stat-icon,
.icon,
.large-icon {
  display: inline-grid;
  place-items: center;
  flex: none;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: #e3f5ec;
  color: var(--green);
}

.stat-icon::before {
  content: "";
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.stat-icon.calendar::before {
  border-radius: 4px;
}

.stat-icon.warning {
  background: #fff3dc;
  color: var(--amber);
}

.stat-icon.warning::before {
  border-radius: 3px;
  transform: rotate(45deg);
}

.stat-icon.tool {
  background: #e4f1f8;
  color: var(--blue);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 14px;
  align-items: start;
}

.workspace > * {
  min-width: 0;
}

.content-panel,
.detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.content-panel {
  min-width: 0;
  overflow: hidden;
}

.detail-panel {
  padding: 18px;
  position: sticky;
  top: 18px;
}

.toolbar {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.search-wrap {
  min-width: 250px;
  flex: 1;
  position: relative;
}

.search-wrap input {
  width: 100%;
  padding-left: 34px;
}

.search-wrap .icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.primary,
.secondary,
.mini-button {
  border: 0;
  border-radius: var(--radius);
  min-height: 38px;
  padding: 0 13px;
  font-weight: 750;
}

.primary {
  background: var(--green);
  color: #ffffff;
}

.primary:hover {
  background: var(--green-dark);
}

.secondary,
.mini-button {
  background: #edf3f0;
  color: #25342e;
  border: 1px solid var(--border);
}

.file-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.file-button input {
  display: none;
}

.readonly-note {
  margin: 12px 14px 0;
  border: 1px solid #d8dde1;
  border-radius: var(--radius);
  padding: 10px 12px;
  background: #f4f6f7;
  color: #4d5960;
  font-size: 13px;
}

.settings-panel {
  padding: 16px;
}

.view-summary {
  margin: 12px 14px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: #fbfcfc;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--muted);
}

.view-summary strong {
  color: var(--text);
}

.settings-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.settings-heading h2 {
  font-size: 20px;
  line-height: 1.2;
}

.settings-heading p {
  color: var(--muted);
  margin-top: 4px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

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

.settings-grid textarea {
  width: 100%;
  min-height: 150px;
  line-height: 1.45;
}

.settings-grid label span {
  font-weight: 500;
}

.settings-actions {
  grid-column: 1 / -1;
}

.settings-actions .primary {
  width: max-content;
}

code {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 0.95em;
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #f9fbfa;
}

tr {
  transition: background 140ms ease;
}

tbody tr:hover,
tbody tr.selected {
  background: #f1f8f5;
}

.item-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 760;
}

.material-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #e3f5ec;
  color: var(--green-dark);
  font-size: 15px;
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
  background: #e7f5ee;
  color: var(--green-dark);
}

.status.low {
  background: #fff2d9;
  color: #87510c;
}

.status.maintenance,
.status.out {
  background: #fde8e5;
  color: var(--red);
}

.status.archived {
  background: #eef1f3;
  color: #536067;
}

.available.low-number {
  color: var(--amber);
  font-weight: 850;
}

.empty-state {
  min-height: 320px;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  color: var(--text);
}

.detail-heading {
  display: flex;
  gap: 12px;
  align-items: center;
}

.large-icon {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  background: var(--surface-soft);
  font-size: 0;
}

.large-icon::before {
  content: "";
  width: 24px;
  height: 24px;
  border: 3px solid var(--green);
  border-radius: 50%;
  box-shadow: 9px 9px 0 -5px var(--green);
}

.detail-heading h2 {
  font-size: 19px;
  line-height: 1.2;
}

.detail-heading p {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.quantity-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0;
}

.quantity-grid > div {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfcfc;
}

.quantity-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.quantity-grid strong {
  font-size: 24px;
}

.stock-editor {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  gap: 8px;
}

.stock-editor button {
  border: 0;
  border-radius: var(--radius);
  background: #e3f5ec;
  color: var(--green-dark);
  font-size: 20px;
  font-weight: 800;
}

.stock-editor input {
  text-align: center;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  gap: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
  overflow-x: auto;
}

.tab {
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  min-height: 34px;
  color: var(--muted);
  font-weight: 750;
  font-size: 13px;
  padding: 0 6px;
}

.tab.active {
  background: #e3f5ec;
  color: var(--green-dark);
}

.tab-panel {
  display: none;
  padding-top: 14px;
}

.tab-panel.active {
  display: block;
}

.inline-form,
.stack-form {
  display: grid;
  gap: 8px;
}

.inline-form {
  grid-template-columns: 1fr 76px 132px auto;
}

.detail-panel .inline-form {
  grid-template-columns: 1fr 74px;
}

.detail-panel .inline-form input:first-child,
.detail-panel .inline-form button {
  grid-column: 1 / -1;
}

.stack-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

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

.list-item,
.alert-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  background: #fbfcfc;
  font-size: 13px;
}

.list-item strong,
.alert-item strong {
  font-size: 14px;
}

.maintenance-alert {
  border-color: #f0cdc7;
  background: #fff7f6;
}

.quiet-alert {
  background: #fbfcfc;
}

.list-item span,
.alert-item span,
.info-readonly {
  color: var(--muted);
}

.list-item footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.danger {
  border: 0;
  background: transparent;
  color: var(--red);
  font-weight: 800;
}

.danger-button {
  border: 1px solid #efc6c0;
  border-radius: var(--radius);
  min-height: 38px;
  padding: 0 13px;
  background: #fff3f1;
  color: var(--red);
  font-weight: 800;
}

.danger-button:hover {
  background: #fde8e5;
}

.order-tag {
  display: inline-flex;
  width: max-content;
  border-radius: 999px;
  padding: 4px 8px;
  background: #fff2d9;
  color: #87510c;
  font-size: 12px;
  font-weight: 850;
}

.hidden {
  display: none !important;
}

.icon {
  width: 18px;
  height: 18px;
  color: currentColor;
}

.icon::before {
  content: "";
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  display: block;
}

.icon.grid::before {
  border-radius: 3px;
  box-shadow: 7px 0 0 -4px currentColor, 0 7px 0 -4px currentColor, 7px 7px 0 -4px currentColor;
}

.icon.box::before {
  border-radius: 4px;
}

.icon.calendar::before {
  border-radius: 3px;
  border-top-width: 5px;
}

.icon.tool::before {
  border-radius: 50%;
  transform: rotate(45deg);
}

.icon.bell::before {
  border-radius: 8px 8px 5px 5px;
}

.icon.search::before {
  border-radius: 50%;
  box-shadow: 7px 7px 0 -5px currentColor;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 86px minmax(0, 1fr);
  }

  .brand div,
  .profile div,
  .nav-item {
    font-size: 0;
  }

  .nav-item {
    justify-content: center;
    padding: 0;
  }

  .nav-badge {
    position: absolute;
    transform: translate(16px, -10px);
  }

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

  .detail-panel {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    min-height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .nav-list {
    display: flex;
  }

  .profile {
    display: none;
  }

  .main {
    padding: 14px;
  }

  .topbar {
    display: grid;
  }

  .demo-banner,
  .demo-actions {
    display: grid;
  }

  .topbar-actions > * {
    width: 100%;
    justify-content: flex-start;
  }

  .topbar-actions {
    width: 100%;
  }

  .role-control select {
    max-width: 128px;
  }

  .stats-band {
    grid-template-columns: 1fr;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .toolbar > * {
    width: 100%;
  }

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

  .settings-actions .primary {
    width: 100%;
  }
}
