@import url('vars.css');

body.admin { background: var(--paper); }

/* ---------- Auth / login screen ---------- */

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(176,141,87,0.18), transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(176,141,87,0.12), transparent 45%),
    linear-gradient(160deg, var(--ink-navy-deep), var(--ink-navy) 60%, var(--ink-navy-soft));
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--paper-raised);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lift);
  padding: 40px 34px 34px;
  position: relative;
  overflow: hidden;
}

.auth-seal {
  width: 68px; height: 68px;
  border-radius: 50%;
  border: 2px dashed var(--brass);
  display: grid; place-items: center;
  margin: 0 auto 18px;
  position: relative;
}
.auth-seal::before {
  content: '';
  position: absolute; inset: 8px;
  border: 1px solid var(--brass-light);
  border-radius: 50%;
}
.auth-seal span {
  font-weight: 800; font-size: 22px; color: var(--brass-dark);
  transform: rotate(-8deg);
}

.auth-title { text-align: center; font-size: 20px; font-weight: 800; color: var(--ink-navy); margin: 0 0 4px; }
.auth-sub { text-align: center; font-size: 13px; color: var(--ink-gray); margin: 0 0 28px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-gray); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--paper-line);
  background: var(--white);
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 4px rgba(176,141,87,0.15);
}
.field textarea { resize: vertical; min-height: 70px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .15s;
  font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, var(--brass), var(--brass-dark)); color: var(--white); box-shadow: 0 8px 20px -8px rgba(138,108,63,0.6); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-navy { background: var(--ink-navy); color: var(--white); }
