:root {
  --line: #e2e8f0;
  --muted: #64748b;
  --text: #0f172a;
  --teal: #0f766e;
  --teal-dark: #115e59;
  --danger: #be123c;
  --warn: #b45309;
  --ok: #047857;
}

body {
  background:
    radial-gradient(circle at top left, rgba(20, 184, 166, .14), transparent 32%),
    radial-gradient(circle at 82% 10%, rgba(59, 130, 246, .12), transparent 28%),
    #07111f;
  color: var(--text);
  font-size: 14px;
}

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

button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: #0f172a;
  cursor: pointer;
}

button:hover { border-color: var(--teal); }
button:disabled { cursor: not-allowed; opacity: .45; }

.btn-primary,
.primary {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}

.btn-primary:hover,
.primary:hover {
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

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

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

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

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

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.table-wrap { overflow: auto; }

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

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  background: #eef7f8;
  color: #475569;
  font-size: 12px;
  font-weight: 700;
}

tbody tr { cursor: pointer; }
tbody tr:hover,
tbody tr.selected { background: #f0fdfa; }

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
}

.s-pending { background: #eff6ff; color: #1d4ed8; }
.s-downloaded { background: #e0f2fe; color: #0369a1; }
.s-producing { background: #fffbeb; color: var(--warn); }
.s-produced { background: #ecfdf5; color: var(--ok); }
.s-exception { background: #fff1f2; color: var(--danger); }
.s-cancelled { background: #f1f5f9; color: #475569; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, .94), rgba(15, 23, 42, .96)),
    url("/uploads/front-chest-pod.png") center / cover;
}

.login-card {
  width: min(440px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .18);
  padding: 28px;
}

.muted { color: var(--muted); }
.app-header {
  background:
    linear-gradient(135deg, rgba(15, 23, 42, .98), rgba(8, 47, 73, .94)),
    repeating-linear-gradient(90deg, rgba(45, 212, 191, .08) 0 1px, transparent 1px 42px);
  border-bottom: 1px solid rgba(45, 212, 191, .22);
  color: #fff;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(15, 23, 42, .92), rgba(15, 118, 110, .72));
  border: 1px solid rgba(45, 212, 191, .32);
  box-shadow: 0 0 28px rgba(20, 184, 166, .18);
  overflow: hidden;
}

.brand-mark img {
  width: 29px;
  height: 29px;
  object-fit: contain;
}

.app-title {
  color: #f8fafc;
  font-size: 22px;
  font-weight: 800;
  line-height: 1.08;
}

.app-subtitle {
  margin-top: 2px;
  color: #94a3b8;
  font-size: 12px;
}

.clock-chip {
  min-width: 178px;
  border: 1px solid rgba(45, 212, 191, .28);
  border-radius: 999px;
  background: rgba(15, 23, 42, .45);
  color: #ccfbf1;
  font-size: 13px;
  font-weight: 700;
  padding: 7px 12px;
  text-align: center;
}

.panel {
  background: rgba(255, 255, 255, .96);
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(2, 6, 23, .22);
}

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

.filters {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr auto;
  gap: 12px;
}

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

.stat-card {
  width: 100%;
  position: relative;
  overflow: hidden;
  min-height: 74px;
  border: 1px solid rgba(45, 212, 191, .28);
  border-radius: 14px;
  background:
    radial-gradient(circle at top right, rgba(45, 212, 191, .32), transparent 38%),
    linear-gradient(135deg, rgba(15, 23, 42, .95), rgba(15, 118, 110, .72));
  color: #ecfeff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px;
  text-align: left;
  box-shadow: 0 20px 60px rgba(2, 6, 23, .28), inset 0 0 30px rgba(45, 212, 191, .08);
}

.stat-card:hover {
  border-color: rgba(125, 211, 252, .64);
  transform: translateY(-1px);
}

.stat-card::after {
  content: "";
  position: absolute;
  right: -40px;
  top: -40px;
  width: 92px;
  height: 92px;
  border: 1px solid rgba(125, 211, 252, .28);
  border-radius: 999px;
}

.stat-label {
  color: #99f6e4;
  font-size: 13px;
  font-weight: 700;
}

.stat-value {
  position: relative;
  z-index: 1;
  margin-top: 0;
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.stat-note {
  margin-top: 5px;
  color: #cbd5e1;
  font-size: 11px;
}

.detail-body {
  display: grid;
  grid-template-columns: minmax(260px, .9fr) minmax(420px, 1.4fr) minmax(280px, .9fr);
  gap: 16px;
  padding: 16px;
  overflow: visible;
  max-height: none;
}

.detail-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 18;
  background: rgba(15, 23, 42, .62);
  padding: 18px;
}

.detail-modal {
  width: 100%;
  height: 100%;
  overflow: auto;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 28px 90px rgba(15, 23, 42, .32);
}

.detail-modal-head {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(8px);
}

.detail-column {
  display: grid;
  gap: 16px;
  align-content: start;
}

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

.info-tile {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  padding: 12px;
}

.info-tile span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.info-tile strong {
  display: block;
  margin-top: 6px;
  color: #0f172a;
  font-size: 15px;
}

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

.file-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
}

.preview {
  aspect-ratio: 16 / 10;
  background: #f1f5f9;
  display: grid;
  place-items: center;
}

.preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.file-meta {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.file-title { display: grid; gap: 3px; }
.file-title span { color: var(--muted); font-size: 12px; }
.action-stack { display: grid; gap: 10px; }
.log-list,
.exception-list { display: grid; gap: 8px; }

.log-item,
.exception-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
  padding: 12px;
}

.empty-detail {
  min-height: 220px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(15, 23, 42, .5);
}

.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .24);
}

.wide-modal { width: min(860px, 100%); }
.admin-modal { width: min(1000px, 100%); }

.modal form {
  display: grid;
  gap: 14px;
  padding: 16px;
}

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

.upload-box {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px dashed #94a3b8;
  border-radius: 12px;
  background: #f8fafc;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.admin-body { padding: 16px; }
.admin-form textarea { min-height: 132px; }
.user-permission-list { display: grid; gap: 12px; }

.user-create-card,
.user-permission-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}

.user-create-card {
  margin-bottom: 14px;
  background: #f0fdfa;
  border-color: #99f6e4;
}

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

.permission-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.permission-grid input {
  width: auto;
  min-height: auto;
}

.account-actions,
.password-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.account-actions { justify-content: space-between; }
.password-inline input { width: 180px; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  border-radius: 12px;
  background: #0f172a;
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, .2);
}

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

@media (max-width: 760px) {
  .filters,
  .form-grid,
  .upload-grid,
  .admin-form,
  .permission-grid,
  .file-grid,
  .info-grid {
    grid-template-columns: 1fr;
  }

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

  .password-inline,
  .account-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .password-inline input { width: 100%; }

  .detail-modal-backdrop {
    padding: 8px;
  }

  .detail-modal {
    border-radius: 12px;
  }

  .detail-modal-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
