@import url('https://fonts.googleapis.com/css2?family=Sora:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
  --ink: #14213D;
  --ink-soft: #2B3A5E;
  --gold: #C88A2E;
  --gold-soft: #F3E3C4;
  --bg: #F6F5F1;
  --card: #FFFFFF;
  --line: #E7E4DC;
  --text: #23262B;
  --text-dim: #6B7178;
  --green: #1F8A5D;
  --green-bg: #E4F5EC;
  --orange: #B7681B;
  --orange-bg: #FBEBD9;
  --blue: #2A5DB0;
  --blue-bg: #E7EEFB;
  --red: #C0392B;
  --red-bg: #FBE4E1;
  --gray-bg: #EFEFED;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

h1, h2, h3 { font-family: 'Sora', sans-serif; color: var(--ink); margin: 0 0 4px; }

a { color: inherit; text-decoration: none; }

.shell { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 220px;
  background: var(--ink);
  color: #EFEFF5;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 24px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--gold); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Sora', sans-serif; font-weight: 700;
}
.brand-text { font-family: 'Sora', sans-serif; font-weight: 600; font-size: 15px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  padding: 10px 12px; border-radius: 8px; color: #C6CAD8; font-weight: 500; font-size: 14px;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar nav a.active { background: var(--gold); color: var(--ink); }
.logout-link { padding: 10px 12px; color: #9AA1B4; font-size: 13px; }
.logout-link:hover { color: #fff; }

/* Content */
.content { flex: 1; padding: 32px 40px; max-width: 1200px; }

.flash {
  background: var(--green-bg); color: var(--green); border: 1px solid #BFE4D2;
  padding: 10px 16px; border-radius: var(--radius); margin-bottom: 20px; font-size: 14px; font-weight: 500;
}
.error { background: var(--orange-bg); color: var(--orange); border: 1px solid #EBCFA3; padding: 10px 16px; border-radius: var(--radius); margin-bottom: 20px; font-size: 14px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-head p { color: var(--text-dim); margin: 4px 0 0; font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--ink); color: #fff; border: none;
  padding: 10px 18px; border-radius: 8px; font-size: 14px; font-weight: 500;
  cursor: pointer; font-family: inherit;
}
.btn:hover { background: var(--ink-soft); }
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-gold:hover { background: #B87D25; }
.btn-outline { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-outline:hover { background: var(--gray-bg); }
.btn-green { background: var(--green); color: #fff; }
.btn-green:hover { background: #196E4A; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* Cards / stats */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.stat-card .label { font-size: 13px; color: var(--text-dim); font-weight: 500; }
.stat-card .value { font-family: 'Sora', sans-serif; font-size: 24px; font-weight: 700; color: var(--ink); margin-top: 6px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 24px; }
.card h2 { font-size: 17px; margin-bottom: 16px; }

/* Table */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; font-size: 14px; border-bottom: 1px solid var(--line); }
th { color: var(--text-dim); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
.table-empty { padding: 32px; text-align: center; color: var(--text-dim); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-orange { background: var(--orange-bg); color: var(--orange); }
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-gray { background: var(--gray-bg); color: var(--text-dim); }
.badge-red { background: var(--red-bg); color: var(--red); }

summary.btn { list-style: none; }
summary.btn::-webkit-details-marker { display: none; }
summary.btn::marker { content: ""; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 16px; }
.form-group.full { grid-column: 1 / -1; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
input[type=text], input[type=number], input[type=email], input[type=password], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
textarea { resize: vertical; min-height: 70px; }
.hint { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

/* Login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--ink); }
.login-box { background: var(--card); border-radius: 14px; padding: 40px; width: 360px; }
.login-box .brand-mark { margin: 0 auto 16px; }
.login-box h1 { text-align: center; font-size: 20px; }
.login-box p.sub { text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 24px; }

/* Invoice view */
.invoice-page { max-width: 720px; margin: 0 auto; padding: 40px 20px; }
.invoice-sheet { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 48px; }
.invoice-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 36px; }
.invoice-top .logo { max-height: 56px; margin-bottom: 8px; }
.invoice-meta { text-align: right; }
.invoice-meta .num { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 18px; color: var(--ink); }
.bill-to { display: flex; justify-content: space-between; margin-bottom: 32px; gap: 24px; }
.bill-to .block h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-dim); margin-bottom: 6px; }
.line-table { margin-bottom: 24px; }
.totals { margin-left: auto; width: 260px; }
.totals div { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
.totals .grand { border-top: 2px solid var(--ink); margin-top: 6px; padding-top: 10px; font-weight: 700; font-size: 17px; color: var(--ink); }
.action-bar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.pill-note { background: var(--gold-soft); color: #8A5E1E; padding: 10px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 20px; }

.avatar { width: 80px; height: 80px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); }
.avatar-placeholder { width: 80px; height: 80px; border-radius: 10px; background: var(--gray-bg); color: var(--text-dim); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }
.avatar-lg { width: 80px; height: 80px; border-radius: 10px; object-fit: cover; border: 1px solid var(--line); }
.avatar-lg-placeholder { width: 80px; height: 80px; border-radius: 10px; background: var(--gray-bg); color: var(--text-dim); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 26px; }
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.progress-bar { background: var(--gray-bg); border-radius: 6px; height: 8px; overflow: hidden; }
.progress-bar > div { background: var(--gold); height: 100%; }

/* Tab pills */
.pill-group { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.pill-group a { padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 500; border: 1px solid var(--line); color: var(--text-dim); }
.pill-group a.active { background: var(--ink); color: #fff; border-color: var(--ink); }

@media print {
  .action-bar, .no-print { display: none !important; }
  body { background: #fff; }
  .invoice-page { padding: 0; }
  .invoice-sheet { border: none; padding: 0; }
}

@media (max-width: 780px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 12px 16px; overflow-x: auto; }
  .sidebar nav { flex-direction: row; }
  .logout-link { margin-left: auto; }
  .content { padding: 20px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .bill-to { flex-direction: column; }
}