:root {
  --bg: #f8fafc;
  --panel: #ffffff;
  --text: #15171c;
  --muted: #6b7280;
  --line: #e7e9ef;
  --brand: #e85d3f;
  --brand-soft: #fff0ec;
  --dark: #263756;
  --green: #16b981;
  --red: #e5485d;
  --shadow: 0 14px 40px rgba(20, 24, 33, 0.06);
}

* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body { margin: 0; font-family: Inter, Arial, sans-serif; color: var(--text); background: var(--bg); }
button, input, select, textarea { font: inherit; }
.app { width: 100%; min-height: 100vh; display: grid; grid-template-columns: 240px minmax(0, 1fr); overflow-x: hidden; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--panel); border-right: 1px solid var(--line); padding: 14px 12px 22px; }
.brand { height: 46px; display: flex; align-items: center; gap: 10px; margin-bottom: 18px; padding: 0 10px; }
.brand-mark { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 10px; color: white; background: linear-gradient(145deg, #e85d3f, #263756); box-shadow: 0 12px 22px rgba(232, 93, 63, .2); }
.brand-title { line-height: 1.05; font-weight: 800; font-size: 20px; }
.brand-title span { color: var(--brand); }
.brand-subtitle { margin-top: 2px; color: #9aa1ad; font-size: 10px; letter-spacing: .3px; }
.menu-label { margin: 22px 12px 10px; color: #1f2937; font-size: 13px; font-weight: 500; }
.nav { display: grid; gap: 4px; }
.nav-link { min-height: 36px; display: flex; align-items: center; gap: 12px; padding: 8px 11px; color: #272b33; text-decoration: none; border-radius: 8px; font-size: 14px; font-weight: 500; }
.nav-link i { width: 18px; height: 18px; color: #28313f; }
.nav-link.active { color: #b7513f; background: var(--brand-soft); }
.nav-link.active i { color: var(--brand); }
.nav-group { border-radius: 8px; }
.nav-group summary { min-height: 36px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 11px; color: #272b33; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; list-style: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary span { display: flex; align-items: center; gap: 12px; min-width: 0; }
.nav-group summary i { width: 18px; height: 18px; color: #28313f; }
.nav-group summary > i:last-child { margin-left: auto; transition: transform .18s ease; }
.nav-group[open] summary { background: #f5f3fb; }
.nav-group[open] summary > i:last-child { transform: rotate(180deg); }
.nav-submenu { display: grid; gap: 2px; padding: 6px 0 8px 42px; }
.nav-sublink { min-height: 32px; display: flex; align-items: center; border-radius: 7px; padding: 7px 10px; color: #6b7280; text-decoration: none; font-size: 13px; font-weight: 600; }
.nav-sublink.active { color: #b7513f; background: var(--brand-soft); }
.main { min-width: 0; max-width: 100%; overflow-x: hidden; }
.topbar { height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 16px; background: var(--panel); border-bottom: 1px solid var(--line); padding: 0 22px; }
.icon-btn { width: 36px; height: 36px; display: inline-grid; place-items: center; border: 1px solid transparent; border-radius: 8px; color: #202938; background: #f9fafb; cursor: pointer; position: relative; }
.top-actions { display: flex; align-items: center; gap: 14px; }
.badge { position: absolute; top: -5px; right: -3px; min-width: 18px; height: 18px; display: grid; place-items: center; border-radius: 99px; color: white; background: #ef233c; border: 2px solid white; font-size: 10px; font-weight: 800; }
.avatar { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; color: white; background: linear-gradient(135deg, #17a2b8, #ed6a4e); font-size: 13px; font-weight: 800; }
.content { min-width: 0; max-width: 100%; padding: 34px 22px 26px; overflow-x: hidden; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.page-head h1 { margin: 0 0 6px; font-size: 27px; line-height: 1.15; letter-spacing: 0; }
.page-head p { margin: 0; color: #1f2937; font-size: 15px; }
.head-actions, .action-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.panel { min-width: 0; max-width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: var(--shadow); overflow: hidden; }
.invoice { padding: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 16px; }
.field { display: grid; gap: 8px; }
.field.wide { grid-column: span 2; }
label { color: #253041; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--text); outline: 0; padding: 11px 12px; }
input, select { min-height: 42px; }
input[readonly] { background: #f1f4f8; color: #3f4858; }
textarea { min-height: 62px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #f0a08d; box-shadow: 0 0 0 3px rgba(232, 93, 63, .12); }
.invoice-tools { display: grid; grid-template-columns: minmax(320px, 1fr) auto auto minmax(220px, 260px); gap: 14px; align-items: end; margin-top: 28px; }
.btn { min-height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; background: white; color: #1f2937; padding: 0 14px; text-decoration: none; font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.btn.primary { color: white; background: var(--brand); border-color: var(--brand); }
.btn.dark { color: white; background: var(--dark); border-color: var(--dark); }
.btn.danger { color: white; background: var(--red); border-color: var(--red); }
.total-card { grid-column: -2 / -1; width: 100%; min-height: 94px; display: grid; align-content: center; justify-items: center; border-radius: 8px; background: #fff5f2; color: var(--brand); border: 1px solid #ffd8cd; }
.total-card span { color: #9f2e1f; font-size: 14px; font-weight: 800; text-transform: uppercase; letter-spacing: .3px; }
.total-card strong { margin-top: 8px; color: #d61f14; font-size: 28px; line-height: 1; }
.check-row { display: flex; align-items: center; gap: 12px; margin-top: 18px; color: var(--muted); font-size: 14px; }
.check-row input, .invoice-checks input { width: 20px; height: 20px; min-height: 20px; accent-color: var(--brand); }
.table-wrap { max-width: 100%; margin-top: 28px; border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; }
table { width: 100%; min-width: 1120px; border-collapse: collapse; }
th, td { padding: 13px 14px; text-align: left; border-bottom: 1px solid #f0f1f4; font-size: 14px; }
th { color: #5f6878; font-size: 12px; text-transform: uppercase; letter-spacing: .3px; background: #fbfcfd; }
tbody tr:nth-child(even) td { background: #fbfcfd; }
tbody tr:last-child td { border-bottom: 0; }
td strong { display: block; max-width: 170px; }
.delete { color: #b42336; font-weight: 800; text-decoration: none; }
.small-input { min-height: 34px; max-width: 92px; padding: 7px 8px; border-radius: 6px; }
.total-cell { font-weight: 800; }
.details-grid { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 16px; margin-top: 26px; }
.note-stack { display: grid; gap: 16px; }
.summary-box { display: grid; gap: 12px; align-content: start; border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: #fbfcfd; }
.summary-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.summary-row.total { padding-top: 12px; border-top: 1px solid var(--line); font-size: 20px; font-weight: 800; }
.bottom-panel { margin-top: 20px; display: grid; grid-template-columns: 1fr; gap: 16px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfd; padding: 20px; }
.invoice-checks { display: flex; flex-wrap: wrap; gap: 18px; color: #3d4656; font-size: 14px; }
.invoice-checks label { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; color: #3d4656; }
@media (max-width: 1280px) {
  .form-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .invoice-tools { grid-template-columns: minmax(260px, 1fr) auto auto minmax(220px, 260px); }
}
@media (max-width: 1100px) {
  .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 920px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 24px 14px; }
  .page-head { flex-direction: column; }
  .head-actions { justify-content: flex-start; }
  .form-grid, .details-grid, .invoice-tools { grid-template-columns: 1fr; }
  .total-card { grid-column: auto; }
  .field.wide { grid-column: auto; }
  .btn { width: 100%; }
}
@media (max-width: 520px) {
  .topbar { padding: 0 12px; }
  .nav { grid-template-columns: 1fr; }
  .invoice { padding: 18px 14px; }
}
