/* ===================================================
   PrintStack — Clean Light Theme
   Space Mono + DM Sans | White background, black text
   =================================================== */

:root {
  --bg: #f5f6f8;
  --bg-card: #ffffff;
  --bg-elevated: #f0f1f4;
  --border: #e0e3ea;
  --border-mid: #c8cdd8;
  --text: #111318;
  --text-muted: #5a6070;
  --text-dim: #9aa0b0;
  --accent: #2563eb;
  --accent-dim: #1d4ed8;
  --green: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --purple: #7c3aed;
  --radius: 6px;
  --radius-lg: 10px;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --mono: 'Space Mono', monospace;
  --sans: 'DM Sans', sans-serif;
}

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

html {
  font-size: 15px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ---- Navbar ---- */

.navbar {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 0 2rem;
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  letter-spacing: 0.05em;
  text-decoration: none;
}

.brand-icon {
  font-size: 1.3rem;
  color: var(--accent);
}

.nav-links {
  display: flex;
  gap: 0.25rem;
  flex: 1;
}

.nav-link {
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
}

.nav-link:hover,
.nav-link.active {
  background: var(--bg-elevated);
  color: var(--text);
  text-decoration: none;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-left: auto;
}

.user-name {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-family: var(--mono);
}

.btn-logout {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.15s;
}

.btn-logout:hover {
  color: var(--danger);
  border-color: var(--danger);
  text-decoration: none;
}

/* ---- Main Content ---- */

.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem;
}

/* ---- Page Header ---- */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2rem;
}

.page-title {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.header-actions {
  display: flex;
  gap: 0.75rem;
}

/* ---- Buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  border: none;
  border-radius: var(--radius);
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--accent-dim);
  color: #fff;
  text-decoration: none;
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border-mid);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  text-decoration: none;
}

.btn-success {
  background: var(--green);
  color: #fff;
}

.btn-success:hover {
  opacity: 0.85;
  text-decoration: none;
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  text-decoration: none;
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.8rem;
}

.btn-login {
  width: 100%;
  justify-content: center;
  padding: 0.75rem;
  font-size: 1rem;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: var(--radius);
  font-size: 1rem;
  transition: background 0.15s;
}

.btn-icon:hover {
  background: var(--bg-elevated);
}

.w-full {
  width: 100%;
}

/* ---- Stats Grid ---- */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 2rem;
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  transition: border-color 0.15s;
  box-shadow: var(--shadow);
}

.stat-card:hover {
  border-color: var(--border-mid);
}

.stat-card--warn {
  border-color: var(--warn);
}

.stat-value {
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---- Sections ---- */

.section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.section-title {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.link-more {
  font-size: 0.85rem;
  color: var(--accent);
}

/* ---- Alert List (Low Stock) ---- */

.alert-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.alert-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: #fffbeb;
  border: 1px solid var(--warn);
  border-radius: var(--radius);
}

.alert-info {
  flex: 1;
  font-size: 0.875rem;
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.owner-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 0.1rem 0.4rem;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* ---- Owner Groups ---- */

.owner-group {
  margin-bottom: 1.25rem;
}

.owner-group:last-child {
  margin-bottom: 0;
}

.owner-group-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}

.owner-avatar,
.owner-avatar-sm {
  width: 28px;
  height: 28px;
  background: var(--purple);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  flex-shrink: 0;
}

.owner-avatar-sm {
  width: 22px;
  height: 22px;
  font-size: 0.65rem;
}

.owner-group-name {
  font-weight: 600;
  font-size: 0.9rem;
}

.owner-count {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* ---- Filament Chips (Dashboard) ---- */

.filament-row {
  /* display: flex; */
  flex-wrap: wrap;
  gap: 0.5rem;
}

.filament-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 180px;
  max-width: 240px;
  flex: 1;
  transition: border-color 0.15s;
}

.filament-chip:hover {
  border-color: var(--border-mid);
}

.chip-empty {
  opacity: 0.5;
}

.chip-swatch,
.swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(0, 0, 0, 0.1);
}

.swatch-lg {
  width: 22px;
  height: 22px;
}

.chip-info {
  flex: 1;
  min-width: 0;
}

