@import url('https://fonts.googleapis.com/css2?family=Jura:wght@400;500;600&family=Tektur:wght@400;500;600;700&display=swap');

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

:root {
  --bg:            #09090f;
  --surface:       #11111a;
  --surface-2:     #17172a;
  --border:        #1e1e30;
  --border-hover:  #2e2e50;
  --blue-dim:      #1a3a5c;
  --blue-mid:      #2a6aad;
  --blue-bright:   #4da6ff;
  --blue-light:    #7ec8ff;
  --accent-purple: #a78bfa;
  --accent-green:  #34d399;
  --accent-red:    #f87171;
  --accent-yellow: #fbbf24;
  --text:          #dde8f5;
  --text-muted:    #7a8a9a;
  --text-dim:      #4a5a6a;
  --radius:        12px;
  --radius-sm:     8px;
  --nav-height:    60px;
}

body {
  font-family: 'Jura', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

/* ── Nav ─────────────────────────────────── */
.portal-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 8px;
  z-index: 100;
}

.nav-brand {
  font-family: 'Tektur', sans-serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--blue-bright);
  text-decoration: none;
  letter-spacing: 0.03em;
  flex-shrink: 0;
  margin-right: 8px;
}
.nav-brand span { color: var(--text-muted); font-weight: 400; }

.nav-links { display: flex; gap: 2px; flex: 1; }

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.nav-links a.active { color: var(--blue-bright); background: var(--surface-2); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  flex-shrink: 0;
}
.nav-user-name { font-size: 13px; color: var(--text-muted); }

.btn-logout {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'Jura', sans-serif;
  font-size: 13px;
  transition: border-color 0.15s, color 0.15s;
}
.btn-logout:hover { border-color: var(--border-hover); color: var(--text); }

/* ── Layout ──────────────────────────────── */
.portal-page { padding-top: var(--nav-height); min-height: 100vh; }

.portal-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
}
.portal-content.wide { max-width: 1300px; }

/* ── Page Header ─────────────────────────── */
.page-header {
  margin-bottom: 28px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header h1 {
  font-family: 'Tektur', sans-serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}
.page-header p { color: var(--text-muted); font-size: 14px; margin-top: 4px; }

/* ── Cards ───────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card + .card { margin-top: 16px; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-family: 'Tektur', sans-serif;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

/* ── Grids ───────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ── Stat Cards ──────────────────────────── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
}
.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.stat-value {
  font-family: 'Tektur', sans-serif;
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
}

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-family: 'Jura', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.15s, opacity 0.15s, border-color 0.15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--blue-mid); color: #fff; }
.btn-primary:hover { background: #3578c0; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--border-hover); background: var(--surface-2); }
.btn-danger { background: transparent; border: 1px solid #5a1818; color: var(--accent-red); }
.btn-danger:hover { background: rgba(248,113,113,0.08); border-color: #7a2020; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* ── Forms ───────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Jura', sans-serif;
  font-size: 14px;
  padding: 10px 12px;
  transition: border-color 0.15s;
  outline: none;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus { border-color: var(--blue-mid); }

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

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a8a9a' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.form-error {
  color: var(--accent-red);
  font-size: 12px;
  margin-top: 5px;
  display: none;
}
.form-error.visible { display: block; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ── Badges ──────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge-pending  { color: var(--text-muted);    background: rgba(122,138,154,0.12); }
.badge-progress { color: var(--blue-bright);   background: rgba(77,166,255,0.12); }
.badge-review   { color: var(--accent-purple); background: rgba(167,139,250,0.12); }
.badge-complete { color: var(--accent-green);  background: rgba(52,211,153,0.12); }
.badge-draft    { color: var(--text-muted);    background: rgba(122,138,154,0.12); }
.badge-sent     { color: var(--blue-bright);   background: rgba(77,166,255,0.12); }
.badge-accepted { color: var(--accent-green);  background: rgba(52,211,153,0.12); }
.badge-paid     { color: var(--accent-green);  background: rgba(52,211,153,0.12); }
.badge-declined { color: var(--accent-red);    background: rgba(248,113,113,0.12); }
.badge-overdue  { color: var(--accent-red);    background: rgba(248,113,113,0.12); }

/* ── Table ───────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
.data-table td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.1s; }
.data-table tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.data-table tbody tr.no-hover:hover { background: transparent; cursor: default; }

/* ── Milestones ──────────────────────────── */
.milestone-list { display: flex; flex-direction: column; gap: 8px; }

.milestone-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.milestone-check {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-hover);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.milestone-check.done { background: var(--accent-green); border-color: var(--accent-green); }
.milestone-check.done::after { content: '✓'; color: #000; font-size: 11px; font-weight: 700; }
.milestone-title { flex: 1; font-size: 14px; }
.milestone-title.done { text-decoration: line-through; color: var(--text-muted); }
.milestone-due { font-size: 12px; color: var(--text-dim); flex-shrink: 0; }

/* ── Messages ────────────────────────────── */
.message-thread { display: flex; flex-direction: column; gap: 14px; padding: 4px 0; }

.message-wrap { display: flex; flex-direction: column; }
.message-wrap.from-admin { align-items: flex-end; }

.message-bubble {
  max-width: 68%;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
}
.message-bubble.from-client {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.message-bubble.from-admin {
  background: var(--blue-dim);
  border: 1px solid rgba(77,166,255,0.2);
  border-bottom-right-radius: 4px;
}

.message-meta { font-size: 11px; color: var(--text-dim); margin-top: 5px; padding: 0 2px; }
.message-project-tag {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  background: rgba(77,166,255,0.08);
  border: 1px solid rgba(77,166,255,0.2);
  border-radius: 4px;
  color: var(--blue-bright);
  margin-bottom: 6px;
}

/* ── Compose ─────────────────────────────── */
.compose-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}
.compose-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-top: 10px;
}
.compose-row .form-input { flex: 1; }

/* ── Line Items ──────────────────────────── */
.line-items { width: 100%; border-collapse: collapse; margin-bottom: 8px; }
.line-items th {
  text-align: left;
  padding: 8px 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.line-items td { padding: 5px 4px; vertical-align: middle; }
.line-items td:last-child { width: 40px; text-align: center; }

.line-item-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: 'Jura', sans-serif;
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s;
}
.line-item-input:focus { border-color: var(--blue-mid); }
.line-item-input.narrow { width: 90px; }

.totals-section {
  display: flex;
  justify-content: flex-end;
  padding: 12px 4px 4px;
  border-top: 1px solid var(--border);
}
.totals-inner { display: flex; flex-direction: column; gap: 6px; min-width: 220px; }
.totals-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; }
.totals-row.total-row { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; }
.totals-label { color: var(--text-muted); }
.totals-value { font-family: 'Tektur', sans-serif; font-weight: 600; color: var(--text); }
.totals-row.total-row .totals-value { font-size: 20px; color: var(--blue-bright); }

