@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

html {
  scrollbar-gutter: stable;
}

:root {
  --primary: #f59e0b;       /* Premium Amber */
  --primary-hover: #d97706; /* Darker Amber */
  --success: #10b981;       /* Emerald */
  --danger: #ef4444;        /* Rose/Red */
  --text: #f3f4f6;          /* Near white */
  --text-dim: #a1a1aa;      /* Zinc 400 */
  --bg-body: #09090b;       /* Zinc 950 (very deep, sleek) */
  --bg-main: #18181b;       /* Zinc 900 */
  --bg-card: #18181b;       /* Zinc 900 */
  --bg-input: #09090b;      /* Zinc 950 */
  --border: #27272a;        /* Zinc 800 */
  --sidebar-bg: #09090b;    /* Zinc 950 */
  --font: 'Outfit', -apple-system, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg-body);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}

/* ── APP LAYOUT ── */
#app { display: flex; min-height: 100vh; }

/* ── SIDEBAR ── */
.sidebar {
  width: 200px;
  background: var(--sidebar-bg);
  position: fixed;
  height: 100vh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  z-index: 10;
}
.sidebar-header {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-header img { height: 26px; }
.nav-links { list-style: none; padding: 12px 8px; flex: 1; }
.nav-links li { margin-bottom: 4px; }
.nav-links a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; color: var(--text-dim); text-decoration: none;
  font-size: 13px; font-weight: 500; border-radius: 8px;
  transition: all .2s ease;
}
.nav-links li:hover a { background: rgba(255, 255, 255, 0.04); color: #fff; }
.nav-links li.active a { background: rgba(245, 158, 11, 0.08); color: var(--primary); font-weight: 600; }
.sidebar-footer {
  padding: 12px; text-align: center; font-size: 11px;
  color: #444; border-top: 1px solid var(--border);
}

/* ── MAIN ── */
.main-content {
  margin-left: 200px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: calc(100% - 200px);
}
.main-content-inner {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 36px;
}

.view { display: none; animation: fadeIn .2s cubic-bezier(0.4, 0, 0.2, 1); }
.view.active { display: block; }
@keyframes fadeIn { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }

/* ── PRIMARY TABS (InvoiceHome Style) ── */
.primary-tabs {
  display: flex;
  margin-bottom: -1px;
  padding-left: 4px;
  gap: 4px;
}
.tab-btn {
  background: #0d0d10;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-bottom: none;
  padding: 10px 20px;
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  font-family: var(--font);
}
.tab-btn:hover {
  background: rgba(255, 255, 255, 0.02);
  color: #fff;
}
.tab-btn.active {
  background: var(--bg-card);
  color: #fff;
  border-color: var(--border);
  border-bottom: 1px solid var(--bg-card);
  z-index: 2;
}

/* ── SUB VIEWS ── */
.sub-view { display: none; }
.sub-view.active { display: block; animation: fadeIn .15s ease; }

/* ── HEADER ── */
.view-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.view-header h1 { font-size: 24px; font-weight: 700; color: #fff; letter-spacing: -0.5px; }

/* ── CARDS ── */
.card {
  background: var(--bg-card); border-radius: 12px;
  border: 1px solid var(--border); padding: 24px; margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.stats-cards { display: grid; grid-template-columns: repeat(3,1fr); gap: 16px; margin-top: 16px; margin-bottom: 24px; }
.stat-card {
  display: flex; align-items: center; gap: 16px;
  background: linear-gradient(145deg, #1f1f23, #18181b);
  border-radius: 12px; border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
  cursor: default;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  box-shadow: inset 0 2px 4px rgba(255,255,255,0.05);
}
.stat-icon.paid { background: rgba(16,185,129,.1); color: var(--success); border: 1px solid rgba(16,185,129,0.15); }
.stat-icon.unpaid { background: rgba(239,68,68,.1); color: var(--danger); border: 1px solid rgba(239,68,68,0.15); }
.stat-icon.balance { background: rgba(245,158,11,.1); color: var(--primary); border: 1px solid rgba(245,158,11,0.15); }
.stat-details h3 { font-size: 11px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 4px; }
.stat-value { font-size: 22px; font-weight: 700; color: #fff; font-family: var(--font); }

/* ── CARD HEADER ── */
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header h2 { font-size: 16px; font-weight: 600; color: #fff; }
.view-all { color: var(--primary); text-decoration: none; font-size: 12px; }

/* ── TABLE ── */
.table-responsive { overflow-x: auto; }
.invoice-table { width: 100%; border-collapse: collapse; }
.invoice-table th, .invoice-table td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.invoice-table th {
  font-weight: 600; color: var(--text-dim); font-size: 11px;
  text-transform: uppercase; letter-spacing: 1px; white-space: nowrap;
  border-bottom: 1.5px solid var(--border);
}
.invoice-table th i { font-size: 9px; color: var(--text-dim); margin-left: 5px; transition: color 0.15s ease, font-size 0.15s ease; }
.invoice-table th i.active { color: var(--primary); font-size: 11px; text-shadow: 0 0 6px rgba(245, 158, 11, 0.6); }
.invoice-table th:hover { color: var(--text); }
.invoice-table th:hover i:not(.active) { color: var(--text); }
.invoice-table tbody tr { cursor: pointer; transition: background .15s ease; }
.invoice-table tbody tr:hover { background: rgba(255,255,255,.015); }

/* Checkbox Style in Table */
.invoice-table input[type="checkbox"] {
  appearance: none;
  background-color: transparent;
  margin: 0;
  font: inherit;
  color: #fff;
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  transform: translateY(-1px);
  display: grid;
  place-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}
.invoice-table input[type="checkbox"]::before {
  content: "\f00c";
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 10px;
  color: #000;
  transform: scale(0);
  transition: 120ms transform ease-in-out;
}
.invoice-table input[type="checkbox"]:checked::before {
  transform: scale(1);
}
.invoice-table input[type="checkbox"]:checked {
  border-color: var(--primary);
  background-color: var(--primary);
}

/* Status colors directly on Paid text column */
.text-paid-green { color: var(--success) !important; font-weight: 600; }
.text-paid-blue { color: #3b82f6 !important; font-weight: 600; }
.text-paid-yellow { color: var(--primary) !important; font-weight: 600; }
.text-paid-red { color: var(--danger) !important; font-weight: 600; }

.badge { padding: 3px 8px; border-radius: 20px; font-size: 10px; font-weight: 600; }
.badge.paid { background: rgba(16,185,129,.15); color: #34d399; }
.badge.unpaid { background: rgba(239,68,68,.15); color: #f87171; }
.badge.partial { background: rgba(234,179,8,.15); color: #fbbf24; }

/* ── FILTER PILLS (Screenshot Style) ── */
.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.pill-btn {
  background: rgba(255, 255, 255, 0.03); color: var(--text-dim); border: 1px solid var(--border);
  padding: 6px 14px; border-radius: 20px; font-size: 12px; font-weight: 500;
  cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font); transition: all .2s ease;
}
.pill-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; border-color: rgba(255,255,255,0.15); }
.pill-btn.active { background: var(--primary); color: #000; border-color: var(--primary); font-weight: 600; }

.pill-badge {
  padding: 2px 7px; border-radius: 10px; font-size: 10px; font-weight: 700; transition: all .2s ease;
}
.pill-btn .pill-badge { background: rgba(255, 255, 255, 0.1); color: #fff; }
.pill-btn.active .pill-badge { background: rgba(0, 0, 0, 0.15); color: #000; }

.pill-badge.pink { background: rgba(244, 63, 94, 0.15) !important; color: #f43f5e !important; }
.pill-badge.blue { background: rgba(59, 130, 246, 0.15) !important; color: #3b82f6 !important; }
.pill-badge.yellow { background: rgba(245, 158, 11, 0.15) !important; color: var(--primary) !important; }
.pill-badge.green { background: rgba(16, 185, 129, 0.15) !important; color: var(--success) !important; }
.pill-badge.grey { background: rgba(161, 161, 170, 0.15) !important; color: var(--text-dim) !important; }
.pill-badge.black { background: rgba(0, 0, 0, 0.3) !important; color: #fff !important; }

/* ── TABLE ACTIONS ROW ── */
.table-actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  gap: 16px;
}
.table-actions-row .search-bar {
  flex: 1;
  margin-bottom: 0;
}

/* ── SEARCH ── */
.search-bar { margin-bottom: 0; }
.search-wrapper {
  position: relative;
  width: 100%;
}
.search-wrapper .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 13px;
  pointer-events: none;
}
.search-bar input {
  width: 100%; padding: 8px 12px 8px 38px; background: var(--bg-input);
  border: 1px solid var(--border); border-radius: 8px; color: var(--text);
  font-size: 13px; font-family: var(--font); height: 38px;
  transition: all .2s ease;
}
.search-bar input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15); }
.search-bar input::placeholder { color: #555; }

/* ── SUMMARY FOOTER (My Invoices) ── */
.table-summary {
  margin-top: 20px;
  background: rgba(255, 255, 255, 0.01);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, 0.01);
}
.table-summary .sum-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; font-size: 13px; font-weight: 500; color: var(--text-dim);
}
.table-summary .sum-row span:last-child {
  color: #fff; font-weight: 600;
}
.table-summary .sum-row:not(:last-child) {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}
.table-summary .sum-row.font-bold span:last-child {
  font-size: 15px;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; font-family: var(--font); transition: all .2s ease;
  white-space: nowrap;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(0);
}
.btn-primary { background: var(--primary); color: #000; box-shadow: 0 2px 8px rgba(245, 158, 11, 0.15); }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25); }
.btn-secondary { background: #27272a; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: #3f3f46; }
.btn-success { background: var(--success); color: #fff; }
.btn-ai {
  background: rgba(245, 158, 11, 0.08);
  color: var(--primary);
  border: 1px solid rgba(245, 158, 11, 0.25) !important;
}
.btn-ai:hover {
  background: rgba(245, 158, 11, 0.18);
  border-color: var(--primary) !important;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.15);
}

/* ── AI dropzone wrapper ── */
.ai-dropzone-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 158, 11, 0.06);
  color: var(--primary);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: 8px;
  padding: 0 16px;
  height: 38px;
  width: 170px;
  min-width: 170px;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  position: relative;
  user-select: none;
  box-sizing: border-box;
}

.ai-dropzone-wrapper.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-dropzone-wrapper:not(.disabled):hover,
.ai-dropzone-wrapper:not(.disabled).dragover {
  height: 60px;
  width: 260px;
  min-width: 260px;
  background: rgba(245, 158, 11, 0.12);
  border: 2px dashed var(--primary);
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.2);
  transform: translateY(-2px);
}

.ai-dropzone-wrapper.dragover {
  background: rgba(245, 158, 11, 0.2) !important;
  border-color: #f59e0b !important;
  animation: pulse-border 1.5s infinite;
}

@keyframes pulse-border {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  70% { box-shadow: 0 0 0 10px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}

.ai-dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: all 0.3s ease;
}

.ai-dropzone-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  transition: all 0.3s ease;
}

.ai-dropzone-main i {
  font-size: 16px;
  transition: all 0.3s ease;
}

.ai-dropzone-sub {
  font-size: 11px;
  color: var(--text-dim, #9ca3af);
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
  margin-top: 0;
  font-weight: 500;
  white-space: nowrap;
}

.ai-dropzone-wrapper:not(.disabled):hover .ai-dropzone-sub,
.ai-dropzone-wrapper:not(.disabled).dragover .ai-dropzone-sub {
  opacity: 1;
  max-height: 16px;
  margin-top: 4px;
}

.ai-dropzone-wrapper:not(.disabled):hover .ai-dropzone-main i,
.ai-dropzone-wrapper:not(.disabled).dragover .ai-dropzone-main i {
  transform: rotate(15deg) scale(1.15);
  color: #fff;
  text-shadow: 0 0 8px var(--primary);
}
.btn-icon {
  width: 32px; height: 32px; border-radius: 8px; display: inline-flex;
  align-items: center; justify-content: center; border: 1px solid var(--border); cursor: pointer;
  background: rgba(255, 255, 255, 0.03); color: var(--text-dim); font-size: 12px; transition: all .2s ease;
}
.btn-icon:hover { background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.3); color: var(--success); transform: scale(1.05); }
.btn-icon.delete:hover { background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.3); color: var(--danger); }

/* ── ACTION BTNS ── */
.action-btns { display: flex; gap: 4px; }

/* ── FORM (Invoice Create) ── */
.invoice-form-wrapper { max-width: 780px; margin: 0 auto; }
.invoice-form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 28px 32px;
  color: var(--text);
}
.invoice-form-card h3 {
  font-size: 13px; font-weight: 700; color: #fff; margin-bottom: 10px;
}
.invoice-form-card h3 i { color: var(--primary); margin-right: 5px; }
.fc {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 5px; background: var(--bg-input); color: #fff;
  font-family: var(--font); font-size: 13px;
  transition: all .15s;
}
.fc:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(234,179,8,.12); }
.fc::placeholder { color: #555; }
textarea.fc { resize: vertical; }
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
select.fc {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg fill='white' height='24' viewBox='0 0 24 24' width='24' xmlns='http://www.w3.org/2000/svg'><path d='M7 10l5 5 5-5z'/><path d='M0 0h24v24H0z' fill='none'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px;
  padding-right: 30px;
}

textarea.fc-textarea {
  height: 95px;
  resize: none;
}
#to-company {
  height: 114px;
  resize: none;
}

/* From + Logo Row */
.form-top-row {
  display: grid; grid-template-columns: 1fr 180px; gap: 20px;
  margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border);
}

/* Bill To + Meta */
.form-bill-row {
  display: grid; grid-template-columns: 1fr 220px; gap: 20px;
  margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--border);
}
.form-meta { display: flex; flex-direction: column; gap: 6px; width: 100%; min-width: 0; max-width: 100%; }
.form-meta .fg {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 0;
}
.form-meta label {
  width: 90px;
  text-align: right;
  margin-bottom: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
}
.form-meta input, .form-meta select {
  flex: 1;
}

/* Table Responsive Wrapper */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Items Table */
.fi-table { width: 100%; border-collapse: collapse; margin-bottom: 4px; }
.fi-table th {
  font-size: 11px; font-weight: 700; color: #f3f4f6; padding: 10px 8px;
  border-bottom: 1.5px solid var(--border); text-align: left;
  letter-spacing: 0.5px;
}
.fi-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.fi-table input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 5px;
  background: var(--bg-input); color: #fff; font-family: var(--font); font-size: 13px;
}
.fi-table input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(234,179,8,.12); }
.fi-table .amt {
  text-align: right; font-weight: 600; color: #fff;
  padding: 8px 10px; font-size: 13px; white-space: nowrap;
}