.chip-name {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip-color {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.chip-bar,
.filament-bar-small,
.progress-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.chip-bar {
  width: 50px;
}

.filament-bar-small {
  width: 80px;
}

.chip-fill,
.filament-bar-fill,
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}

.chip-weight {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.pct-label {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.fill-ok {
  background: var(--green);
}

.fill-warn {
  background: var(--warn);
}

.fill-critical {
  background: var(--danger);
}

/* ---- Shopping Preview (Dashboard) ---- */

.shopping-preview-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
}

.shopping-preview-item:last-child {
  border-bottom: none;
}

.priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.priority-dot--high {
  background: var(--danger);
}

.priority-dot--medium {
  background: var(--warn);
}

.priority-dot--low {
  background: var(--text-dim);
}

.shopping-name {
  flex: 1;
  font-weight: 500;
}

.shopping-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.shopping-price {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--green);
}

/* ---- Filter Bar ---- */

.filter-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.filter-search {
  flex: 1;
  min-width: 200px;
}

.filter-select {
  width: 160px;
}

/* ---- Data Table ---- */

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.data-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  white-space: nowrap;
}

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: var(--bg-elevated);
}

.row-empty td {
  opacity: 0.45;
}

.color-cell {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.owner-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.weight-cell {
  font-family: var(--mono);
  font-size: 0.85rem;
}

.weight-total {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.progress-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.progress-bar {
  width: 80px;
}

.actions-cell {
  white-space: nowrap;
}

.date-text {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.empty-row {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
}

/* ---- Badges ---- */

.badge {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.72rem;
  font-family: var(--mono);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-material {
  background: #eff6ff;
  color: var(--accent);
  border: 1px solid #bfdbfe;
}

.count-badge {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0.1rem 0.5rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-family: var(--mono);
  color: var(--text-muted);
}

.priority-badge {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-family: var(--mono);
  font-weight: 700;
  text-transform: uppercase;
}

.priority-badge--high {
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fecaca;
}

.priority-badge--medium {
  background: #fffbeb;
  color: var(--warn);
  border: 1px solid #fde68a;
}

.priority-badge--low {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* ---- Shopping Cards ---- */

.shopping-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.shopping-list--purchased {
  opacity: 0.6;
}

.shopping-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border);
  border-radius: var(--radius);
  gap: 1rem;
  box-shadow: var(--shadow);
}

.priority-border--high {
  border-left-color: var(--danger);
}

.priority-border--medium {
  border-left-color: var(--warn);
}

.priority-border--low {
  border-left-color: var(--text-dim);
}

.shopping-card--done {
  background: var(--bg-elevated);
}

.shopping-card-main {
  flex: 1;
}

.shopping-card-top {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.shopping-item-name {
  font-weight: 600;
  font-size: 0.95rem;
  flex: 1;
}

.shopping-desc {
  color: var(--text-muted);
  font-size: 0.83rem;
  margin-bottom: 0.5rem;
}

.shopping-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.meta-chip {
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-muted);
  font-family: var(--mono);
}

.shopping-card-actions {
  display: flex;
  gap: 0.4rem;
  align-items: flex-start;
  flex-shrink: 0;
}

.link-external {
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
}

.link-external:hover {
  color: var(--accent);
}

/* ---- Forms ---- */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 0;
}

.form-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--mono);
}

.form-input,
.form-select {
  background: var(--bg-card);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font-family: var(--sans);
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

.form-input:focus,
.form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-input::placeholder {
  color: var(--text-dim);
}

.form-color {
  width: 100%;
  height: 40px;
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  background: var(--bg-card);
  cursor: pointer;
  padding: 2px;
}

.form-textarea {
  min-height: 80px;
  resize: vertical;
}

/* ---- Modals ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-sm {
  max-width: 380px;
}

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

.modal-header h3 {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
  border-radius: var(--radius);
  transition: all 0.15s;
}

.modal-close:hover {
  background: var(--bg-elevated);
  color: var(--text);
}

.modal-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-desc {
  color: var(--text-muted);
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
  background: #eff6ff;
  border-radius: var(--radius);
  border-left: 3px solid var(--accent);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* ---- Alerts ---- */

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
}

/* ---- Empty State ---- */

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

/* ---- Login Page ---- */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
  position: relative;
  background: var(--bg);
}

.login-container {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 420px;
  padding: 2rem 1rem;
}

.login-brand {
  text-align: center;
  margin-bottom: 2rem;
}

.brand-icon-large {
  font-size: 3rem;
  color: var(--accent);
  display: block;
  margin-bottom: 0.5rem;
}

.login-brand h1 {
  font-family: var(--mono);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text);
}

.login-brand p {
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  text-align: center;
  margin-bottom: 1.25rem;
}

.login-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.75rem;
  margin-top: 1.5rem;
  font-family: var(--mono);
}

/* Background grid pattern */
.login-bg {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.grid-pattern {
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(rgba(37, 99, 235, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(37, 99, 235, 0.04) 1px, transparent 1px);
  background-size: 40px 40px;
}