* {
    box-sizing: border-box;
}

:root {
    --bg: #f5f5f7;
    --card: #ffffff;
    --text: #111111;
    --muted: #777777;
    --line: #e7e7ec;
    --soft: #fafafa;
    --black: #0f0f10;
    --radius: 24px;
    --shadow: 0 24px 70px rgba(0, 0, 0, 0.06);
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

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

.sidebar {
    width: 230px;
    background: rgba(255, 255, 255, 0.9);
    border-right: 1px solid var(--line);
    padding: 30px 24px;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 900;
    letter-spacing: -0.7px;
    margin-bottom: 38px;
}

.brand-mark {
    width: 32px;
    height: 32px;
    background: var(--black);
    color: #fff;
    border-radius: 9px;
    display: grid;
    place-items: center;
    font-size: 17px;
    font-weight: 900;
}

.side-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.side-nav a {
    text-decoration: none;
    color: #6d6d72;
    font-weight: 750;
    padding: 14px 15px;
    border-radius: 16px;
}

.side-nav a.active {
    background: var(--black);
    color: white;
}

.main {
    flex: 1;
    padding: 36px 42px 60px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.eyebrow {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 800;
    color: var(--muted);
}

h1 {
    margin: 0;
    font-size: 32px;
    line-height: 1;
    letter-spacing: -2px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.saved-status {
    font-size: 14px;
    color: var(--muted);
    font-weight: 700;
    margin-right: 6px;
}

.primary-btn,
.secondary-btn,
.ghost-btn {
    border: 0;
    cursor: pointer;
    font-weight: 850;
    font-family: inherit;
}

.primary-btn {
    background: var(--black);
    color: #fff;
    padding: 15px 24px;
    border-radius: 999px;
    box-shadow: 0 8px 22px rgba(0,0,0,0.14);
}

.ghost-btn {
    background: #fff;
    border: 1px solid var(--line);
    color: var(--text);
    padding: 14px 20px;
    border-radius: 999px;
}

.secondary-btn {
    background: #f0f0f3;
    color: var(--text);
    padding: 12px 16px;
    border-radius: 14px;
}

.content {
    display: grid;
    grid-template-columns: 460px minmax(680px, 1fr);
    gap: 32px;
    align-items: start;
}

.form-column {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.card,
.invoice-preview {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.card {
    padding: 22px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.card h2 {
    font-size: 19px;
    letter-spacing: -0.4px;
    margin: 0;
}

label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    font-weight: 850;
    margin: 10px 0 7px;
}

input,
textarea {
    width: 100%;
    border: 1px solid #e0e0e6;
    background: var(--soft);
    border-radius: 15px;
    padding: 14px 15px;
    font-size: 15px;
    font-family: inherit;
    outline: none;
    margin-bottom: 10px;
    transition: 0.15s ease;
}

input:focus,
textarea:focus {
    background: #fff;
    border-color: #111;
    box-shadow: 0 0 0 4px rgba(0,0,0,0.05);
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.textarea-count {
    text-align: right;
    font-size: 12px;
    color: var(--muted);
    margin-top: -4px;
}

.logo-upload {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    border: 1px dashed #d4d4da;
    border-radius: 18px;
    cursor: pointer;
    margin-bottom: 14px;
    transition: 0.15s ease;
}

.logo-upload:hover {
    background: #fafafa;
    border-color: #111;
}

.logo-upload input {
    display: none;
}

.logo-upload strong {
    display: block;
    font-size: 15px;
}

.logo-upload small {
    color: var(--muted);
    font-weight: 700;
}

.logo-preview,
.preview-logo-fallback {
    width: 52px;
    height: 52px;
    background: var(--black);
    color: white;
    border-radius: 15px;
    display: grid;
    place-items: center;
    font-size: 24px;
    font-weight: 900;
    overflow: hidden;
    flex: 0 0 auto;
}

.logo-preview img,
.preview-logo-fallback img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: white;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.items-header,
.item-row {
    display: grid;
    grid-template-columns: 1fr 72px 100px 38px;
    gap: 8px;
    align-items: start;
}

.items-header {
    color: var(--muted);
    font-size: 12px;
    font-weight: 850;
    padding: 0 8px 8px;
}

.item-row {
    margin-bottom: 10px;
}

.item-row input {
    margin-bottom: 0;
}

.item-note {
    margin-top: 6px;
    font-size: 13px;
    padding: 10px 12px;
}

.trash-btn {
    width: 38px;
    height: 48px;
    border: 1px solid var(--line);
    background: white;
    border-radius: 13px;
    font-size: 22px;
    cursor: pointer;
    color: #777;
}

.trash-btn:hover {
    color: #111;
    border-color: #111;
}

.preview-column {
    min-width: 0;
}

.invoice-preview {
    padding: 46px;
    min-height: 760px;
    height: auto;
    overflow: visible;
    position: sticky;
    top: 24px;
}

.invoice-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 30px;
    margin-bottom: 34px;
}

.preview-brand-block{
    display:flex;
    flex-direction:column;
    align-items:flex-start;
    width:300px;
}

#previewLogo {
    display: none;
    width: 58px;
    height: 58px;
    object-fit: contain;
    border-radius: 14px;
}

.preview-brand-block h2 {
    font-size: 42px;
    margin: 0;
    letter-spacing: -1.8px;
}

.invoice-title-block {
    text-align: right;
}

.invoice-title-block h3 {
    margin: 0;
    font-size: 30px;
    letter-spacing: -1px;
}

.invoice-title-block p {
    margin: 5px 0 0;
    font-size: 18px;
    font-weight: 750;
}

.business-preview{
    margin-top:18px;
}

.business-preview strong{
    display:block;
    font-size:28px;
    font-weight:700;
    margin-bottom:14px;
    color:#111;
}

.business-preview p{
    margin:4px 0;
    font-size:16px;
    color:#444;
    line-height:1.45;
}

.business-preview p,
.bill-section p,
.preview-notes p {
    margin: 4px 0;
    line-height: 1.35;
}

.invoice-meta {
    display: grid;
    grid-template-columns: 1fr 240px;
    margin-bottom: 26px;
}

.meta-grid {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: 10px 12px;
    font-size: 14px;
}

.meta-grid strong {
    color: #555;
}

hr {
    border: 0;
    border-top: 1px solid var(--line);
    margin: 28px 0;
}

.label {
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 12px;
    font-weight: 900;
    margin-bottom: 10px !important;
}

.bill-section {
    margin-bottom: 28px;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.invoice-table th {
    text-align: left;
    color: #777;
    font-size: 13px;
    padding: 13px 0;
    border-bottom: 1px solid var(--line);
}

.invoice-table th:nth-child(2),
.invoice-table th:nth-child(3),
.invoice-table th:nth-child(4),
.invoice-table td:nth-child(2),
.invoice-table td:nth-child(3),
.invoice-table td:nth-child(4) {
    text-align: right;
}

.invoice-table td {
    padding: 18px 0;
    border-bottom: 1px solid #eeeeef;
    vertical-align: top;
}

.invoice-table td strong {
    display: block;
    font-size: 15px;
}

.invoice-table td small {
    display: block;
    color: var(--muted);
    margin-top: 5px;
}

.totals {
    width: 310px;
    margin-left: auto;
    margin-top: 24px;
}

.totals div {
    display: flex;
    justify-content: space-between;
    padding: 9px 0;
}

.totals .grand {
    border-top: 1px solid #111;
    margin-top: 7px;
    padding-top: 16px;
    font-size: 24px;
    font-weight: 900;
}

.preview-notes {
    margin-top: 58px;
    max-width: 420px;
}

.hidden {
    display: none !important;
}

.mobile-actions {
    display: none;
}

.full {
    width: 100%;
    margin-bottom: 10px;
}

@media print {
    body {
        background: white;
    }

    .sidebar,
    .topbar,
    .form-column {
        display: none !important;
    }

    .main {
        padding: 0;
    }

    .content {
        display: block;
    }

    .invoice-preview {
        box-shadow: none;
        border: 0;
        border-radius: 0;
        position: static;
        width: 100%;
        min-height: auto;
        padding: 40px;
    }
}

@media (max-width: 1180px) {
    .content {
        grid-template-columns: 1fr;
    }

    .invoice-preview {
        position: static;
    }
}

@media (max-width: 760px) {
    .app {
        display: block;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        padding: 18px;
    }

    .brand {
        margin-bottom: 18px;
    }

    .side-nav {
        flex-direction: row;
        overflow-x: auto;
    }

    .side-nav a {
        white-space: nowrap;
    }

    .main {
        padding: 22px 16px 40px;
    }

    .topbar {
        display: block;
    }

    h1 {
        font-size: 38px;
    }

    .top-actions {
        display: none;
    }

    .card {
        padding: 18px;
    }

    .grid-2,
    .items-header,
    .item-row {
        grid-template-columns: 1fr;
    }

    .items-header {
        display: none;
    }

    .trash-btn {
        width: 100%;
    }

    .invoice-preview {
        padding: 24px;
        min-height: auto;
    }

    .invoice-top,
    .invoice-meta {
        display: block;
    }

    .invoice-title-block {
        text-align: left;
        margin-top: 24px;
    }

    .preview-brand-block h2 {
        font-size: 34px;
    }

    .meta-grid {
        margin-top: 20px;
    }

    .totals {
        width: 100%;
    }

    .mobile-actions {
        display: block;
    }
}



.flatpickr-calendar {
  border: 1px solid #e5e7eb !important;
  border-radius: 28px !important;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.16) !important;
  padding: 18px !important;
  font-family: inherit !important;
}

.flatpickr-months {
  margin-bottom: 10px;
}

.flatpickr-current-month {
  font-size: 20px !important;
  font-weight: 800 !important;
}

.flatpickr-weekday {
  color: #777 !important;
  font-weight: 800 !important;
}

.flatpickr-day {
  border-radius: 14px !important;
  font-weight: 700 !important;
}

.flatpickr-day:hover {
  background: #f1f1f3 !important;
  border-color: #f1f1f3 !important;
}

.flatpickr-day.today {
  border-color: #111 !important;
}

.flatpickr-day.selected {
  background: #111 !important;
  border-color: #111 !important;
  color: white !important;
}

.hidden {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.25);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  z-index: 9999;
}

.email-modal {
  width: min(520px, 92vw);
  background: white;
  border-radius: 32px;
  padding: 34px;
  box-shadow: 0 30px 90px rgba(0,0,0,.25);
}

.email-modal h2 {
  font-size: 34px;
  margin-bottom: 24px;
}

.email-modal label {
  display: block;
  font-weight: 800;
  color: #777;
  margin: 18px 0 8px;
}

.modal-actions {
  display: flex;
  gap: 14px;
  justify-content: flex-end;
  margin-top: 28px;
}


/* ===========================
   PDF Invoice
=========================== */

.print-invoice{
    width: 210mm;
    min-height: 297mm;
    padding: 42px 48px;
    background:#fff;
    color:#111;
    font-family:-apple-system,BlinkMacSystemFont,"SF Pro Display","Helvetica Neue",Arial,sans-serif;
    font-size:14px;
    line-height:1.5;
}

.print-invoice h1,
.print-invoice h2,
.print-invoice h3{
    margin:0;
    font-weight:700;
}

.print-invoice hr{
    border:none;
    border-top:1px solid #ececec;
    margin:32px 0;
}

.invoice-top{
    display:flex;
    justify-content:space-between;
    align-items:flex-start;
    margin-bottom:48px;
}

.invoice-title-block{
    text-align:right;
}

.invoice-title-block h3{
    font-size:32px;
}

.invoice-title-block p{
    font-size:22px;
    color:#666;
}


.pdf-logo{
    width:92px;
    height:92px;
    object-fit:contain;
    margin-bottom:18px;
}

.business-preview p{
    margin:4px 0;
    color:#444;
}

.invoice-meta{
    display:grid;
    grid-template-columns:1fr 240px;
    margin:34px 0;
}

.meta-grid{
    display:grid;
    grid-template-columns:90px 1fr;
    gap:8px 16px;
    font-size:14px;
}

.bill-section{
    margin:34px 0;
}

.invoice-table{
    width:100%;
    border-collapse:collapse;
}

.invoice-table th{
    text-align:left;
    font-size:13px;
    color:#888;
    padding-bottom:12px;
    border-bottom:1px solid #ececec;
}

.invoice-table td{
    padding:18px 0;
    border-bottom:1px solid #f1f1f1;
}

.invoice-table th:nth-child(2),
.invoice-table th:nth-child(3),
.invoice-table th:nth-child(4),
.invoice-table td:nth-child(2),
.invoice-table td:nth-child(3),
.invoice-table td:nth-child(4){
    text-align:right;
}

.totals{
    width:320px;
    margin-left:auto;
    margin-top:30px;
}

.totals div{
    display:flex;
    justify-content:space-between;
    margin:8px 0;
}

.totals .grand{
    border-top:2px solid #111;
    padding-top:16px;
    margin-top:12px;
    font-size:28px;
    font-weight:700;
}

.preview-notes{
    margin-top:60px;
    max-width:430px;
}

.preview-notes .label{
    font-size:12px;
    letter-spacing:.08em;
    color:#888;
    font-weight:700;
    margin-bottom:8px;
}

.simple-footer {
    margin-top: 40px;
    padding-top: 18px;
    border-top: 1px solid #ececec;
    text-align: center;
    font-size: 12px;
    color: #999;
}


@media (max-width: 760px) {
    .item-row input[data-field="qty"]::before,
    .item-row input[data-field="rate"]::before {
        content: "";
    }

    .item-row input[data-field="qty"] {
        position: relative;
    }

    .item-row input[data-field="qty"],
    .item-row input[data-field="rate"] {
        padding-top: 24px;
    }

    .item-row input[data-field="qty"]::placeholder {
        color: #999;
    }

    .item-row input[data-field="rate"]::placeholder {
        color: #999;
    }
}



