/* =====================================================
   Smart Price Compare V-1.0  —  Stylesheet
   Clean white theme, mobile-responsive.
   Theme color poriborton korte nicher --primary value ti
   change korlei pura site-er rong bodle jabe.
   ===================================================== */

:root {
  --primary:      #1d4ed8;
  --primary-dark: #1742a8;
  --primary-soft: #eef2ff;
  --bg:           #f4f6fb;
  --card:         #ffffff;
  --text:         #1f2937;
  --muted:        #6b7280;
  --border:       #e5e7eb;
  --green:        #16a34a;
  --green-soft:   #dcfce7;
  --red:          #dc2626;
  --red-soft:     #fee2e2;
  --amber:        #d97706;
  --amber-soft:   #fef3c7;
  --gray-soft:    #f1f5f9;
  --radius:       12px;
  --shadow:       0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px; height: 60px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; font-size: 17px; color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--primary); color: #fff; font-size: 17px;
}
#mainnav { display: flex; align-items: center; gap: 4px; }
#mainnav a {
  color: var(--muted); font-weight: 500;
  padding: 8px 14px; border-radius: 8px;
}
#mainnav a:hover { background: var(--gray-soft); color: var(--text); text-decoration: none; }
#mainnav a.active { background: var(--primary-soft); color: var(--primary); }
#mainnav a.logout { color: var(--red); }
.nav-toggle {
  display: none; background: none; border: none;
  font-size: 24px; cursor: pointer; color: var(--text);
}