.btn-navy:hover { background: var(--ink-navy-soft); }
.btn-ghost { background: transparent; color: var(--ink-navy); border: 1.5px solid var(--paper-line); }
.btn-ghost:hover { border-color: var(--brass); color: var(--brass-dark); }
.btn-danger { background: var(--seal-red-soft); color: var(--seal-red); }
.btn-danger:hover { background: #ecd3d0; }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 12.5px; border-radius: 7px; }

.auth-error {
  background: var(--seal-red-soft); color: var(--seal-red);
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px;
}

/* ---------- App shell ---------- */

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

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: linear-gradient(190deg, var(--ink-navy-deep), var(--ink-navy) 75%);
  color: #dfe4f2;
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 4px 24px; border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 22px; }
.brand-seal {
  width: 42px; height: 42px; border-radius: 50%;
  border: 2px dashed var(--brass-light);
  display: grid; place-items: center;
  color: var(--brass-light); font-weight: 800; font-size: 15px;
  transform: rotate(-6deg);
}
.brand-name { font-weight: 800; font-size: 16px; color: #fff; }
.brand-tag { font-size: 11px; color: #93a0c2; letter-spacing: .04em; }

.nav-group { margin-bottom: 22px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: #6b7796; margin: 0 8px 8px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: 10px;
  font-size: 14px; font-weight: 600; color: #c7cee3;
  margin-bottom: 4px;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link.active { background: linear-gradient(135deg, rgba(176,141,87,0.35), rgba(176,141,87,0.12)); color: #fff; box-shadow: inset 0 0 0 1px rgba(217,190,143,0.35); }
.nav-icon { width: 18px; text-align: center; opacity: .9; }

.sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.sidebar-user { font-size: 13px; color: #c7cee3; margin-bottom: 10px; }
.sidebar-user b { color: #fff; }

.main { flex: 1; min-width: 0; padding: 30px 36px 60px; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 26px; flex-wrap: wrap; }
.page-title { font-size: 22px; font-weight: 800; color: var(--ink-navy); margin: 0; }
.page-sub { font-size: 13px; color: var(--ink-gray); margin: 4px 0 0; }

/* ---------- Stat cards ---------- */

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.stat-card {
  background: var(--paper-raised); border-radius: var(--radius-md);
  padding: 18px 20px; box-shadow: var(--shadow-soft);
  border: 1px solid var(--paper-line);
}
.stat-card .k { font-size: 12px; color: var(--ink-gray); font-weight: 600; margin-bottom: 8px; }
.stat-card .v { font-size: 24px; font-weight: 800; color: var(--ink-navy); }
.stat-card.accent .v { color: var(--brass-dark); }
.stat-card.good .v { color: var(--seal-green); }
.stat-card.bad .v { color: var(--seal-red); }

/* ---------- Table / list ---------- */

.panel { background: var(--paper-raised); border-radius: var(--radius-lg); box-shadow: var(--shadow-soft); border: 1px solid var(--paper-line); overflow: hidden; }
.panel-head { padding: 18px 22px; border-bottom: 1px solid var(--paper-line); display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 800; color: var(--ink-navy); }

.filters { display: flex; gap: 10px; align-items: center; }
.filters input[type=text] { padding: 9px 14px; border-radius: 8px; border: 1.5px solid var(--paper-line); font-size: 13px; width: 220px; font-family: inherit; }
.filters input:focus { outline: none; border-color: var(--brass); }
.chip { padding: 7px 14px; border-radius: 20px; font-size: 12.5px; font-weight: 700; border: 1.5px solid var(--paper-line); color: var(--ink-gray); }
.chip.active { background: var(--ink-navy); color: #fff; border-color: var(--ink-navy); }

table.data { width: 100%; border-collapse: collapse; }
table.data th { text-align: right; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); padding: 12px 22px; border-bottom: 1px solid var(--paper-line); font-weight: 700; }
table.data td { padding: 15px 22px; border-bottom: 1px solid var(--paper-line); font-size: 13.5px; color: var(--ink); vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fbf9f2; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge.paid { background: var(--seal-green-soft); color: var(--seal-green); }
.badge.unpaid { background: var(--seal-red-soft); color: var(--seal-red); }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }

.row-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.icon-btn { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; border: 1.5px solid var(--paper-line); color: var(--ink-gray); background: var(--white); cursor: pointer; transition: all .15s; }
.icon-btn:hover { border-color: var(--brass); color: var(--brass-dark); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--ink-gray); }
.empty-state .em-icon { font-size: 40px; margin-bottom: 12px; }
.empty-state h4 { color: var(--ink-navy); margin: 0 0 6px; }

/* ---------- Invoice builder ---------- */

.builder-grid { display: grid; grid-template-columns: 1fr 360px; gap: 22px; align-items: start; }
@media (max-width: 1100px) { .builder-grid { grid-template-columns: 1fr; } }

.card { background: var(--paper-raised); border-radius: var(--radius-lg); box-shadow: var(--shadow-soft); border: 1px solid var(--paper-line); padding: 22px; margin-bottom: 20px; }
.card h3 { margin: 0 0 16px; font-size: 14.5px; font-weight: 800; color: var(--ink-navy); display: flex; align-items: center; gap: 8px; }
.card h3 .num { width: 22px; height: 22px; border-radius: 50%; background: var(--brass-light); color: var(--ink-navy-deep); font-size: 11px; display: grid; place-items: center; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* items builder */
.items-table { width: 100%; border-collapse: collapse; }
.items-table th { font-size: 11px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .04em; text-align: right; padding: 0 8px 8px; }
.items-table td { padding: 6px 6px; vertical-align: top; }
.items-table input[type=text], .items-table input[type=number] {
  width: 100%; padding: 9px 10px; border-radius: 7px; border: 1.5px solid var(--paper-line);
  font-family: inherit; font-size: 13px; background: var(--white);
}
.items-table input:focus { outline: none; border-color: var(--brass); }
.items-table .col-title { width: 30%; }
.items-table .col-sub { width: 20%; }
.items-table .col-qty, .items-table .col-price, .items-table .col-disc { width: 12%; }
.items-table .col-tot { width: 12%; white-space: nowrap; font-weight: 700; color: var(--ink-navy); padding-top: 12px; text-align: center; }
.items-table .col-actions { width: 60px; text-align: center; }

.removable-toggle { display: flex; align-items: center; gap: 6px; justify-content: center; padding-top: 10px; }
.removable-toggle input { width: auto !important; }
.removable-toggle label { font-size: 10.5px; color: var(--ink-gray); cursor: pointer; }

.row-remove-btn { width: 30px; height: 30px; border-radius: 7px; border: 1.5px solid var(--paper-line); background: var(--white); color: var(--seal-red); cursor: pointer; margin-top: 6px; }
.row-remove-btn:hover { background: var(--seal-red-soft); }

.add-row-btn {
  margin-top: 10px; padding: 10px 16px; border-radius: 9px; border: 1.5px dashed var(--brass);
  background: transparent; color: var(--brass-dark); font-weight: 700; font-size: 13px; cursor: pointer; width: 100%;
}
.add-row-btn:hover { background: rgba(176,141,87,0.08); }

/* asset picker */
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.asset-swatch {
  border: 2px solid var(--paper-line); border-radius: 12px; padding: 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  transition: all .15s; background: var(--white);
}
.asset-swatch img { width: 100%; height: 46px; object-fit: contain; }
.asset-swatch span { font-size: 10.5px; color: var(--ink-gray); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; width: 100%; }
.asset-swatch.selected { border-color: var(--brass); box-shadow: 0 0 0 3px rgba(176,141,87,0.18); background: #fffaf0; }
.asset-swatch.none-option { justify-content: center; height: 100%; color: var(--ink-faint); font-size: 12px; }

/* sticky preview / totals panel */
.sticky-panel { position: sticky; top: 22px; }
.preview-total { background: linear-gradient(160deg, var(--ink-navy-deep), var(--ink-navy)); color: #fff; border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow-lift); }
.preview-total .pt-row { display: flex; justify-content: space-between; font-size: 13px; color: #b9c1dc; padding: 6px 0; }
.preview-total .pt-row.grand { border-top: 1px dashed rgba(255,255,255,0.25); margin-top: 8px; padding-top: 14px; font-size: 18px; font-weight: 800; color: #fff; }
.preview-total .pt-row.grand .amt { color: var(--brass-light); }

.upload-inline { display: flex; gap: 8px; margin-top: 10px; }
.upload-inline input[type=text] { flex: 1; }

form .field-hint { font-size: 11.5px; color: var(--ink-faint); margin-top: 5px; }

.toolbar-actions { display: flex; gap: 10px; }

.toast-banner { background: var(--seal-green-soft); color: var(--seal-green); padding: 12px 18px; border-radius: 10px; font-size: 13px; font-weight: 700; margin-bottom: 18px; display: flex; align-items: center; gap: 8px; }

.copy-link-box { display: flex; gap: 8px; align-items: center; background: #fbf9f2; border: 1.5px dashed var(--paper-line); border-radius: 10px; padding: 10px 14px; margin-top: 6px; }
.copy-link-box code { flex: 1; font-size: 12.5px; color: var(--ink-navy); overflow-x: auto; white-space: nowrap; direction: ltr; text-align: left; }

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; align-items: center; overflow-x: auto; }
  .brand { border-bottom: none; margin-bottom: 0; padding: 0 14px 0 0; border-left: 1px solid rgba(255,255,255,0.08); }
  .nav-group { display: flex; margin-bottom: 0; margin-right: 10px; }
  .nav-label { display: none; }
  .sidebar-foot { display: none; }
  .main { padding: 20px; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}