.btn-add-item {
  width: 100%; padding: 10px; border: none;
  background: var(--primary); color: #1a1a1a;
  font-size: 13px; font-weight: 700; cursor: pointer; border-radius: 6px;
  font-family: var(--font); transition: all .15s;
  margin-bottom: 20px;
}
.btn-add-item:hover { background: var(--primary-hover); }

.btn-rm-item {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25) !important;
  color: var(--danger);
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s ease;
  padding: 6px 12px;
  border-radius: 6px;
}
.btn-rm-item:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: var(--danger) !important;
  color: #f87171;
  text-decoration: none;
  transform: none;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.15);
}

/* Summary */
.f-summary {
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.s-row {
  width: 300px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text);
}
.s-row.total {
  font-size: 16px;
  font-weight: 700;
  border-top: 1.5px solid var(--border);
  margin-top: 6px;
  padding-top: 10px;
  color: var(--primary);
}
.s-row.balance { font-weight: 700; color: var(--danger); font-size: 14px; }
.s-row .inline-input { width: 80px; text-align: right; }

/* Bottom row (Terms + Signature) */
.form-bottom-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
}
.sig-box, .logo-box {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 500;
  transition: all .2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 95px;
  height: 95px;
  background: rgba(255, 255, 255, 0.03);
}
.sig-box:hover, .logo-box:hover { border-color: var(--primary); color: var(--primary); background: rgba(255, 255, 255, 0.07); }
.sig-box i, .logo-box i { font-size: 22px; }

