/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #1e3a5f;
  --primary-hover: #162d4a;
  --accent:     #2563eb;
  --success:    #16a34a;
  --warning:    #d97706;
  --danger:     #dc2626;
  --neutral:    #64748b;
  --bg:         #f1f5f9;
  --bg-card:    #ffffff;
  --border:     #e2e8f0;
  --text:       #1e293b;
  --text-muted: #94a3b8;
  --radius:     8px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

html { font-size: 15px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ===== Navbar ===== */
.navbar {
  background: var(--primary);
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 4px rgba(0,0,0,.15);
}

.navbar-brand a {
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.3px;
}
.navbar-brand a:hover { color: #cbd5e1; }

.navbar-subtitle {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.75rem;
  color: #94a3b8;
  font-weight: 400;
}

.navbar-links {
  display: flex;
  list-style: none;
  gap: 4px;
  align-items: center;
}

.navbar-links a {
  color: #cbd5e1;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.navbar-links a:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.navbar-links a.active { background: rgba(255,255,255,.18); color: #fff; }

.btn-logout {
  margin-left: 8px;
  background: rgba(220,38,38,.15) !important;
  color: #fca5a5 !important;
  border: 1px solid rgba(220,38,38,.3);
}
.btn-logout:hover { background: rgba(220,38,38,.3) !important; }

/* ===== Layout ===== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 768px) { .detail-grid { grid-template-columns: 1fr; } }

/* ===== Stats Bar ===== */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  text-align: center;
  box-shadow: var(--shadow);
}

.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-value-lg { font-size: 1.5rem; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.5px; }

.stat-card-highlight {
  background: var(--primary);
  border-color: var(--primary);
}
.stat-card-highlight .stat-value { color: #fff; }
.stat-card-highlight .stat-label { color: rgba(255,255,255,0.75); }

/* ===== Cards ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.card-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.card-body { padding: 20px; }
.card-form { padding: 28px; }
.card-form.card { overflow: visible; }

/* ===== Tables ===== */
.table-responsive { overflow-x: auto; }

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

.table th {
  background: #f8fafc;
  padding: 10px 14px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--neutral);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfc; }
.table tfoot td { background: #f8fafc; border-top: 2px solid var(--border); }

.row-leader { background: #f0fdf4 !important; }
.row-leader:hover { background: #dcfce7 !important; }

.td-thumb { width: 64px; }
.td-money { white-space: nowrap; font-variant-numeric: tabular-nums; }
.td-rank { width: 40px; font-weight: 600; color: var(--neutral); }
.td-center { text-align: center; }
.td-actions { white-space: nowrap; text-align: right; }
.text-right { text-align: right; }

.table-total td { font-size: 0.95rem; padding: 14px; }

/* ===== Images ===== */
.thumb {
  width: 52px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
  display: block;
}

.thumb-placeholder {
  width: 52px;
  height: 40px;
  background: #f1f5f9;
  border-radius: 4px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.article-image {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  display: block;
}

.no-image {
  background: #f1f5f9;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.preview-img {
  max-width: 200px;
  max-height: 150px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: block;
  margin-top: 6px;
}

.current-image { margin-bottom: 8px; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef9c3; color: #a16207; }
.badge-neutral { background: #f1f5f9; color: #475569; }
.badge-ok      { background: #dbeafe; color: #1d4ed8; }
.badge-defect  { background: #fce7f3; color: #9d174d; }

/* ===== Status Boxes ===== */
.status-box {
  border-radius: var(--radius);
  padding: 16px 18px;
  border: 1px solid;
}

.status-none    { background: #f8fafc; border-color: var(--border); }
.status-leading { background: #f0fdf4; border-color: #86efac; }
.status-below   { background: #fffbeb; border-color: #fde68a; }

.status-label   { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.8px; font-weight: 700; color: var(--neutral); margin-bottom: 6px; }
.status-leading .status-label { color: #15803d; }
.status-below .status-label   { color: #a16207; }

.status-bidder  { font-size: 1.05rem; font-weight: 600; margin-bottom: 4px; }
.status-amount  { font-size: 1.1rem; color: var(--text); font-weight: 600; }
.status-total   { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }
.status-qty     { font-size: 0.85rem; color: var(--text-muted); }
.status-sub     { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

/* ===== Info List ===== */
.info-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
.info-list dt { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.4px; align-self: center; }
.info-list dd { color: var(--text); }
.money-value { font-size: 1.1rem; font-weight: 600; color: var(--primary); }

/* ===== Forms ===== */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
  -webkit-appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.form-group-narrow { max-width: 140px; }
.form-group-wide   { flex: 2; }
.form-group-action { max-width: 120px; }

.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 4px; }
.required   { color: var(--danger); }

.form-section { margin-bottom: 28px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.form-section:last-of-type { border-bottom: none; }
.form-section-title { font-size: 1rem; font-weight: 600; color: var(--primary); margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid var(--border); }

.form-actions { display: flex; gap: 10px; padding-top: 8px; align-items: center; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

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

.btn-secondary { background: #e2e8f0; color: var(--primary); border-color: #cbd5e1; }
.btn-secondary:hover { background: #cbd5e1; text-decoration: none; }

.btn-ghost     { background: transparent; color: var(--neutral); border-color: var(--border); }
.btn-ghost:hover { background: #f1f5f9; color: var(--text); text-decoration: none; }

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

.btn-sm        { padding: 5px 12px; font-size: 0.82rem; }
.btn-block     { width: 100%; justify-content: center; }

.btn-add-row {
  margin-top: 4px;
  border-style: dashed;
}

/* ===== Bid Item Rows ===== */
.bid-item-row {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.bid-item-grid {
  display: grid;
  grid-template-columns: 2fr auto 120px 140px 150px 100px;
  gap: 12px;
  align-items: end;
}

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

.bid-item-info { font-size: 0.8rem; }
.article-hint  { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 4px; }

/* ===== Alerts ===== */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid;
}
.alert-success { background: #f0fdf4; color: #15803d; border-color: #86efac; }
.alert-error   { background: #fef2f2; color: #b91c1c; border-color: #fca5a5; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }

/* ===== Empty States ===== */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.empty-state p { color: var(--text-muted); margin-bottom: 16px; font-size: 1rem; }

.empty-state-inline {
  padding: 32px 24px;
  text-align: center;
}
.empty-state-inline p { color: var(--text-muted); margin-bottom: 12px; }

/* ===== Misc ===== */
.text-muted  { color: var(--text-muted); }
.text-small  { font-size: 0.82rem; }
.link-strong { color: var(--text); font-weight: 500; }
.link-strong:hover { color: var(--accent); }

.divider { border: none; border-top: 1px solid var(--border); margin: 24px 0; }

.danger-zone {
  padding: 20px;
  border-radius: var(--radius);
  background: #fef2f2;
  border: 1px solid #fecaca;
}
.danger-zone h3 { color: var(--danger); font-size: 0.95rem; margin-bottom: 8px; }

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 24px;
  font-size: 0.8rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg-card);
  margin-top: auto;
}

/* ===== Login Page ===== */
.login-page {
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 24px;
}

.login-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 40px rgba(0,0,0,.25);
  overflow: hidden;
}

.login-header {
  background: var(--primary);
  color: #fff;
  text-align: center;
  padding: 32px 24px;
}
.login-header h1 { font-size: 1.4rem; font-weight: 700; }
.login-header p  { font-size: 0.9rem; color: #94a3b8; margin-top: 4px; }

.login-form { padding: 28px; }
.login-form .form-group { margin-bottom: 20px; }

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .navbar { padding: 0 16px; }
  .navbar-subtitle { display: none; }
  .container { padding: 16px 16px 40px; }
  .page-header { flex-direction: column; }
  .form-row { grid-template-columns: 1fr; }
  .form-group-narrow { max-width: 100%; }
  .stats-bar { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}
