:root {
  --red: #d4111b;
  --ink: #20203f;
  --steel: #6d7f89;
  --line: #d9dee4;
  --paper: #ffffff;
  --soft: #f4f6f8;
  --warn: #f59e0b;
  --ok: #0f9f6e;
  --danger: #be123c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
}

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

button {
  cursor: pointer;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(135deg, rgba(212, 17, 27, 0.08), transparent 38%),
    linear-gradient(315deg, rgba(32, 32, 63, 0.1), transparent 42%),
    var(--soft);
}

.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 60px rgba(32, 32, 63, 0.12);
}

.login-logo {
  width: min(260px, 100%);
  height: auto;
  justify-self: center;
}

.login-card h1 {
  font-size: 1.9rem;
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 700;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

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

.sidebar {
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
}

.brand-mark {
  width: 76px;
  height: 48px;
  border-radius: 8px;
  object-fit: contain;
  background: white;
}

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

.brand span,
.eyebrow,
.muted,
.meta {
  color: var(--steel);
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 28px;
}

.nav-item {
  height: 44px;
  border: 0;
  border-radius: 8px;
  color: var(--ink);
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  text-align: left;
}

.nav-item.active {
  background: var(--ink);
  color: white;
}

.icon {
  width: 24px;
  text-align: center;
  font-weight: 800;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
}

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

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

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

.top-actions select {
  width: auto;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(300px, 0.8fr);
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}

.panel,
.card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 18px;
}

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

.stat {
  padding: 16px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat strong {
  display: block;
  font-size: 2rem;
}

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

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.card {
  min-height: 230px;
  overflow: hidden;
  display: grid;
  grid-template-rows: 135px 1fr;
}

.thumb {
  background: linear-gradient(135deg, #e8edf1, #ffffff);
  border-bottom: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.placeholder-icon {
  font-size: 3rem;
  color: var(--steel);
}

.card-body {
  padding: 13px;
}

.card-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.card h3 {
  margin-bottom: 4px;
  font-size: 1.05rem;
}

.meta {
  font-size: 0.9rem;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef1f4;
  color: var(--ink);
  font-size: 0.82rem;
}

.badge.due {
  background: #fee2e2;
  color: var(--danger);
}

.badge.soon {
  background: #fef3c7;
  color: #8a4b00;
}

.badge.ok {
  background: #dcfce7;
  color: #067647;
}

.primary,
.ghost,
.danger,
.small {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 40px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.primary {
  background: var(--red);
  color: white;
}

.ghost {
  background: white;
  border-color: var(--line);
  color: var(--ink);
}

.danger {
  background: #fff1f2;
  border-color: #fecdd3;
  color: var(--danger);
}

.small {
  min-height: 34px;
  padding: 6px 9px;
  font-size: 0.9rem;
}

.list {
  display: grid;
  gap: 10px;
}

.list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.field {
  display: grid;
  gap: 6px;
}

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

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

.file-preview {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px;
  background: #f8fafc;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.file-preview img {
  width: 82px;
  height: 62px;
  object-fit: cover;
  border-radius: 6px;
  background: white;
}

.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.scanner-card {
  display: grid;
  gap: 14px;
}

.scanner-frame {
  position: relative;
  min-height: 320px;
  overflow: hidden;
  border-radius: 8px;
  background: #111827;
}

.scanner-frame video {
  width: 100%;
  height: 100%;
  min-height: 320px;
  display: block;
  object-fit: cover;
}

.scan-box {
  position: absolute;
  inset: 18%;
  border: 3px solid white;
  border-radius: 8px;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.28);
}

.scanner-manual {
  display: grid;
  gap: 8px;
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.machine-detail {
  display: grid;
  gap: 14px;
}

.detail-photo {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.detail-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.45fr) minmax(0, 1fr);
  gap: 12px;
  padding: 10px 12px;
  background: white;
  border-bottom: 1px solid var(--line);
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-row span {
  color: var(--steel);
}

.detail-row strong {
  font-weight: 700;
  overflow-wrap: anywhere;
}

dialog {
  border: 0;
  border-radius: 8px;
  padding: 0;
  width: min(760px, calc(100vw - 24px));
}

dialog::backdrop {
  background: rgba(18, 20, 36, 0.52);
}

.dialog-card {
  padding: 18px;
}

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

.dialog-actions {
  margin: 16px 0 0;
  padding: 0;
}

.icon-button {
  border: 0;
  background: transparent;
  font-size: 1.6rem;
  width: 38px;
  height: 38px;
}

.employee-home {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 14px;
}

.notice {
  border-left: 4px solid var(--red);
  background: white;
  padding: 14px;
  border-radius: 8px;
}

.license-notice {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.license-notice p {
  margin-bottom: 0;
}

.license-notice.soon {
  border-left-color: var(--warn);
  background: #fffbeb;
}

.license-notice.due {
  border-left-color: var(--danger);
  background: #fff1f2;
}

.hidden {
  display: none !important;
}

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

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px;
  }

  .brand {
    min-height: 44px;
  }

  .brand-mark {
    width: 64px;
    height: 40px;
  }

  .nav {
    display: flex;
    overflow-x: auto;
    margin-top: 12px;
    padding-bottom: 4px;
  }

  .nav-item {
    flex: 0 0 auto;
  }

  .main {
    padding: 14px;
  }

  .topbar,
  .toolbar,
  .hero,
  .employee-home {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .input-action,
  .inline-form,
  .detail-row {
    grid-template-columns: 1fr;
  }

  .scanner-frame,
  .scanner-frame video {
    min-height: 260px;
  }
}
