/* Tasdeer — editorial / luxury theme */
:root {
  --bg: #f5f2ea;
  --bg-soft: #ebe6d8;
  --canvas: #ffffff;
  --ink: #14171f;
  --ink-soft: #3a3f4d;
  --muted: #7a7d86;
  --line: #e3dfd0;
  --line-strong: #d4ceb8;
  --sidebar: #0b1220;
  --sidebar-line: #1c2536;
  --sidebar-ink: #d8d6cc;
  --sidebar-muted: #8a8e9c;
  --accent: #b88a3a;
  --accent-soft: #d9b977;
  --accent-dark: #8a6320;
  --good: #1f7a3a;
  --good-bg: #e3f1e6;
  --bad: #a82828;
  --bad-bg: #fbe2e2;
  --warn: #a16207;
  --warn-bg: #fbf2d6;
  --shadow-sm: 0 1px 2px rgba(20,23,31,.04), 0 0 0 1px var(--line);
  --shadow-md: 0 4px 18px rgba(20,23,31,.06), 0 0 0 1px var(--line);
  --radius: 14px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px; line-height: 1.55; color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}
.serif { font-family: 'Fraunces', 'Cormorant Garamond', Georgia, serif; }

h1, h2, h3, h4 {
  font-family: 'Fraunces', 'Cormorant Garamond', Georgia, serif;
  font-weight: 500; letter-spacing: -0.01em; margin: 0;
}
h1 { font-size: 32px; line-height: 1.15; }
h2 { font-size: 20px; margin-top: 32px; margin-bottom: 14px; font-weight: 500; color: var(--ink-soft); }
h3 { font-size: 17px; }

a { color: var(--ink); text-decoration: none; border-bottom: 1px solid transparent; transition: border-color .15s; }
a:hover { border-bottom-color: var(--accent); }

code, pre { font-family: 'JetBrains Mono', ui-monospace, Menlo, monospace; font-size: 12.5px; }
pre { background: var(--bg-soft); padding: 14px 16px; border-radius: var(--radius-sm); overflow: auto; }

/* ===== Layout ===== */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex: 0 0 240px; background: var(--sidebar); color: var(--sidebar-ink);
  padding: 28px 0; position: sticky; top: 0; height: 100vh; overflow: auto;
}
.sidebar .brand {
  padding: 0 26px 26px; border-bottom: 1px solid var(--sidebar-line); margin-bottom: 18px;
}
.sidebar .brand .mark {
  font-family: 'Fraunces', serif; font-size: 26px; font-weight: 500; color: #fff; letter-spacing: -0.01em;
}
.sidebar .brand .mark .gold { color: var(--accent-soft); }
.sidebar .brand .ar { font-family: 'Amiri', serif; color: var(--sidebar-muted); font-size: 13px; display: block; margin-top: 2px; }
.sidebar nav { display: flex; flex-direction: column; padding: 0 14px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 12px;
  color: var(--sidebar-ink); padding: 9px 12px; border-radius: 8px;
  font-size: 13.5px; border: none; margin-bottom: 2px;
  transition: background .15s, color .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.04); color: #fff; border: none; }
