:root {
  --bg: #f2f4f8;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #475569;
  --accent: #0f766e;
  --accent-soft: #d1fae5;
  --border: #dbe3ea;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, #e0f2fe 0%, rgba(224, 242, 254, 0) 40%),
    radial-gradient(circle at bottom left, #fef9c3 0%, rgba(254, 249, 195, 0) 35%),
    var(--bg);
  min-height: 100vh;
}

header {
  padding: 2rem 1rem 1rem;
  text-align: center;
}

header h1 {
  margin: 0;
  font-size: 2rem;
}

header p {
  margin-top: 0.5rem;
  color: var(--muted);
}

main {
  width: min(1200px, 92vw);
  margin: 0 auto 2rem;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.role-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.role-card {
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.role-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.1);
}

.home-link {
  display: inline-block;
  margin-top: 0.75rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.home-link:hover {
  text-decoration: underline;
}

.logout-btn {
  margin-top: 0.75rem;
  width: auto;
  display: inline-block;
  padding: 0.5rem 0.9rem;
}

.hint {
  color: var(--muted);
  margin: 0.5rem 0;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
}

h2 {
  margin-top: 0;
  font-size: 1.05rem;
}

form {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

input,
select,
textarea,
button {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font: inherit;
}

button {
  background: linear-gradient(120deg, var(--accent), #0ea5a3);
  border: none;
  color: #ffffff;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  filter: brightness(1.05);
}

.output {
  margin-top: 0.65rem;
  background: #ffffff;
  border: 1px solid #d5dee8;
  border-radius: 10px;
  padding: 0.6rem;
  max-height: 300px;
  overflow: auto;
}

.output table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.output th,
.output td {
  border: 1px solid #e2e8f0;
  padding: 0.45rem 0.5rem;
  text-align: left;
  vertical-align: top;
}

.output th {
  background: #f1f5f9;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

.output .section-title {
  margin: 0.4rem 0 0.25rem;
  color: #0f172a;
  font-size: 0.92rem;
}

.output .message-ok {
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  background: #ecfeff;
  color: #155e75;
  border: 1px solid #a5f3fc;
}

.output .message-error {
  padding: 0.4rem 0.5rem;
  border-radius: 8px;
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.output .muted {
  color: #64748b;
  font-size: 0.86rem;
}

.output tr.row-sold td {
  background: #dbeafe;
}

.output tr.row-partial td {
  background: #fef9c3;
}

.alloc-box {
  border: 1px solid #dbe3ea;
  border-radius: 8px;
  padding: 0.6rem;
  background: #f8fafc;
}

.alloc-title {
  font-weight: 600;
  font-size: 0.92rem;
}

.alloc-hint {
  color: #64748b;
  font-size: 0.84rem;
  margin-top: 0.2rem;
}

.alloc-grid {
  margin-top: 0.55rem;
  display: grid;
  gap: 0.45rem;
}

.alloc-row {
  display: grid;
  grid-template-columns: 1fr 28px 120px auto;
  gap: 0.45rem;
  align-items: center;
}

.alloc-consignment {
  font-weight: 600;
  color: #1e293b;
}

.alloc-x {
  text-align: center;
  color: #475569;
  font-weight: 600;
}

.alloc-available {
  color: #475569;
  font-weight: 600;
  white-space: nowrap;
}

.dashboard-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.45rem;
  margin-top: 0.6rem;
}

.summary-chip {
  border: 1px solid #dbe3ea;
  border-radius: 10px;
  padding: 0.5rem;
  background: #f8fafc;
}

.summary-chip .label {
  display: block;
  color: #64748b;
  font-size: 0.82rem;
}

.summary-chip .value {
  display: block;
  margin-top: 0.15rem;
  font-weight: 700;
  font-size: 1rem;
  color: #0f172a;
}

.dashboard-pie {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  margin: 0.85rem auto 0.35rem;
  border: 1px solid #cbd5e1;
  background: #e2e8f0;
}

.dashboard-pies {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.8rem;
  margin-top: 0.5rem;
}

.dashboard-pie-card {
  border: 1px solid #dbe3ea;
  border-radius: 10px;
  padding: 0.55rem;
  background: #ffffff;
}

.dashboard-pie-card h3 {
  margin: 0.1rem 0 0.2rem;
  font-size: 0.95rem;
  color: #0f172a;
}

.dashboard-legend {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 0.45rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: #334155;
  font-size: 0.9rem;
}

.legend-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.selfie-box {
  border: 1px solid #dbe3ea;
  border-radius: 10px;
  background: #f8fafc;
  padding: 0.6rem;
}

.selfie-head {
  font-weight: 600;
  margin-bottom: 0.45rem;
}

.selfie-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.45rem;
  margin-bottom: 0.45rem;
}

.selfie-video,
.selfie-image {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #0f172a;
}

.selfie-image {
  background: #ffffff;
}

.selfie-preview-wrap {
  position: relative;
  width: 100%;
  max-height: 220px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  background: #0f172a;
}

.selfie-preview-wrap .selfie-video {
  display: block;
  max-height: 220px;
  border: none;
}

.selfie-guide {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.selfie-guide::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 62%;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border: 3px solid rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.32);
}

.print-card {
  border: 1px solid #dbe3ea;
  border-radius: 10px;
  padding: 0.8rem;
  background: #ffffff;
}

.print-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.print-subtitle {
  font-weight: 600;
  margin: 0.55rem 0 0.35rem;
}

.print-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.35rem 0.8rem;
}

.print-selfie-wrap {
  margin-top: 0.45rem;
}

.print-selfie {
  width: 180px;
  height: 220px;
  object-fit: cover;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
}

.print-actions {
  margin-top: 0.55rem;
}

@media print {
  @page {
    size: 80mm auto;
    margin: 2mm;
  }

  body * {
    visibility: hidden;
  }

  #signupPrintCard,
  #signupPrintCard * {
    visibility: visible;
  }

  #signupPrintCard {
    position: absolute;
    left: 0;
    top: 0;
    width: 76mm;
    border: none;
    box-shadow: none;
    padding: 2mm;
    font-size: 10pt;
  }

  #signupPrintCard .print-grid {
    grid-template-columns: 1fr;
    gap: 1.5mm;
  }

  #signupPrintCard .print-title {
    font-size: 12pt;
    margin-bottom: 2mm;
  }

  #signupPrintCard .print-subtitle {
    margin: 2mm 0 1.2mm;
  }

  #signupPrintCard .print-selfie {
    width: 50mm;
    height: 62mm;
  }
}

@media (max-width: 640px) {
  header h1 {
    font-size: 1.4rem;
  }
}
