/* Admin UI */
:root {
  --bg: #f7fafc;
  --card: #fff;
  --ink: #0c121d;
  --muted: #5b6575;
  --line: #e3e8ef;
  --sky: #fde8f2;
  --sky-500: #f33f99;
  --blue: #3069d8;
  --navy: #c5337c;
  --grad: linear-gradient(90deg, #f33f99 0%, #3879fa 50%, #f33f99 100%);
  --radius: 12px;
  --danger: #dc2626;
}
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400 800; font-display: swap; src: url('fonts/inter-latin-400-800.woff2') format('woff2'); }
@font-face { font-family: 'Fraunces'; font-style: normal; font-weight: 700 800; font-display: swap; src: url('fonts/fraunces-latin-700-800.woff2') format('woff2'); }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--blue); }
h1 { font: 800 26px/1.5 "Fraunces", Georgia, serif; margin: 0; }
h2 { font-size: 15px; margin: 0 0 14px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 24px; padding-bottom: 60px; }
.muted { color: var(--muted); font-weight: 400; }
.tiny { font-size: 12px; }
.strong { font-weight: 600; text-decoration: none; }
.text-danger { color: var(--danger); }
.hidden { display: none !important; }

/* Top bar */
.topbar { background: #fff; border-bottom: 1px solid var(--line); position: relative; }
.topbar::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--grad); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font: 800 17px "Fraunces", Georgia, serif; color: var(--ink); text-decoration: none; }
.brand-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--grad); }
.nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--sky); color: var(--ink); }
.nav a.on { background: var(--sky); color: var(--navy); }

/* Layout */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.back { display: inline-block; font-size: 13px; color: var(--muted); text-decoration: none; margin-bottom: 4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 18px; }
.grid-2, .grid-3 { display: grid; gap: 12px 16px; margin-bottom: 12px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.sticky { position: sticky; top: 16px; }
.settings-bottom { margin-top: 18px; }
.inline-form { margin-top: 10px; }
.below-actions { margin-top: 18px; }

/* Forms */
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); width: 100%;
  padding: 9px 11px; border: 1px solid #d4d8de; border-radius: 8px; background: #fff;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sky-500); outline-offset: -1px; border-color: var(--sky-500); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: auto; }
label.inline { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; }
label.inline input { width: 70px; }
.vat-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 0; }
.side label + label { margin-top: 12px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
  padding: 9px 16px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--ink);
  transition: border-color .15s, background-position .4s;
}
.btn:hover { border-color: #94a3b8; }
.btn-primary { color: #fff; border: 0; background: var(--grad); background-size: 200% 100%; }
.btn-primary:hover { background-position: 100% 0; }
.btn-sm { padding: 5px 11px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-danger-ghost { color: var(--danger); border-color: #fecaca; }
.icon-btn { border: 0; background: none; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 6px; }
.icon-btn:hover { background: #fee2e2; color: var(--danger); }

/* Flash */
.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.flash-ok { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.flash-err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 16px 18px; }
.stat span { font-size: 12.5px; color: var(--muted); }
.stat strong { font-size: 20px; }

/* Lists */
.filters { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input[type=search] { max-width: 300px; }
.tabs { display: flex; gap: 4px; background: #f1f5f9; padding: 4px; border-radius: 10px; }
.tabs a { padding: 6px 14px; border-radius: 7px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 13px; }
.tabs a.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.table-scroll { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
.list th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.list td { padding: 11px 10px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
.row-actions { text-align: right; white-space: nowrap; }
.row-actions > * { vertical-align: middle; }
.empty { text-align: center; padding: 40px 10px; }

/* Status badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #f1f5f9; color: #475569; }
.badge-sent { background: var(--sky); color: #0369a1; }
.badge-paid, .badge-accepted { background: #dcfce7; color: #166534; }
.badge-overdue, .badge-declined { background: #fee2e2; color: #991b1b; }
.badge-expired, .badge-cancelled { background: #f1f5f9; color: #94a3b8; }

/* More menu */
.menu { display: inline-block; position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 190px;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, .12); text-align: left;
}
.menu-pop a, .menu-pop button {
  display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 6px;
  font: inherit; color: var(--ink); text-decoration: none; background: none; border: 0; cursor: pointer;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--sky); }
.menu-pop .danger { color: var(--danger); }
.menu-pop .danger:hover { background: #fee2e2; }

/* Items editor */
table.items { width: 100%; border-collapse: collapse; margin-bottom: 12px; min-width: 560px; }
.items th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 0 6px 8px; }
.items td { padding: 5px 6px; vertical-align: top; }
.items .c-qty { width: 80px; }
.items .c-price { width: 130px; }
.items .c-total { width: 130px; }
.items .c-rm { width: 36px; }
.items .line-total { padding-top: 14px; font-weight: 600; }
.items textarea { min-height: 42px; }
.quick-client { border: 1px dashed #cbd5e1; border-radius: 10px; padding: 10px 14px; }
.quick-client summary { cursor: pointer; font-weight: 600; color: var(--blue); }
.quick-client[open] summary { margin-bottom: 12px; }

/* Totals */
.totals { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; margin: 16px 0 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.totals dt { color: var(--muted); }
.totals dd { margin: 0; text-align: right; white-space: nowrap; }
.totals .grand { font-size: 18px; font-weight: 800; color: var(--ink); padding-top: 6px; }

/* Auth */
.auth-card { max-width: 420px; margin: 60px auto; }
.auth-card h1 { margin-bottom: 6px; }

/* Settings */
.logo-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.logo-preview { max-height: 56px; max-width: 200px; padding: 6px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

@media (max-width: 980px) {
  .edit-grid { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat strong { font-size: 17px; }
  .filters input[type=search] { max-width: none; }
}

/* Project panel */
.project-panel { margin-bottom: 18px; }
.pp-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.pp-head h2 { margin-bottom: 4px; }
.pp-head p { margin: 0; }
.list tr.is-current td { background: #f0f9ff; }

.danger-zone { margin-top: 18px; border-color: #fecaca; }
.reset-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.app-foot { padding-bottom: 30px; font-size: 12px; color: #94a3b8; }
.grid-1 { display: grid; gap: 12px; margin-bottom: 12px; }

/* Login & security */
.security { margin-top: 18px; }
.security h3 { font-size: 14px; margin: 0; display: flex; align-items: center; gap: 8px; }
.sec-grid { align-items: start; gap: 24px; }
.qr { width: 180px; height: 180px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.qr svg { width: 100%; height: 100%; display: block; }
.key { font-family: ui-monospace, Menlo, Consolas, monospace; background: #f1f5f9; padding: 2px 6px; border-radius: 6px; color: var(--ink); word-break: break-all; }
.codes-box { background: #fefce8; border: 1px solid #fde68a; border-radius: 10px; padding: 12px 14px; }
.codes-box p { margin: 4px 0 8px; }
.codes { margin: 0; padding-left: 20px; columns: 2; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
@media (max-width: 980px) { .sec-grid { grid-template-columns: 1fr; } }

/* Carmen */
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--sky); color: var(--navy); }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.no-mb { margin-bottom: 0; }
.form-note { margin: -4px 0 0; }
.totals .dep-row.is-off { display: none; }