/* Save Button */
.btn-save-main {
  display: block; width: 100%; padding: 14px; font-size: 15px; font-weight: 700;
  background: var(--primary); color: #1a1a1a; border: none; border-radius: 8px;
  cursor: pointer; margin-top: 14px; font-family: var(--font); transition: all .15s;
  letter-spacing: 0.3px;
  text-align: center;
}
.btn-save-main:hover { background: var(--primary-hover); }



/* ── PREVIEW ── */
.preview-toolbar {
  background: #4b5563; padding: 8px 14px; border-radius: 8px 8px 0 0;
  display: flex; gap: 6px; flex-wrap: wrap;
  position: sticky;
  top: 64px;
  z-index: 90;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
@media (max-width: 768px) {
  .preview-toolbar {
    top: 56px;
  }
}
.preview-container {
  background: #555; border-radius: 0 0 8px 8px; padding: 24px 12px;
  overflow-x: auto; display: flex; justify-content: center;
}
#preview-paper {
  width: 210mm;
  flex-shrink: 0;
  position: relative;
}
.preview-page {
  box-sizing: border-box;
  background: #fff;
  width: 210mm;
  height: 297mm;
  padding: 20mm;
  margin-bottom: 20px;
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
  position: relative;
  color: #000;
  font-family: 'Outfit', -apple-system, sans-serif;
}
.preview-page:last-child {
  margin-bottom: 0;
}
.paid-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  max-width: 450px;
  z-index: 5;
  user-select: none;
  pointer-events: none;
}
.paid-watermark img {
  width: 100%;
  height: auto;
  display: block;
}

