/* Rianni Tech house style: dark surfaces, warm amber→pink gradient accents.
   Palette mirrors riannitech.com's design tokens. */
:root {
  --bg: #0a0a0f;
  --bg-deep: #050509;
  --surface: #11111a;
  --surface-elevated: #181823;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f5f7;
  --muted: #9b9bab;
  --accent: #f59e0b;
  --accent-2: #ec4899;
  --gradient-warm: linear-gradient(135deg, #f59e0b 0%, #ec4899 100%);
  --gradient-warm-soft: linear-gradient(135deg, rgba(245, 158, 11, 0.16) 0%, rgba(236, 72, 153, 0.16) 100%);
  --danger: #f87171;
  --ok: #4ade80;
  --warn: #fbbf24;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --font-display: "Space Grotesk", "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }

/* ---- app shell ---- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 210px;
  flex-shrink: 0;
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 16px 10px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  padding: 4px 10px 16px;
  color: var(--text);
}
.sidebar .brand span {
  background: var(--gradient-warm);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.global-search { position: relative; margin: 0 2px 12px; }
.global-search-input { font-size: 13px; padding: 6px 10px; }
.search-results {
  position: absolute; top: calc(100% + 4px); left: 0; width: 260px; z-index: 40;
  background: var(--surface-elevated); border: 1px solid var(--border-strong); border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55); max-height: 60vh; overflow-y: auto;
}
.search-group { padding: 8px 10px 2px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.search-item { display: flex; flex-direction: column; padding: 6px 10px; color: var(--text); }
.search-item:hover { background: rgba(255, 255, 255, 0.05); text-decoration: none; }

.sidebar nav a {
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 500;
}
.sidebar nav a:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); text-decoration: none; }
.sidebar nav a.active { background: var(--gradient-warm-soft); color: var(--accent); }

.sidebar .footer { padding: 8px 10px; font-size: 12px; color: var(--muted); }
.sidebar .footer .who { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; }

.main { flex: 1; padding: 24px 28px; min-width: 0; }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---- cards / tables ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat .num { font-family: var(--font-display); font-size: 24px; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 12px; margin-top: 2px; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border-strong); }
td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr.rowlink { cursor: pointer; }
tbody tr.rowlink:hover { background: rgba(255, 255, 255, 0.03); }
.table-wrap { overflow-x: auto; }

/* ---- forms ---- */
label.field { display: block; margin-bottom: 12px; }
label.field .lbl { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }

input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  font: inherit;
  background: var(--bg-deep);
  color: var(--text);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(245, 158, 11, 0.35); border-color: var(--accent); }
textarea { resize: vertical; min-height: 70px; }
input[type="date"], input[type="datetime-local"] { color-scheme: dark; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }

button {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  background: var(--gradient-warm);
  color: #0a0a0f;
}
button:hover { filter: brightness(1.1); }
button.secondary { background: var(--surface-elevated); color: var(--text); border-color: var(--border-strong); }
button.secondary:hover { background: rgba(255, 255, 255, 0.08); filter: none; }
button.danger { background: var(--surface-elevated); color: var(--danger); border-color: var(--border-strong); }
button.danger:hover { background: rgba(248, 113, 113, 0.12); border-color: var(--danger); filter: none; }
button.small { padding: 4px 10px; font-size: 13px; }
button:disabled { opacity: 0.5; cursor: default; filter: none; }

.searchbar { max-width: 280px; }

/* ---- auth pages ---- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: radial-gradient(1200px 600px at 70% -10%, rgba(236, 72, 153, 0.08), transparent 60%), radial-gradient(900px 500px at 10% 110%, rgba(245, 158, 11, 0.07), transparent 60%), var(--bg-deep); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 16px; padding: 28px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55); }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); margin: 0 0 20px; }
.auth-card .alt { margin-top: 16px; font-size: 13px; color: var(--muted); }

/* ---- misc ---- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border-strong); color: var(--muted); }
.badge.ok { background: rgba(74, 222, 128, 0.12); color: var(--ok); border-color: rgba(74, 222, 128, 0.35); }
.badge.warn { background: rgba(251, 191, 36, 0.12); color: var(--warn); border-color: rgba(251, 191, 36, 0.35); }
.badge.danger { background: rgba(248, 113, 113, 0.12); color: var(--danger); border-color: rgba(248, 113, 113, 0.35); }
.badge.accent { background: var(--gradient-warm-soft); color: var(--accent); border-color: rgba(245, 158, 11, 0.35); }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.spacer { flex: 1; }
.empty { text-align: center; color: var(--muted); padding: 32px 16px; }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; font-size: 13px; color: var(--muted); }

/* ---- timeline ---- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline li:last-child { border-bottom: none; }
.timeline .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border-strong); margin-top: 6px; flex-shrink: 0; }
.timeline .dot.note { background: var(--accent); }
.timeline .dot.email { background: var(--accent-2); }
.timeline .dot.task_done { background: var(--ok); }
.timeline .body { flex: 1; min-width: 0; }
.timeline .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.timeline .text { white-space: pre-wrap; overflow-wrap: break-word; }

/* ---- modal ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(5, 5, 9, 0.7);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 16px; z-index: 50; overflow-y: auto;
}
.modal { background: var(--surface-elevated); border: 1px solid var(--border-strong); border-radius: 16px; padding: 22px; width: 100%; max-width: 520px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55); }
.modal h2 { margin-bottom: 16px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal .card { background: var(--surface); }

/* ---- toasts ---- */
#toasts { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--surface-elevated); border: 1px solid var(--border-strong); color: var(--text); padding: 10px 14px; border-radius: 10px; font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); max-width: 320px; }
.toast.error { background: rgba(248, 113, 113, 0.15); border-color: var(--danger); color: #fecaca; }

/* ---- detail layout ---- */
.detail-grid { display: grid; grid-template-columns: 320px 1fr; gap: 16px; align-items: start; }
.kv { margin: 0; }
.kv div { display: flex; padding: 5px 0; gap: 8px; }
.kv dt { color: var(--muted); width: 90px; flex-shrink: 0; }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border-strong); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); padding: 8px 12px; }
.tabs button:hover { background: none; color: var(--text); filter: none; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

.task-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.task-row:last-child { border-bottom: none; }
.task-row input[type="checkbox"] { width: auto; accent-color: var(--accent); }
.task-row .title { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.task-row.done .title { text-decoration: line-through; color: var(--muted); }

/* ---- kanban ---- */
.kanban { display: flex; gap: 12px; overflow-x: auto; align-items: flex-start; padding-bottom: 12px; }
.kanban-col {
  min-width: 230px; width: 230px; flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px;
}
.kanban-col.dragover { outline: 2px dashed var(--accent); outline-offset: -2px; }
.kanban-head { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; padding: 2px 4px 10px; }
.kanban-head .name { font-family: var(--font-display); font-weight: 700; font-size: 13px; }
.kanban-drop { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.deal-card {
  background: var(--surface-elevated); border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 10px; cursor: grab;
}
.deal-card.dragging { opacity: 0.5; }
.deal-card .title { font-weight: 600; color: var(--text); display: block; margin-bottom: 4px; overflow-wrap: anywhere; }
.deal-card .meta { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--muted); }
.deal-card .value { font-weight: 600; color: var(--accent); }

/* ---- dashboard / report bars ---- */
.stage-bar { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.stage-bar .lbl { width: 120px; flex-shrink: 0; font-size: 13px; }
.stage-bar .track { flex: 1; background: rgba(255, 255, 255, 0.05); border-radius: 4px; height: 18px; overflow: hidden; }
.stage-bar .fill { height: 100%; background: var(--gradient-warm); border-radius: 4px; min-width: 2px; }
.stage-bar .amt { width: 110px; text-align: right; font-size: 12px; color: var(--muted); flex-shrink: 0; }

/* ---- responsive ---- */
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 8px 12px; gap: 8px; overflow-x: auto; }
  .sidebar .brand { padding: 0 8px 0 0; white-space: nowrap; }
  .global-search { margin: 0 4px; min-width: 120px; }
  .search-results { width: 240px; }
  .sidebar nav { flex-direction: row; }
  .sidebar nav a { white-space: nowrap; padding: 6px 10px; }
  .sidebar .footer { display: none; }
  .main { padding: 16px; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