.sidebar nav a.active { background: rgba(217,185,119,.10); color: #fff; }
.sidebar nav a.active .icon { color: var(--accent-soft); }
.sidebar nav a .icon { width: 16px; height: 16px; color: var(--sidebar-muted); flex: 0 0 16px; }
.sidebar nav a .count {
  margin-left: auto; background: var(--accent); color: #fff;
  font-size: 11px; padding: 1px 7px; border-radius: 99px; font-weight: 600;
}
.sidebar nav .section {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--sidebar-muted); padding: 18px 12px 6px;
}
.sidebar .user-block {
  margin-top: auto; padding: 18px 26px; border-top: 1px solid var(--sidebar-line);
  font-size: 12.5px; color: var(--sidebar-muted);
}
.sidebar .user-block b { color: #fff; }
.sidebar .user-block a { color: var(--sidebar-muted); border: none; }
.sidebar .user-block a:hover { color: var(--accent-soft); border: none; }

main {
  flex: 1; padding: 36px 48px 80px; min-width: 0;
}
.page-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 24px;
  margin-bottom: 28px; padding-bottom: 18px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.page-head > div:first-child { flex: 1 1 60%; min-width: 0; }
.page-head h1 { word-break: normal; overflow-wrap: break-word; line-height: 1.2; }
.page-head .actions {
  flex: 0 1 auto; flex-wrap: wrap; justify-content: flex-end;
  gap: 8px;
}
.page-head .actions .btn,
.page-head .actions button {
  white-space: nowrap !important;
  word-break: keep-all;
  min-width: max-content;
}
/* On narrower screens, push the action row below the title for clarity */
@media (max-width: 1100px) {
  .page-head { gap: 14px; }
  .page-head > div:first-child { flex: 1 1 100%; }
  .page-head .actions { width: 100%; justify-content: flex-start; }
}
.page-head .eyebrow {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px;
}
.page-head .actions { display: flex; gap: 10px; align-items: center; }

/* ===== Cards ===== */
.card {
  background: var(--canvas); border-radius: var(--radius); padding: 22px 24px;
  box-shadow: var(--shadow-sm); margin-bottom: 18px;
}
.card.tight { padding: 18px; }
.card-title { font-family: 'Fraunces', serif; font-size: 17px; margin-bottom: 14px; color: var(--ink); }

.row { display: grid; gap: 18px; }
.row-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.row-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

/* Dashboard overview: items get the majority of the screen, alerts side-panel */
.row-2-wide { display: grid; gap: 22px; grid-template-columns: minmax(0, 2.4fr) minmax(280px, 1fr); align-items: start; }
.overview-main { min-width: 0; }
.overview-side { min-width: 0; }
@media (max-width: 1200px) {
  .row-2-wide { grid-template-columns: 1fr; }
}

/* Search + filter bar — clean grid layout (Dashboard + Items page) */
.filter-bar {
  display: grid;
  grid-template-columns: minmax(240px, 3fr) minmax(150px, 1.4fr) minmax(150px, 1.4fr) auto auto;
  gap: 12px;
  align-items: center;
  background: var(--canvas);
  padding: 18px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}
.filter-bar .filter-search,
.filter-bar select,
.filter-bar input[type=text] {
  margin: 0;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
  width: 100%;
  text-transform: none;
  letter-spacing: normal;
  font-weight: 400;
}
.filter-bar .filter-search { padding-left: 38px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%237a7d86' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
  background-repeat: no-repeat;
  background-position: 12px center;
  background-size: 16px;
}
.filter-bar .filter-search:focus,
.filter-bar select:focus,
.filter-bar input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(184,138,58,.15); }
.filter-bar button,
.filter-bar > a.btn { white-space: nowrap; margin: 0; justify-self: start; width: max-content; }
.filter-bar label.inline {
  margin: 0; padding: 0 4px;
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--ink-soft);
  text-transform: none; letter-spacing: normal; font-weight: 400;
  white-space: nowrap;
  grid-column: span 2;
}
.filter-bar label.inline input[type=checkbox] { width: auto; margin: 0 4px 0 0; }
/* Pills wrap to a dedicated row spanning the full grid */
.filter-bar .filter-pills {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; gap: 6px;
  padding-top: 14px;
  margin-top: 4px;
  border-top: 1px solid var(--line);
}
.filter-bar .filter-pills .btn { padding: 5px 12px; font-size: 12px; }