/* ── SETTINGS ── */
.form-control {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-input); color: var(--text); font-family: var(--font); font-size: 12px;
}
.form-control:focus { outline: none; border-color: var(--primary); }
.form-control::placeholder { color: #555; }
input[type="file"].form-control {
  padding: 4px 6px;
  cursor: pointer;
}
input[type="file"].form-control::file-selector-button {
  background: var(--border);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  margin-right: 8px;
  transition: background 0.15s, border-color 0.15s;
}
input[type="file"].form-control::file-selector-button:hover {
  background: #3f3f46;
  border-color: #52525b;
}
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 500; color: var(--text); }
.header-actions { display: flex; gap: 6px; }

/* ── ADVANCED REPORTS ── */
.reports-advanced-card {
  padding: 16px 24px; margin-bottom: 24px;
}
.report-filters-row {
  display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
}
.report-filter-group {
  display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 150px;
}
.report-filter-group label {
  font-size: 11px; font-weight: 600; color: var(--text-dim); text-transform: uppercase;
}
.report-filter-group .input-with-icon {
  position: relative;
}
.report-filter-group .input-with-icon i {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-dim); pointer-events: none;
}
.report-filter-group .input-with-icon input {
  padding-left: 36px; height: 38px;
}
.report-filter-group select { height: 38px; padding-top: 0; padding-bottom: 0; }
.search-btn-group { flex: 0 0 auto; min-width: auto; }

