:root {
  --ink: #172033;
  --muted: #667085;
  --line: #d8dee8;
  --surface: #ffffff;
  --page: #f3f6fb;
  --blue: #1d4ed8;
  --cyan: #06b6d4;
  --green: #147d64;
  --yellow: #d89b11;
  --red: #c24135;
  --panel: #263041;
  --shadow: 0 14px 38px rgba(23, 32, 51, .08);
}

* { box-sizing: border-box; }

html {
  width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  width: 100%;
  min-width: 0;
  overflow-x: hidden;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(29, 78, 216, .12), transparent 34rem),
    linear-gradient(180deg, #f8fbff, var(--page));
}

#app {
  min-width: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

.login-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 460px) 1fr;
  background: linear-gradient(90deg, #f7f9fc 0%, #f7f9fc 42%, #dfe7f1 42%, #dfe7f1 100%);
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 48px;
}

.login-panel h1,
.page-title h1 {
  margin: 0;
  font-size: 3rem;
  line-height: 1.02;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.login-aside {
  display: grid;
  place-items: center;
  padding: 48px;
}

.machine-visual {
  width: min(520px, 80vw);
  aspect-ratio: 4 / 5;
  border: 10px solid #263041;
  border-radius: 8px;
  background: #f8fbff;
  position: relative;
  box-shadow: 0 24px 80px rgba(23, 32, 51, .22);
  overflow: hidden;
}

.glass {
  height: 68%;
  margin: 24px;
  border: 4px solid #91a3bb;
  background:
    linear-gradient(120deg, rgba(255,255,255,.8), rgba(255,255,255,0) 38%),
    #dbeafe;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  padding: 28px;
}

.glass span {
  border-radius: 50% 50% 44% 44%;
  background: var(--c, #f4b942);
  box-shadow: inset 0 -18px rgba(0,0,0,.08);
}

.glass span:nth-child(2) { --c: #f87171; }
.glass span:nth-child(3) { --c: #34d399; }
.glass span:nth-child(4) { --c: #60a5fa; }

.claw {
  width: 72px;
  height: 90px;
  position: absolute;
  left: 50%;
  top: 42px;
  transform: translateX(-50%);
  border-left: 6px solid #3f4a5f;
  border-right: 6px solid #3f4a5f;
  border-bottom: 6px solid #3f4a5f;
}

.panel {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 24px;
  height: 110px;
  background: #27364d;
  display: grid;
  grid-template-columns: 1fr 1fr 96px;
  gap: 18px;
  align-items: center;
  padding: 18px;
}

.panel div {
  height: 54px;
  background: #0f172a;
  border: 2px solid #475569;
}

.panel button {
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: var(--yellow);
}

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

.muted, .side-note, small {
  color: var(--muted);
}

.form-stack {
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

label {
  font-weight: 700;
  font-size: .9rem;
}

input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 88px;
  resize: vertical;
}

.primary, .secondary, .danger, .tab, .icon-button {
  min-height: 42px;
  border-radius: 6px;
  padding: 10px 14px;
  font-weight: 700;
}

.primary {
  background: var(--blue);
  color: #fff;
}

.secondary {
  background: #e8eef7;
  color: var(--ink);
}

.install-button {
  border: 1px solid #bfdbfe;
}

.install-hint {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: .9rem;
  line-height: 1.35;
}

.danger {
  background: #fee2e2;
  color: #991b1b;
}

.small-button {
  min-height: 34px;
  padding: 8px 10px;
  font-size: .84rem;
}

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

.sidebar {
  background: linear-gradient(180deg, #111827, var(--panel));
  color: #fff;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand h2 {
  margin: 0;
  font-size: 1.3rem;
  letter-spacing: .01em;
}

.brand p {
  margin: 4px 0 0;
  color: #cbd5e1;
}

.nav {
  display: grid;
  gap: 8px;
}

.tab {
  text-align: left;
  color: #dbe4ef;
  background: transparent;
  border: 1px solid transparent;
}

.tab.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 8px 18px rgba(0,0,0,.14);
}

.tab:hover {
  border-color: rgba(255,255,255,.2);
  background: rgba(255,255,255,.08);
}

.tab.active:hover {
  background: #fff;
}

.content {
  padding: 28px;
  display: grid;
  gap: 22px;
  min-width: 0;
}

.topline {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.page-title p {
  margin: 8px 0 0;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.kpi, .panel-block, .item-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.kpi {
  padding: 16px;
  min-height: 110px;
}

.kpi span {
  color: var(--muted);
  font-size: .84rem;
}

.kpi strong {
  display: block;
  margin-top: 12px;
  font-size: 1.55rem;
  color: #0f172a;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  min-width: 0;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}

.panel-block {
  padding: 18px;
  min-width: 0;
}

.panel-block h2 {
  margin: 0 0 14px;
  font-size: 1.15rem;
}

.table-wrap {
  overflow-x: auto;
  max-width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

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

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

th {
  font-size: .78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: .82rem;
  font-weight: 700;
  background: #e0f2fe;
  color: #075985;
}

.status.ok {
  background: #dcfce7;
  color: #166534;
}

.status.warn {
  background: #fef3c7;
  color: #92400e;
}

.status.bad {
  background: #fee2e2;
  color: #991b1b;
}

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

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

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

.item-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  min-width: 0;
}

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

.item-card {
  padding: 16px;
  display: grid;
  gap: 8px;
  min-width: 0;
  overflow-wrap: anywhere;
  transition: transform .16s ease, border-color .16s ease;
}

.item-card:hover {
  transform: translateY(-2px);
  border-color: #bfdbfe;
}

.item-card h3 {
  margin: 0;
  font-size: 1rem;
}

.machine-summary {
  margin-top: 18px;
  padding: 16px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
  display: grid;
  gap: 8px;
}

.machine-summary h3 {
  margin: 0;
  font-size: 1.25rem;
}

.machine-summary p {
  margin: 0;
}

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

.meta span {
  background: #eef2f6;
  border-radius: 999px;
  padding: 5px 8px;
  font-size: .8rem;
}

.error {
  color: var(--red);
  font-weight: 700;
}

.notice {
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 10px 12px;
  border-radius: 6px;
}

.receipt-actions {
  margin-top: 10px;
}

@media (max-width: 940px) {
  .login-layout,
  .shell,
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }

  .login-aside {
    display: none;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 16px;
  }

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

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

@media (max-width: 620px) {
  .content, .login-panel {
    padding: 16px;
  }

  .login-layout {
    min-height: 100svh;
  }

  .login-panel {
    justify-content: start;
    padding-top: 28px;
  }

  .login-panel h1,
  .page-title h1 {
    font-size: 2rem;
    line-height: 1.08;
  }

  .kpis,
  .item-grid,
  .item-grid.compact,
  .split-form {
    grid-template-columns: 1fr;
  }

  .topline {
    align-items: stretch;
    flex-direction: column;
  }

  .topline .secondary,
  .topline .primary,
  .actions .primary,
  .actions .secondary {
    width: 100%;
  }

  .kpi {
    min-height: 92px;
    padding: 14px;
  }

  .kpi strong {
    font-size: 1.35rem;
  }

  .panel-block {
    padding: 14px;
  }

  .nav {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  .tab {
    min-height: 38px;
    padding: 9px 10px;
    text-align: center;
  }

  table {
    min-width: 620px;
  }

  th, td {
    padding: 9px 8px;
    font-size: .86rem;
  }
}

@media (max-width: 420px) {
  .content, .login-panel {
    padding: 12px;
  }

  .login-panel h1,
  .page-title h1 {
    font-size: 1.75rem;
  }

  .brand h2 {
    font-size: 1.05rem;
  }

  .sidebar {
    padding: 12px;
    gap: 12px;
  }

  .panel-block,
  .item-card {
    padding: 12px;
  }

  .kpi strong {
    font-size: 1.2rem;
  }
}
