*, *::before, *::after {
  box-sizing: border-box;
}

:root {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --primary: #0f4c81;
  --primary-hover: #0b3963;
  --primary-light: #e0effc;
  --secondary: #e2e8f0;
  --secondary-hover: #cbd5e1;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --success: #15803d;
  --success-bg: #dcfce7;
  --info: #1d4ed8;
  --info-bg: #dbeafe;
  --warning: #b45309;
  --warning-bg: #fef3c7;
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.14);
  --radius: 10px;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg);
  color: var(--text-main);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
  transition: background-color 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
}

button:active {
  transform: scale(0.99);
}

button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.hidden {
  display: none !important;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--text-main);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--secondary-hover);
}

.btn-outline-light {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.28);
  padding: 8px 12px;
  font-size: 13px;
}

.btn-outline-light:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.22);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-edit {
  background: #e2e8f0;
  color: #1e293b;
}

.btn-edit:hover {
  background: #cbd5e1;
}

.btn-delete {
  background: var(--danger-bg);
  color: var(--danger);
}

.btn-delete:hover {
  background: #fecaca;
}

/* Entry / Auth Screen */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #0f172a 0%, #0f4c81 100%);
}

.auth-card {
  background: var(--surface);
  padding: 32px 28px;
  border-radius: 16px;
  width: 100%;
  max-width: 450px;
  box-shadow: var(--shadow-lg);
}

.brand-badge {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: 12px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
}

.auth-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  text-align: center;
  color: var(--text-main);
}

.auth-subtitle {
  margin: 0 0 20px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

.step-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 18px;
  font-size: 13px;
}

.step-badge {
  font-weight: 700;
  color: var(--primary);
}

.connected-project {
  font-size: 12px;
  color: var(--success);
  font-weight: 600;
  max-width: 210px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field {
  margin-bottom: 15px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: #334155;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  background: #ffffff;
  color: var(--text-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 76, 129, 0.14);
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.auth-note {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* Header */
header {
  background: #0f172a;
  color: #ffffff;
  padding: 16px 24px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  max-width: 1480px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.header-title h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}

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

.user-pill {
  font-size: 13px;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 12px;
  border-radius: 999px;
}

/* Container */
.container {
  max-width: 1480px;
  margin: 0 auto;
  padding: 24px;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--surface);
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.stat-card span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-card strong {
  display: block;
  font-size: 28px;
  font-weight: 700;
  margin-top: 6px;
  color: var(--text-main);
}

.stat-card.sticker-accent strong { color: var(--success); }
.stat-card.sign-accent strong { color: var(--info); }
.stat-card.pending-accent strong { color: var(--warning); }

/* Toolbar / Filters */
.toolbar {
  background: var(--surface);
  padding: 18px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

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

.toolbar-top h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

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

.filters-grid input, .filters-grid select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  background: #ffffff;
}

.filters-grid input:focus, .filters-grid select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Table Section */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.section-header h2 {
  margin: 0;
  font-size: 18px;
}

.record-count {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.table-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

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

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

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

th {
  background: var(--surface-alt);
  color: #475569;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

tbody tr:hover {
  background-color: #f8fafc;
}

.notes-cell {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
}

.actions-cell {
  white-space: nowrap;
  display: flex;
  gap: 6px;
}

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-sticker {
  background: var(--success-bg);
  color: var(--success);
}

.badge-sign {
  background: var(--info-bg);
  color: var(--info);
}

.badge-processing {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-hold {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Empty & Loading States */
.state-box {
  padding: 42px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  background: var(--surface);
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 14px;
  padding: 26px;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.close-icon {
  background: transparent;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--text-muted);
  padding: 4px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

/* Alerts & Toast */
.error-text {
  color: var(--danger);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

.info-text {
  color: var(--success);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #0f172a;
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
}

.toast.toast-error {
  background: var(--danger);
}

/* Responsive */
@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 680px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .header-right {
    width: 100%;
    justify-content: space-between;
  }

  .container {
    padding: 14px;
  }

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

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

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