:root {
  color-scheme: light;
  --bg: #f3f5f0;
  --panel: #ffffff;
  --panel-soft: #f6f8f3;
  --ink: #151b18;
  --muted: #68756f;
  --line: #dce4de;
  --line-strong: #cad6cf;
  --accent: #1f7a5b;
  --accent-strong: #0d5e44;
  --accent-soft: #e2f4ec;
  --amber: #a65f00;
  --red: #b42318;
  --blue: #235f9f;
  --coal: #111a16;
  --gold: #e7b84e;
  --shadow: 0 22px 54px rgba(23, 33, 28, 0.12);
  --shadow-soft: 0 8px 24px rgba(23, 33, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(231, 184, 78, 0.22), transparent 24rem),
    linear-gradient(135deg, rgba(31, 122, 91, 0.10), transparent 42rem),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 18px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), transparent 22rem),
    var(--coal);
  color: #f8fbf8;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(145deg, #f3c85f, var(--gold));
  color: #142018;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(231, 184, 78, 0.22);
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.sidebar .brand span,
.sidebar .ghost-button {
  color: #c7d4ce;
}

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

.nav-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.nav-button span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
}

.nav-button[aria-current="page"],
.nav-button:hover {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.11);
}

.nav-button:hover {
  transform: translateX(2px);
}

.nav-button[aria-current="page"] span {
  background: var(--gold);
  color: #17211c;
}

.main {
  min-width: 0;
  padding: 28px clamp(18px, 3vw, 44px) 44px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding: 4px 0 10px;
}

.topbar h1,
.modal h2 {
  margin: 4px 0 0;
  line-height: 1.1;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(2rem, 4vw, 3.25rem);
}

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

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 300px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9), var(--shadow-soft);
}

.search-field input {
  width: 100%;
  min-height: 42px;
  border: 0;
  outline: 0;
  background: transparent;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button,
.icon-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease, border-color 140ms ease;
}

.primary-button:hover,
.secondary-button:hover,
.danger-button:hover,
.icon-button:hover,
.chip:hover,
.row-action:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}

.primary-button {
  background: linear-gradient(180deg, #238763, var(--accent-strong));
  color: white;
  box-shadow: 0 10px 22px rgba(31, 122, 91, 0.22);
}

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

.secondary-button {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(23, 33, 28, 0.06);
}

.ghost-button {
  margin-top: auto;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
}

.danger-button {
  background: #fff5f3;
  border-color: #f3b8b1;
  color: var(--red);
  margin-right: auto;
}

.icon-button {
  width: 40px;
  padding: 0;
  background: #eef3ee;
  color: var(--ink);
  font-size: 1.35rem;
}

.view-root {
  display: grid;
  gap: 20px;
}

.storage-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  box-shadow: var(--shadow-soft);
}

.storage-banner strong {
  color: var(--ink);
}

.storage-banner.ok {
  border-color: #b6e6d4;
  background: #effbf6;
}

.storage-banner.warning {
  border-color: #f4d793;
  background: #fff8e7;
}

.auth-status {
  min-height: 40px;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 4px 6px 4px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow-soft);
}

.user-pill span {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 750;
}

.user-pill strong {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 420px);
  gap: 20px;
  padding: 24px;
  align-items: center;
}

.auth-copy h2 {
  margin: 4px 0 10px;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
}

.login-form {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.form-message {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #f4d793;
  border-radius: 8px;
  background: #fff8e7;
  color: #835000;
  font-weight: 750;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(150px, 1fr));
  gap: 14px;
}

.stat {
  position: relative;
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.stat::after {
  content: "";
  position: absolute;
  inset: auto -28px -36px auto;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: rgba(31, 122, 91, 0.10);
}

.stat span {
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 750;
}

.stat strong {
  display: block;
  margin-top: 10px;
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  letter-spacing: 0;
}

.stat small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 650;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #fbfcfa);
}

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 1.02rem;
}

.panel-kicker {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 760px;
}

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #f8faf7;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr {
  transition: background 140ms ease;
}

tbody tr:hover {
  background: #fbfcfa;
}

tr:last-child td {
  border-bottom: 0;
}

.row-action {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 800;
  padding: 0 11px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge.valid,
.badge.active {
  color: #0f684b;
  background: #dcf5eb;
  border-color: #b6e6d4;
}

.badge.soon {
  color: #835000;
  background: #fff0c8;
  border-color: #f4d793;
}

.badge.expired,
.badge.due {
  color: #9a1c12;
  background: #ffe1dd;
  border-color: #f2b4ad;
}

.badge.neutral {
  color: #34505e;
  background: #e7f0f6;
  border-color: #c9dce9;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  min-height: 36px;
  padding: 0 12px;
  cursor: pointer;
  color: var(--ink);
  font-weight: 750;
}

.chip.active {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: #e5f4ee;
}

.profile-head {
  display: grid;
  grid-template-columns: 154px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
}

.machine-art {
  min-height: 112px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(231, 184, 78, 0.96), rgba(31, 122, 91, 0.86)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='160' viewBox='0 0 240 160'%3E%3Cpath fill='none' stroke='%23142118' stroke-width='10' stroke-linecap='round' d='M42 112h104l34-46 28 21M64 112V73h72v39M28 119h170'/%3E%3Ccircle cx='62' cy='121' r='18' fill='%23142118'/%3E%3Ccircle cx='165' cy='121' r='18' fill='%23142118'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover, 86%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.detail-grid,
.report-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
  padding: 18px;
}

.detail {
  min-height: 78px;
  padding: 13px;
  border-radius: 8px;
  background: var(--panel-soft);
  border: 1px solid #e8eee9;
}

.detail span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.detail strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.timeline {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(23, 33, 28, 0.04);
}

.timeline-date {
  display: grid;
  gap: 4px;
}

.timeline-date span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.machine-cell {
  display: flex;
  align-items: center;
  gap: 11px;
}

.machine-thumb {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 8px;
  background: #17211c;
  color: var(--gold);
  font-weight: 900;
}

.machine-title {
  display: grid;
  gap: 2px;
}

.machine-title span {
  color: var(--muted);
  font-size: 0.86rem;
}

.muted {
  color: var(--muted);
}

.empty-state {
  margin: 16px;
  padding: 34px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--panel-soft);
  text-align: center;
  color: var(--muted);
}

.modal {
  width: min(980px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(13, 20, 17, 0.46);
}

.modal-body {
  padding: 20px;
  background: #fbfcfa;
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-actions {
  margin-top: 20px;
  justify-content: flex-end;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 800;
}

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

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(31, 122, 91, 0.16);
  border-color: var(--accent);
}

textarea {
  resize: vertical;
}

.wide {
  grid-column: 1 / -1;
}

.settings-list {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

@media (max-width: 1100px) {
  .stats-grid,
  .detail-grid,
  .report-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    gap: 12px;
    padding: 14px;
  }

  .brand {
    padding: 4px 4px 10px;
  }

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

  .nav-button {
    min-height: 46px;
    padding: 9px;
    font-size: 0.92rem;
  }

  .ghost-button {
    margin-top: 0;
  }

  .main {
    padding-top: 20px;
  }

  .topbar,
  .topbar-actions,
  .profile-head {
    align-items: stretch;
    flex-direction: column;
    display: flex;
  }

  .auth-panel {
    grid-template-columns: 1fr;
  }

  .user-pill {
    justify-content: space-between;
  }

  .search-field {
    min-width: 0;
  }

  .stats-grid,
  .detail-grid,
  .report-grid,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .timeline-item {
    grid-template-columns: 1fr;
  }
}