.report-tabs-actions {
  display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 0; flex-wrap: wrap; gap: 12px;
}
.r-tabs {
  display: flex;
}
.r-tab {
  background: #27272a; color: #a1a1aa; border: 1px solid var(--border); border-bottom: none; 
  padding: 10px 18px; font-size: 12px; font-weight: 600; cursor: pointer;
  border-radius: 8px 8px 0 0; margin-right: 4px; display: inline-flex; align-items: center; gap: 8px; font-family: var(--font); transition: all 0.2s;
}
.r-tab:hover { background: #3f3f46; color: #fff; }
.r-tab.active { background: var(--bg-card); color: #fff; border-color: var(--border); position: relative; }
.r-tab.active::after {
  content: ''; position: absolute; bottom: -1px; left: 0; right: 0; height: 1px; background: var(--bg-card);
}
.r-badge { background: #18181b; color: #fff; padding: 2px 6px; border-radius: 12px; font-size: 10px; border: 1px solid #3f3f46; }

.r-actions {
  display: flex; gap: 6px; margin-bottom: 8px; margin-right: 12px;
}
.r-action-btn {
  background: transparent; color: var(--text-dim); border: 1px solid var(--border); padding: 8px 14px; border-radius: 6px;
  font-size: 12px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-family: var(--font);
  transition: all 0.2s;
}
.r-action-btn:hover { background: rgba(255,255,255,0.05); }
.r-action-btn.pdf:hover { color: #f43f5e; border-color: rgba(244,63,94,0.3); background: rgba(244,63,94,0.05); }
.r-action-btn.excel:hover { color: #10b981; border-color: rgba(16,185,129,0.3); background: rgba(16,185,129,0.05); }
.r-action-btn.print:hover { color: #06b6d4; border-color: rgba(6,182,212,0.3); background: rgba(6,182,212,0.05); }

.r-action-btn.pdf i { color: #f43f5e; }
.r-action-btn.excel i { color: #10b981; }
.r-action-btn.print i { color: #06b6d4; }

.report-table th { font-size: 10px; color: var(--text-dim); }
.report-table td { font-size: 12px; }
.report-table tbody tr { border-bottom: 1px solid rgba(255, 255, 255, 0.05); }

.report-table tfoot {
  background: rgba(255,255,255,0.02);
  border-top: 2px solid rgba(255,255,255,0.1);
}
.report-totals-row td {
  padding: 16px 10px !important;
  font-size: 13px;
  vertical-align: middle;
}


/* ── MODAL (Payments Overlay) ── */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal.active {
  display: flex;
}
.modal-content {
  width: 540px;
  max-width: 95%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.modal-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin: 0;
}
.btn-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s;
}
.btn-close:hover {
  color: #fff;
}
.modal input[type="checkbox"] {
  accent-color: var(--primary);
  width: 15px;
  height: 15px;
  cursor: pointer;
}
.pm-summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.pm-sum-box {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
}
.pm-sum-box .label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.pm-sum-box .value {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
}
.pm-sum-box .value.paid {
  color: var(--success);
}
.pm-sum-box .value.balance {
  color: var(--danger);
}
.section-title {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
  margin-bottom: 10px;
}
.pm-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.pm-history-table th {
  text-align: left;
  color: var(--text-dim);
  font-weight: 600;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.pm-history-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.pm-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}
.pm-form-row .fg {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pm-form-row label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
}

@media (max-width: 768px) {
  #app {
    flex-direction: column !important;
  }

  /* Native-feel Bottom Navigation */
  .sidebar { 
    position: fixed; bottom: 0; left: 0; right: 0; height: 60px; width: 100%; 
    flex-direction: row; border-right: none; border-top: 1px solid rgba(255, 255, 255, 0.08); 
    background: rgba(9, 9, 11, 0.85); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    z-index: 100; box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
  }
  .sidebar-header, .sidebar-footer { display: none; }
  .nav-links { display: flex; flex-direction: row; justify-content: space-around; align-items: center; padding: 0 8px; width: 100%; }
  .nav-links li { margin: 0; flex: 1; }
  .nav-links a { 
    flex-direction: column; padding: 6px 0; font-size: 9px; gap: 4px; 
    text-align: center; border: none; border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .nav-links a i { font-size: 16px; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); }
  .nav-links li.active a { background: rgba(245, 158, 11, 0.1); color: var(--primary); }
  .nav-links li.active a i { transform: translateY(-2px); text-shadow: 0 2px 6px rgba(245, 158, 11, 0.4); }
  
  /* Main Container Layout */
  .main-content { margin-left: 0; margin-bottom: 60px; padding: 0; width: 100%; }
  .main-content-inner { max-width: 100%; padding: 10px 8px !important; }
  
  /* Headers and Actions */
  .view-header { flex-direction: column; align-items: flex-start; gap: 4px !important; margin-bottom: 12px !important; }
  .view-header h1 { font-size: 18px !important; letter-spacing: -0.3px; }
  
  .header-actions { flex-wrap: wrap; width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .header-actions .btn { width: 100%; justify-content: center; padding: 8px 12px; font-size: 13px; }
  #btn-cancel-invoice { grid-column: 1 / -1; }
  .ai-dropzone-wrapper {
    width: 100% !important;
    min-width: 0 !important;
    grid-column: 1 / -1;
    height: 42px !important;
  }
  .ai-dropzone-wrapper:not(.disabled):hover,
  .ai-dropzone-wrapper:not(.disabled).dragover {
    width: 100% !important;
    min-width: 0 !important;
    height: 60px !important;
  }
  
  /* Compact Table Actions Row (Search & Action Buttons Side-by-Side) */
  .table-actions-row { 
    flex-direction: row !important; 
    align-items: center !important; 
    gap: 6px !important; 
    margin-bottom: 12px !important; 
  }
  .table-actions-row .search-bar { 
    flex: 1; 
  }
  .table-actions-row > div:last-child { 
    display: flex !important; 
    width: auto !important; 
    gap: 4px !important; 
  }
  .table-actions-row .btn { 
    width: auto !important; 
    padding: 6px 10px !important; 
    font-size: 12px !important; 
    border-radius: 6px !important; 
    height: 34px !important;
    gap: 4px !important;
  }
  
  /* Premium Compact Search Bar for Mobile */
  .search-wrapper input { 
    padding: 6px 10px 6px 30px !important;
    font-size: 13px !important;
    height: 34px !important;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03); 
  }
  .search-wrapper .search-icon { left: 10px !important; font-size: 12px !important; }
  
  /* Cards & Forms */
  .invoice-form-card, .card { padding: 12px 10px !important; border-radius: 8px !important; margin-bottom: 12px !important; box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
  
  /* 3-Column Compact Stats Row */
  .stats-cards { 
    grid-template-columns: repeat(3, 1fr) !important; 
    gap: 6px !important; 
    margin-top: 8px !important;
    margin-bottom: 16px !important;
  }
  .stat-card { 
    flex-direction: column !important; 
    align-items: center !important; 
    text-align: center !important; 
    padding: 8px 4px !important; 
    border-radius: 10px !important;
    gap: 4px !important;
  }
  .stat-icon {
    width: 28px !important;
    height: 28px !important;
    font-size: 12px !important;
    border-radius: 8px !important;
  }
  .stat-details h3 {
    font-size: 8px !important;
    letter-spacing: 0.2px !important;
    margin-bottom: 2px !important;
  }
  .stat-value {
    font-size: 11px !important;
    font-weight: 700 !important;
  }
  
  /* Side-by-side Form Layouts */
  .form-top-row {
    grid-template-columns: minmax(0, 1fr) 100px !important;
    gap: 10px !important;
    padding-bottom: 10px !important;
    margin-bottom: 12px !important;
  }
  .form-bill-row {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px !important;
    padding-bottom: 10px !important;
    margin-bottom: 12px !important;
  }
  .form-bottom-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 10px !important;
    padding-top: 10px !important;
    margin-top: 12px !important;
  }
  .form-meta label { text-align: left; width: 100%; margin-bottom: 2px; font-size: 11px; }
  .form-meta .fg { flex-direction: column; align-items: flex-start; gap: 4px; margin-bottom: 8px; }
  .form-group { margin-bottom: 10px !important; }
  
  /* Tab and Filter Styling (Compact / Flex Proportion) */
  .primary-tabs { 
    display: flex;
    flex-wrap: nowrap;
    padding-bottom: 0;
    border-bottom: 1px solid var(--border); 
    margin-bottom: 12px;
    gap: 2px;
  }
  .tab-btn { 
    flex: 1;
    justify-content: center;
    padding: 8px 6px !important; 
    font-size: 11.5px !important;
    border-radius: 6px 6px 0 0 !important;
    white-space: nowrap;
    font-weight: 500;
    gap: 4px;
  }
  .tab-btn i {
    font-size: 11.5px !important;
  }
  .tab-text-desktop {
    display: none;
  }
  .btn-text-desktop {
    display: none;
  }
  
  /* Horizontal Scrolling Filters */
  .filter-pills { 
    overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px !important; margin-bottom: 8px !important;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
    gap: 4px !important;
  }
  .filter-pills::-webkit-scrollbar { display: none; }
  .pill-btn { 
    flex-shrink: 0; 
    padding: 4px 10px !important; 
    font-size: 11px !important; 
    border-radius: 6px !important;
    height: 26px !important;
  }
  .pill-badge {
    padding: 1px 4px !important;
    font-size: 9px !important;
    border-radius: 4px !important;
  }
  
  /* Subtotals & Tables */
  .f-summary { align-items: stretch; padding-top: 14px; }
  .s-row { width: 100%; padding: 6px 0; font-size: 13px; }
  .s-row.total { font-size: 16px; padding-top: 10px; margin-top: 6px; }
  
  .table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; margin-bottom: 12px; }
  .invoice-table th, .invoice-table td { padding: 8px 6px !important; white-space: nowrap; font-size: 12px; }
  
  /* Form Items Table Optimization */
  .fi-table { min-width: 500px; /* force scroll */ }
  .fi-table th { font-size: 11px; padding: 8px 6px !important; }
  .fi-table td { padding: 6px 4px !important; }
  .fi-table input, .fi-table textarea.item-desc {
    font-size: 12px !important;
    padding: 4px 6px !important;
    border-radius: 4px;
    height: 28px !important;
  }
  .fi-table textarea.item-desc {
    height: 28px !important;
    min-height: 28px !important;
  }
  .btn-add-item { padding: 10px; font-size: 13px; border-radius: 8px; margin-top: 8px; }
  
  /* Better preview mode on mobile */
  .preview-toolbar { 
    padding: 10px; gap: 6px; overflow-x: auto; flex-wrap: nowrap; 
    -webkit-overflow-scrolling: touch; background: var(--bg-card);
    border-radius: 10px 10px 0 0;
  }
  .preview-toolbar .btn { flex-shrink: 0; padding: 8px 12px; border-radius: 6px; }
  .preview-container { padding: 12px 8px; overflow-x: auto; justify-content: flex-start; -webkit-overflow-scrolling: touch; border-radius: 0 0 10px 10px; }
  #preview-paper { 
    min-width: 700px; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.15);
  }
  
  /* Modals */
  .modal-content { width: 95%; padding: 16px; border-radius: 16px; }
  .pm-form-row { grid-template-columns: 1fr; gap: 12px; }
  .pm-summary-grid { grid-template-columns: 1fr; gap: 8px; }
  .pm-sum-box { padding: 12px; border-radius: 10px; }
  
  /* Reset inputs for normal layout density */
  .fc, .form-control { 
    font-size: 13px !important; 
    padding: 6px 10px !important;
    border-radius: 6px;
    height: 34px !important;
  }
  .fc-textarea { height: 80px; }
  #to-company { height: 90px; }
  .btn-save-main { padding: 14px; font-size: 14px; border-radius: 10px; box-shadow: 0 2px 10px rgba(245, 158, 11, 0.2); }
  
  /* Fix meta box heights */
  .sig-box, .logo-box { min-height: 70px !important; height: 70px !important; border-radius: 10px; padding: 12px; font-size: 11px; }
  .sig-box i, .logo-box i { font-size: 14px !important; margin-bottom: 4px; }

  /* Reports Mobile (2-Column Compact Layout) */
  .reports-advanced-card { padding: 12px 10px !important; margin-bottom: 12px !important; }
  .report-filters-row { 
    display: grid !important; 
    grid-template-columns: 1fr 1fr !important; 
    gap: 8px 10px !important; 
  }
  .report-filter-group { 
    min-width: 0 !important; 
    gap: 3px !important;
  }
  .report-filter-group label {
    font-size: 9.5px !important;
    margin-bottom: 1px !important;
  }
  .report-filter-group .input-with-icon input {
    height: 34px !important;
    padding-left: 32px !important;
  }
  .report-filter-group .input-with-icon i {
    left: 10px !important;
    font-size: 11px !important;
  }
  .report-filter-group select {
    height: 34px !important;
  }
  .search-btn-group { grid-column: 1 / -1 !important; width: 100% !important; }
  .search-btn-group .btn { width: 100% !important; justify-content: center !important; height: 36px !important; padding: 8px 12px !important; }

  .report-tabs-actions { flex-direction: column; gap: 10px; }
  .r-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; flex-wrap: nowrap; width: 100%; }
  .r-tabs::-webkit-scrollbar { display: none; }
  .r-tab { flex-shrink: 0; padding: 8px 14px; font-size: 11px; }
  .r-actions { width: 100%; justify-content: stretch; gap: 6px; margin: 0; flex-wrap: wrap; }
  .r-action-btn { flex: 1; justify-content: center; padding: 8px 8px; font-size: 11px; }

  .report-table { min-width: 700px; }
  
  /* Financial Overview Chart Container & Placeholder overrides */
  .report-chart-card {
    margin-bottom: 12px !important;
  }
  .report-chart-card > div:last-child {
    height: 160px !important;
  }
  .chart-no-data-overlay {
    height: 160px !important;
  }
  .chart-no-data-overlay > div {
    padding: 12px 10px !important;
  }
  .chart-no-data-overlay i {
    font-size: 28px !important;
    margin-bottom: 4px !important;
  }
  .chart-no-data-overlay div div {
    font-size: 11px !important;
    line-height: 1.3 !important;
  }
  .chart-no-data-overlay div div:first-of-type {
    font-size: 13px !important;
    font-weight: 600 !important;
    margin-bottom: 2px !important;
  }

  /* Baris input item form bertumpuk di mobile */
  .fi-table {
    min-width: 0 !important;
    display: block !important;
    width: 100% !important;
  }
  .fi-table thead {
    display: none !important;
  }
  .fi-table tbody {
    display: block !important;
    width: 100% !important;
  }
  .fi-table tbody tr {
    display: grid !important;
    grid-template-columns: 2fr 3fr 3fr 38px !important;
    gap: 8px !important;
    padding: 12px 0 !important;
    border-bottom: 1px solid var(--border) !important;
  }
  .fi-table tbody tr td {
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    display: block !important;
    width: 100% !important;
  }
  .fi-table tbody tr td:first-child {
    grid-column: 1 / -1 !important;
    margin-bottom: 4px !important;
  }
  .fi-table .btn-rm-item {
    font-size: 0 !important;
    width: 100% !important;
    height: 28px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 6px !important;
  }
  .fi-table .btn-rm-item::before {
    content: "\f2ed" !important;
    font-family: "Font Awesome 6 Free" !important;
    font-weight: 900 !important;
    font-size: 13px !important;
    color: var(--danger) !important;
  }

  /* Kolom tersembunyi untuk tabel laporan di mobile */
  .report-table th:nth-child(2),
  .report-table td:nth-child(2), /* Document */
  .report-table th:nth-child(5),
  .report-table td:nth-child(5), /* Subtotal */
  .report-table th:nth-child(6),
  .report-table td:nth-child(6)  /* Tax */ {
    display: none !important;
  }

  /* Kolom tanggal tersembunyi untuk tabel invoice di mobile */
  .invoice-table th:nth-child(4),
  .invoice-table td:nth-child(4) {
    display: none !important;
  }

  /* Kaki tabel laporan diubah menjadi kartu ringkas */
  .report-table tfoot {
    display: block !important;
    border: none !important;
    background: var(--bg-card) !important;
    margin-top: 10px !important;
  }
  .report-table tfoot tr {
    display: flex !important;
    flex-direction: column !important;
    gap: 6px !important;
    padding: 12px 10px !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
  }
  .report-table tfoot td {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 4px 0 !important;
    border: none !important;
    width: 100% !important;
    background: transparent !important;
  }
  .report-table tfoot tr td:first-child {
    display: none !important;
  }
  #rs-subtotal::before { content: "Subtotal: "; font-weight: 500; color: var(--text-dim); }
  #rs-tax::before { content: "Pajak: "; font-weight: 500; color: var(--text-dim); }
  #rs-paid::before { content: "Total Terbayar: "; font-weight: 500; color: var(--text-dim); }
  #rs-total::before { content: "Total Tagihan: "; font-weight: 700; color: var(--text-dim); }

  /* Pembatasan lebar sel tabel & efek ellipsis */
  #all-invoices-body td:nth-child(2) {
    max-width: 100px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  #all-invoices-body td:nth-child(3) {
    max-width: 80px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  #customers-body td:nth-child(1) {
    max-width: 130px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  #report-table-body td:nth-child(1) {
    max-width: 100px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }
  #report-table-body td:nth-child(3) {
    max-width: 80px !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
  }

  /* Preview PDF terskala pas di mobile */
  .preview-container {
    padding: 8px 4px !important;
    overflow-x: hidden !important;
  }
  @media (min-width: 481px) {
    .preview-container {
      padding: 12px 8px !important;
    }
  }

  /* Tombol aksi massal tabel diperkecil */
  #btn-restore-selected, #btn-delete-selected {
    font-size: 0 !important;
    padding: 0 !important;
    width: 34px !important;
    height: 34px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 8px !important;
  }
  #btn-restore-selected i, #btn-delete-selected i {
    font-size: 13px !important;
    margin: 0 !important;
  }

  /* Modals dan PM Form layouts */
  .pm-summary-grid { 
    grid-template-columns: repeat(3, 1fr) !important; 
    gap: 6px !important; 
  }
  .pm-sum-box { 
    padding: 8px 4px !important; 
    border-radius: 8px !important; 
  }
  .pm-sum-box .label { 
    font-size: 8px !important; 
    letter-spacing: 0px !important;
  }
  .pm-sum-box .value { 
    font-size: 11px !important; 
  }
  .pm-form-row {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  .pm-form-row .fg:first-child {
    grid-column: span 2 !important;
  }
  #tax-form {
    display: grid !important;
    grid-template-columns: 2fr 1fr !important;
    gap: 10px !important;
  }
  #tax-modal-name {
    grid-column: 1 / -1 !important;
    width: 100% !important;
  }
  #tax-form label {
    grid-column: 1 / -1 !important;
    margin-top: 4px !important;
    justify-content: flex-start !important;
  }
  #tax-form button {
    grid-column: 1 / -1 !important;
    width: 100% !important;
  }
}