@media (max-width: 900px) {
  .filter-bar { grid-template-columns: 1fr 1fr; }
  .filter-bar .filter-search { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .filter-bar { grid-template-columns: 1fr; }
}

/* Research page: source cards grid */
.research-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px; margin-bottom: 22px;
}
.research-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--canvas); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px;
  text-decoration: none; color: var(--ink);
  transition: transform .12s, box-shadow .12s, border-color .12s;
}
.research-card:hover {
  transform: translateY(-1px); box-shadow: var(--shadow-md);
  border-color: var(--accent); text-decoration: none; border-bottom-color: var(--accent);
}
.research-card .rc-icon { font-size: 24px; line-height: 1; flex: 0 0 auto; }
.research-card .rc-body { flex: 1; min-width: 0; }
.research-card .rc-name { font-weight: 500; font-size: 14px; }
.research-card .rc-blurb { font-size: 12px; color: var(--muted); margin-top: 2px; }
.research-card .rc-arrow { color: var(--muted); font-size: 16px; flex: 0 0 auto; }

/* ===== Forms ===== */
form label { display: block; margin-bottom: 14px; font-size: 12.5px; color: var(--muted);
  letter-spacing: 0.02em; text-transform: uppercase; font-weight: 500; }
form input[type=text], form input[type=url], form input[type=email],
form input[type=number], form input[type=password],
form input:not([type]), form select, form textarea {
  display: block; width: 100%; padding: 10px 12px; margin-top: 6px;
  border: 1px solid var(--line-strong); border-radius: 8px;
  font-size: 14px; font-family: inherit; color: var(--ink);
  background: #fff; transition: border-color .15s, box-shadow .15s;
  text-transform: none; letter-spacing: normal;
}
form input:focus, form textarea:focus, form select:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(184,138,58,.15);
}
form textarea { min-height: 90px; resize: vertical; }
form input[type=checkbox] { display: inline-block; width: auto; margin-right: 8px; }
form label.inline {
  display: flex; align-items: center; text-transform: none; letter-spacing: normal;
  font-size: 14px; color: var(--ink); font-weight: 400;
}

button, .btn {
  background: var(--ink); color: #fff; border: 1px solid var(--ink);
  padding: 10px 18px; border-radius: 8px; font-size: 13.5px; font-weight: 500;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 8px;
  font-family: inherit; transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
button:hover, .btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; border-bottom-color: var(--accent-dark); }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--line-strong); }
.btn-secondary:hover { background: var(--bg); color: var(--ink); border-color: var(--ink); border-bottom-color: var(--ink); }
.btn-danger { background: #fff; color: var(--bad); border: 1px solid var(--line-strong); }
.btn-danger:hover { background: var(--bad-bg); color: var(--bad); border-color: var(--bad); border-bottom-color: var(--bad); }
.btn-gold { background: var(--accent); border-color: var(--accent); }
.btn-gold:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; white-space: nowrap !important; }

/* ===== Login ===== */
.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, #0b1220 0%, #1a253e 100%);
  padding: 24px;
}
.login-card {
  width: 380px; background: var(--canvas); border-radius: 16px;
  padding: 40px 36px; box-shadow: 0 30px 80px rgba(0,0,0,.30);
}
.login-card .mark {
  font-family: 'Fraunces', serif; font-size: 30px; color: var(--ink); margin-bottom: 4px;
}
.login-card .mark .gold { color: var(--accent); }
.login-card .ar { font-family: 'Amiri', serif; color: var(--muted); font-size: 13px; margin-bottom: 20px; display: block; }
.login-card .subtitle { color: var(--muted); font-size: 13px; margin-bottom: 28px; }
.login-card button { width: 100%; justify-content: center; padding: 12px; }

/* ===== Messages ===== */
.flash { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 13.5px; }
.flash.error { background: var(--bad-bg); color: var(--bad); }
.flash.ok { background: var(--good-bg); color: var(--good); }
.flash.warn { background: var(--warn-bg); color: var(--warn); }