/* ---------- Layout ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 22px 18px 60px; }
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; margin-bottom: 18px; flex-wrap: wrap;
}
.page-head h1 { font-size: 22px; margin: 0; }
.subtitle { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.section-title { font-size: 16px; margin: 26px 0 12px; color: var(--text); }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 18px;
}
.card-title { font-size: 15px; margin: 0 0 14px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

/* ---------- Stat boxes ---------- */
.stat-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: 18px;
}
.stat-box {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; display: flex; flex-direction: column; gap: 6px;
}
.stat-box.clickable { cursor: pointer; transition: transform .08s, box-shadow .12s; }
.stat-box.clickable:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(16,24,40,.1); text-decoration: none; }
.stat-box.sel { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.stat-label { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.stat-value { font-size: 24px; font-weight: 700; }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-amber { color: var(--amber); }
.text-gray { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; cursor: pointer;
  font-size: 14px; font-weight: 600; line-height: 1;
  padding: 10px 16px; border-radius: 8px;
  border: 1px solid transparent; text-align: center;
  transition: background .12s, border-color .12s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-light { background: #fff; color: var(--text); border-color: var(--border); }
.btn-light:hover { background: var(--gray-soft); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: #fbcaca; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
.form-grid { display: flex; flex-direction: column; gap: 14px; }
.form-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 13.5px; font-weight: 600; color: var(--text); }
input[type="text"], input[type="url"], input[type="number"],
input[type="password"], select {
  font: inherit; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.check { flex-direction: row; align-items: center; gap: 8px; }
.check input { width: auto; }
.hint { color: var(--muted); font-size: 12.5px; }
.form-actions { display: flex; gap: 10px; padding-top: 4px; }

/* inline add-link form */
.inline-grid {
  display: grid; grid-template-columns: 200px 1fr 140px auto;
  gap: 12px; align-items: end;
}
.inline-grid .grow { min-width: 0; }
.inline-grid .end { display: flex; align-items: end; }

/* ---------- Tables ---------- */
.table-wrap {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  overflow-x: auto; margin-bottom: 14px;
}
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left; padding: 13px 14px;
  background: #fafbfc; border-bottom: 1px solid var(--border);
  font-size: 12.5px; text-transform: uppercase; letter-spacing: .02em;
  color: var(--muted); white-space: nowrap;
}
.data-table td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: #fbfcfe; }
.data-table .right { text-align: right; }
.data-table .center { text-align: center; }
.data-table .strong, .strong { font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.actions { white-space: nowrap; display: flex; gap: 6px; justify-content: center; }
.url-cell a { white-space: nowrap; }
.comp-mini { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* row tint */
.row-red    { background: linear-gradient(90deg, var(--red-soft) 0 4px, transparent 4px); }
.row-green  { background: linear-gradient(90deg, var(--green-soft) 0 4px, transparent 4px); }
.row-amber  { background: linear-gradient(90deg, var(--amber-soft) 0 4px, transparent 4px); }

/* mini update-price form inside table */
.mini-form { display: flex; gap: 6px; align-items: center; justify-content: center; }
.mini-form input { width: 90px; padding: 6px 8px; font-size: 13px; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge.tiny { font-size: 11px; padding: 2px 7px; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red   { background: var(--red-soft);   color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-blue  { background: var(--primary-soft); color: var(--primary); }
.badge-gray  { background: var(--gray-soft); color: var(--muted); }

/* ---------- Filter bar ---------- */
.filter-bar { padding: 14px 18px; }
.filter-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filter-form input[type="text"] { max-width: 260px; }
.filter-form select { max-width: 200px; }

/* ---------- Flash ---------- */
.flash {
  padding: 12px 16px; border-radius: 9px; margin-bottom: 16px;
  font-weight: 500; font-size: 14px;
}
.flash-success { background: var(--green-soft); color: var(--green); }
.flash-error   { background: var(--red-soft); color: var(--red); }

/* ---------- Footer ---------- */
.site-footer {
  text-align: center; color: var(--muted); font-size: 13px;
  padding: 24px; border-top: 1px solid var(--border); margin-top: 20px;
}

/* ---------- Login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; background: var(--bg); }
.login-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: 0 8px 30px rgba(16,24,40,.1);
  padding: 34px 30px; width: 100%; max-width: 360px; text-align: center;
}
.login-logo .brand-mark { width: 48px; height: 48px; font-size: 24px; margin: 0 auto 14px; }
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.login-card form { text-align: left; display: flex; flex-direction: column; gap: 6px; }
.login-card label { font-size: 13px; font-weight: 600; margin-top: 8px; }
.login-card .btn { margin-top: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .form-two { grid-template-columns: 1fr; }
  .inline-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .nav-toggle { display: block; }
  #mainnav {
    display: none; position: absolute; top: 60px; left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--card); border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow); padding: 8px;
  }
  #mainnav.open { display: flex; }
  #mainnav a { padding: 12px 14px; border-radius: 8px; }

  /* stacked card tables */
  .table-wrap { overflow: visible; background: transparent; border: none; box-shadow: none; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    margin-bottom: 12px; padding: 6px 4px;
  }
  .data-table tr:hover { background: var(--card); }
  .data-table td {
    display: flex; justify-content: space-between; align-items: center;
    gap: 12px; padding: 9px 14px; border-bottom: 1px solid var(--border);
    text-align: right;
  }
  .data-table td:last-child { border-bottom: none; }
  .data-table td::before {
    content: attr(data-label);
    font-size: 12px; font-weight: 600; color: var(--muted);
    text-transform: uppercase; text-align: left;
  }
  .data-table td[data-label=""]::before { content: ""; }
  .data-table .right, .data-table .center { text-align: right; }
  .actions { justify-content: flex-end; }
  .mini-form { justify-content: flex-end; }
  .row-red, .row-green, .row-amber { background: var(--card); }
  .row-red    { border-left: 4px solid var(--red); }
  .row-green  { border-left: 4px solid var(--green); }
  .row-amber  { border-left: 4px solid var(--amber); }
}
@media (max-width: 460px) {
  .stat-row { grid-template-columns: 1fr; }
  .inline-grid { grid-template-columns: 1fr; }
}

/* ---------- Phase 2 additions ---------- */
.fetch-actions { margin: 4px 0 14px; }
.mini-table { font-size: 14px; margin-top: 10px; }
.code-block {
  display: block; background: #0f172a; color: #e2e8f0;
  padding: 12px 14px; border-radius: 8px; font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all; margin: 6px 0;
}

/* ---------- Phase 4: scorecard ---------- */
.scorecard { padding: 18px 20px; }
.scorecard-head { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.scorecard-rate { font-size: 38px; font-weight: 700; line-height: 1; color: var(--text); }
.scorecard-sub { font-size: 13px; color: var(--muted); padding-bottom: 5px; }
.seg-bar { display: flex; height: 16px; border-radius: 6px; overflow: hidden; background: var(--gray-soft); margin-bottom: 10px; }
.seg { height: 100%; }
.seg-green { background: var(--green); }
.seg-amber { background: var(--amber); }
.seg-red { background: var(--red); }
.seg-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; color: var(--muted); }
.seg-legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; }
.dot-green { background: var(--green); }
.dot-amber { background: var(--amber); }
.dot-red { background: var(--red); }