/* Logout Splash Overlay — Premium Design */
#logout-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 10, 12, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 99999;
  display: none;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.5s cubic-bezier(0.25, 1, 0.5, 1);
  pointer-events: none;
}

#logout-overlay.active {
  opacity: 1 !important;
  pointer-events: auto !important;
}

.logout-loading-layout {
  text-align: center;
  max-width: 400px;
  width: 90%;
}

.logout-icon-wrapper {
  position: relative;
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
}

#logout-overlay.active .logout-icon-wrapper {
  animation: welcomeAvatarSpring 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.logout-avatar {
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 22px;
  color: var(--text-dim, #9ca3af);
  position: relative;
  z-index: 2;
  box-shadow: none;
}

.logout-avatar-glow {
  display: none !important;
}

.logout-subtitle {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--text-dim, #9ca3af);
  margin-bottom: 6px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(15px);
}

#logout-overlay.active .logout-subtitle {
  animation: welcomeFadeInUp 0.8s cubic-bezier(0.25, 1, 0.5, 1) 0.2s both;
}

.logout-title {
  font-size: 18px;
  font-weight: 500;
  color: #fff;
  margin-bottom: 20px;
  letter-spacing: -0.2px;
  opacity: 0;
  transform: translateY(15px);
}

#logout-overlay.active .logout-title {
  animation: welcomeFadeInUp 0.8s cubic-bezier(0.25, 1, 0.5, 1) 0.4s both;
}