/* ===== KPI tiles ===== */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 28px; }
.kpi { background: var(--canvas); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 6px; }
.kpi .label {
  font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted);
}
.kpi .value { font-family: 'Fraunces', serif; font-size: 30px; font-weight: 500; color: var(--ink); letter-spacing: -0.01em; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi .icon { color: var(--accent); width: 18px; height: 18px; }

/* ===== Tables ===== */
.tbl-wrap { background: var(--canvas); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table th { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--line);
  font-weight: 500; text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; color: var(--muted);
  background: #fafaf6; }
table td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table tr:last-child td { border-bottom: none; }
table tr:hover td { background: #faf8f1; }
table .right { text-align: right; font-variant-numeric: tabular-nums; }
table .center { text-align: center; }
table .thumb-cell img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; }
table .name a { font-weight: 500; }
table .secondary { color: var(--muted); font-size: 12px; }

/* ===== Pills ===== */
.pill { display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.05em; }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.muted { background: var(--bg-soft); color: var(--muted); }
.pill.ink { background: var(--ink); color: #fff; }
.pill.dot::before { content: ''; width: 6px; height: 6px; border-radius: 99px; background: currentColor; }

/* ===== Breakdown ===== */
.breakdown { display: grid; grid-template-columns: 1fr auto; row-gap: 8px; column-gap: 24px; font-size: 13.5px; }
.breakdown .label { color: var(--muted); }
.breakdown .value { font-variant-numeric: tabular-nums; color: var(--ink); }
.breakdown .total { border-top: 1px solid var(--line); padding-top: 10px; margin-top: 4px;
  font-weight: 600; font-family: 'Fraunces', serif; font-size: 16px; }

/* ===== Item grid ===== */
.item-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; }
.item-tile {
  background: var(--canvas); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow-sm); transition: transform .15s, box-shadow .15s;
  display: flex; flex-direction: column;
}
.item-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.item-tile .thumb { aspect-ratio: 1/1; background: var(--bg-soft) center/cover no-repeat; }
.item-tile .body { padding: 14px 16px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.item-tile .meta { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.item-tile h3 { font-size: 15px; font-weight: 500; line-height: 1.3; margin-top: 2px; }
.item-tile h3 a { border: none; color: var(--ink); }
.item-tile h3 a:hover { color: var(--accent-dark); border: none; }
.item-tile .foot { margin-top: auto; padding-top: 8px; display: flex; justify-content: space-between; align-items: center; }
.item-tile .price { font-family: 'Fraunces', serif; font-size: 18px; font-weight: 500; }

/* ===== Sparkline ===== */
.spark { display: inline-block; vertical-align: middle; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.spark .area { fill: rgba(184,138,58,.12); stroke: none; }

/* ===== Alerts feed ===== */
.alert-row { display: grid; grid-template-columns: 56px 1fr auto; gap: 18px; padding: 16px 20px;
  border-bottom: 1px solid var(--line); align-items: center; }
.alert-row:last-child { border-bottom: none; }
.alert-row.unread { background: #fbf8ec; }
.alert-row .thumb { width: 56px; height: 56px; border-radius: 8px; background: var(--bg-soft) center/cover no-repeat; }
.alert-row .body .title { font-weight: 500; margin-bottom: 2px; }
.alert-row .body .msg { color: var(--ink-soft); font-size: 13px; }
.alert-row .body .meta { font-size: 11px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.08em; }
.alert-row .actions { display: flex; gap: 6px; align-items: center; }

/* ===== Misc ===== */
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; align-items: center; }
.muted-block { color: var(--muted); font-size: 13px; }
.divider { height: 1px; background: var(--line); margin: 22px 0; }

hr { border: none; height: 1px; background: var(--line); margin: 24px 0; }

@media (max-width: 900px) {
  .sidebar { width: 70px; flex: 0 0 70px; }
  .sidebar .brand .mark, .sidebar .brand .ar, .sidebar nav a span:not(.icon),
  .sidebar nav .section, .sidebar .user-block { display: none; }
  .sidebar nav a { justify-content: center; }
  main { padding: 24px; }
}