.remove-row-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 4px;
  transition: color 0.15s;
}
.remove-row-btn:hover { color: var(--accent-red); }

/* ── Modal ───────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.modal-title { font-family: 'Tektur', sans-serif; font-size: 16px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  padding: 4px;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text); }

/* ── Login ───────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 38px;
  width: 100%;
  max-width: 400px;
}
.login-logo { text-align: center; margin-bottom: 30px; }
.login-logo h1 {
  font-family: 'Tektur', sans-serif;
  font-size: 20px;
  font-weight: 600;
  color: var(--blue-bright);
}
.login-logo p { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* ── Split Layout (messages/admin) ───────── */
.split-layout { display: grid; grid-template-columns: 280px 1fr; gap: 0; min-height: calc(100vh - var(--nav-height)); }
.split-sidebar {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 0;
}
.split-main { padding: 28px 24px; overflow-y: auto; }

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 20px;
  cursor: pointer;
  transition: background 0.1s;
  border-left: 2px solid transparent;
  font-size: 14px;
}
.sidebar-item:hover { background: var(--surface-2); }
.sidebar-item.active { background: var(--surface-2); border-left-color: var(--blue-bright); color: var(--blue-bright); }
.sidebar-item-name { flex: 1; }
.sidebar-item-sub { font-size: 12px; color: var(--text-muted); }

/* ── Toast ───────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 14px;
  color: var(--text);
  z-index: 300;
  display: none;
  min-width: 220px;
}
.toast.success { border-left: 3px solid var(--accent-green); }
.toast.error   { border-left: 3px solid var(--accent-red); }
.toast.show    { display: block; animation: fadeUp 0.2s ease; }

@keyframes fadeUp {
  from { transform: translateY(6px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

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

.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 32px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; margin-top: 6px; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  text-decoration: none;
  margin-bottom: 20px;
  transition: color 0.15s;
}
.back-link:hover { color: var(--text); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab {
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}
.tab.active { color: var(--blue-bright); border-bottom-color: var(--blue-bright); }

.admin-badge {
  font-size: 10px;
  padding: 2px 7px;
  background: rgba(167,139,250,0.12);
  border: 1px solid rgba(167,139,250,0.25);
  border-radius: 4px;
  color: var(--accent-purple);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-left: 4px;
  vertical-align: middle;
}

.unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--blue-bright);
  display: inline-block;
  flex-shrink: 0;
}

.section-gap { margin-top: 28px; }

/* ── Scrollbar ───────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