.logout-loader {
  width: 120px;
  height: 2px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 1px;
  margin: 0 auto 16px;
  overflow: hidden;
  position: relative;
  opacity: 0;
  transform: translateY(15px);
}

#logout-overlay.active .logout-loader {
  animation: welcomeFadeInUp 0.8s cubic-bezier(0.25, 1, 0.5, 1) 0.6s both;
}

.logout-loader-bar {
  width: 50px;
  height: 100%;
  background: var(--primary, #f59e0b);
  border-radius: 1px;
  position: absolute;
  left: -50px;
  animation: welcomeLoad 1.5s infinite ease-in-out;
}

.logout-status {
  font-size: 11px;
  color: var(--text-dim);
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  opacity: 0;
  transform: translateY(15px);
}

#logout-overlay.active .logout-status {
  animation: welcomeFadeInUp 0.8s cubic-bezier(0.25, 1, 0.5, 1) 0.8s both;
}

.fi-table textarea.item-desc {
  width: 100%;
  min-height: 38px;
  height: 38px;
  resize: vertical; /* Enable vertical resizing only */
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-input);
  color: #fff;
  font-family: var(--font);
  font-size: 13px;
  transition: border-color 0.15s;
  display: block;
}
.fi-table textarea.item-desc:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}

/* ── LOADING SPINNER & LOADING STATES ── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 6px;
}

/* Button loading state */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none !important;
  cursor: not-allowed;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-top: -8px;
  margin-left: -8px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Global Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(9, 9, 10, 0.75); /* Sleek backdrop */
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999990; /* Higher than modals to block everything when loading */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.loading-overlay .spinner-large {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(245, 158, 11, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

.loading-overlay .loading-text {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.5px;
}

/* Custom Toast Notification System */
#toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 9999999; /* Highest priority to show toasts above loading/modals */
  max-width: 380px;
  width: calc(100% - 48px);
  pointer-events: none;
}

.toast-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-radius: 12px;
  background: rgba(18, 18, 24, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #fff;
  font-family: var(--font, 'Outfit', sans-serif);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.toast-item.show {
  transform: translateX(0);
  opacity: 1;
}

.toast-item.hide {
  transform: translateX(120%);
  opacity: 0;
}

.toast-icon {
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast-success .toast-icon {
  color: var(--success, #10b981);
}

.toast-error .toast-icon {
  color: var(--danger, #ef4444);
}

.toast-warning .toast-icon {
  color: var(--warning, #f59e0b);
}

.toast-info .toast-icon {
  color: #3b82f6;
}

.toast-content {
  flex-grow: 1;
  line-height: 1.4;
  word-break: break-word;
}

.toast-close-btn {
  background: none;
  border: none;
  color: var(--text-dim, #9ca3af);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
  flex-shrink: 0;
}

.toast-close-btn:hover {
  color: #fff;
}

/* Custom Confirm Modal System */
.custom-confirm-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(9, 9, 11, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 999990; /* Modals should sit below loading-overlay */
  display: none;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.custom-confirm-backdrop.show {
  opacity: 1;
}

.custom-confirm-card {
  background: var(--bg-card, #18181b);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.08));
  border-radius: 16px;
  width: 90%;
  max-width: 420px;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
  transform: scale(0.9);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.custom-confirm-backdrop.show .custom-confirm-card {
  transform: scale(1);
}

.custom-confirm-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.custom-confirm-header .warning-icon {
  font-size: 22px;
  color: var(--warning, #f59e0b);
}

.custom-confirm-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  margin: 0;
  letter-spacing: -0.3px;
}

.custom-confirm-body {
  font-size: 13px;
  color: var(--text-dim, #a1a1aa);
  line-height: 1.5;
  margin-bottom: 20px;
}

.custom-confirm-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Avatar Header outline */
#header-avatar-img {
  border: 1.5px solid rgba(255, 255, 255, 0.25) !important;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 8px rgba(245, 158, 11, 0.1);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

#header-avatar-img:hover {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 1.5px rgba(245, 158, 11, 0.35), 0 0 12px rgba(245, 158, 11, 0.3);
  transform: scale(1.05);
}

/* Setting Avatar Preview outline */
#setting-avatar-preview {
  border: 1.5px solid rgba(255, 255, 255, 0.2) !important;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 4px 12px rgba(0, 0, 0, 0.25);
  transition: border-color 0.2s, box-shadow 0.2s;
}

#setting-avatar-preview:hover {
  border-color: var(--primary) !important;
  box-shadow: 0 0 0 1.5px rgba(245, 158, 11, 0.3), 0 6px 16px rgba(0, 0, 0, 0.35);
}

/* Premium Security Log Items */
.security-log-item {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 12px;
  line-height: 1.4;
  color: #e5e7eb;
}
.security-log-item:last-child {
  border-bottom: none;
}
.security-log-item .log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 3px;
}
.security-log-item .log-action {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 5px;
}
.security-log-item .log-time {
  font-size: 10px;
  color: #9ca3af;
}
.security-log-item .log-details {
  color: #9ca3af;
  font-size: 11px;
  word-break: break-word;
}
.security-log-item .log-ua {
  font-size: 9px;
  color: #6b7280;
  margin-top: 2px;
  font-style: italic;
}

/* Status colors for logs */
.security-log-item.log-success .log-action { color: #34d399; }
.security-log-item.log-warning .log-action { color: #fbbf24; }
.security-log-item.log-danger .log-action { color: #f87171; }
.security-log-item.log-info .log-action { color: #60a5fa; }

/* Chart Card Premium Look */
.chart-card {
  transition: transform 0.2s, box-shadow 0.2s;
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
}
.chart-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  border-color: rgba(245, 158, 11, 0.2) !important;
}

/* Template Selector Cards CSS */
.template-selector-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  margin-top: 8px;
}
.template-selector-cards {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  gap: 12px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 4px 4px 12px 4px;
  margin: 0 -4px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}
.template-selector-cards::-webkit-scrollbar {
  height: 4px;
}
.template-selector-cards::-webkit-scrollbar-track {
  background: transparent;
}
.template-selector-cards::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
.template-selector-cards::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}
.template-card {
  flex: 0 0 135px;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 8px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.template-card:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.3);
}
.template-card.active {
  background: rgba(234, 179, 8, 0.05);
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(234, 179, 8, 0.15);
}
.template-card .card-icon {
  font-size: 18px;
  margin-bottom: 6px;
  color: var(--text-dim);
  transition: transform 0.2s;
}
.template-card.active .card-icon {
  color: var(--primary);
  transform: scale(1.1);
}
.template-card .card-title {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.template-card .card-desc {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 2px;
}

/* Miniature Mockup CSS */
.template-mockup {
  width: 100%;
  height: 80px;
  background: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 6px 8px;
  margin-bottom: 10px;
  box-shadow: inset 0 0 8px rgba(0,0,0,0.02);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}
.template-card:hover .template-mockup {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.template-card.active .template-mockup {
  border-color: rgba(234, 179, 8, 0.4);
  box-shadow: 0 4px 12px rgba(234, 179, 8, 0.15);
}
.mockup-row {
  display: flex;
  align-items: center;
  width: 100%;
}
.mockup-box {
  border-radius: 1px;
}
.mockup-table {
  width: 100%;
}
.mockup-table-header {
  width: 100%;
}
.mockup-table-row {
  width: 100%;
}


