/* ===== Color Palette & Variables ===== */
:root {
  --primary: #f97316;
  --primary-light: #fb923c;
  --primary-dark: #ea580c;
  --accent: #eab308;
  --accent-light: #facc15;
  --success: #10b981;
  --danger: #ef4444;
  --bg-body: #fff7ed;
  --bg-card: #ffffff;
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --border: #fed7aa;
  --gradient-nav: linear-gradient(135deg, #f97316 0%, #f59e0b 50%, #eab308 100%);
  --gradient-footer: linear-gradient(135deg, #7c2d12 0%, #9a3412 100%);
  --gradient-hero: linear-gradient(135deg, #fff7ed 0%, #fef3c7 50%, #ffedd5 100%);
  --gradient-btn: linear-gradient(135deg, #f97316 0%, #f59e0b 100%);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(249,115,22,.12);
  --shadow-lg: 0 8px 30px rgba(249,115,22,.18);
  --radius: 12px;
  --radius-sm: 8px;
}

/* ===== Global ===== */
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-body);
  color: var(--text-dark);
  min-height: 100vh;
}

/* ===== Navbar ===== */
.navbar-gradient {
  background: var(--gradient-nav);
  box-shadow: 0 2px 20px rgba(249,115,22,.3);
}
.navbar-gradient .navbar-brand {
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: -.02em;
}
.navbar-gradient .nav-link {
  font-weight: 500;
  transition: opacity .2s;
}
.navbar-gradient .nav-link:hover { opacity: .85; }

/* ===== Footer ===== */
.footer-gradient {
  background: var(--gradient-footer);
}

/* ===== Hero Section ===== */
.hero-section {
  background: var(--gradient-hero);
  padding: 3rem 0 2rem;
}
.hero-section h1 {
  font-weight: 800;
  background: var(--gradient-btn);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-badge {
  display: inline-block;
  background: var(--gradient-btn);
  color: #fff;
  padding: .35rem 1rem;
  border-radius: 50px;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .03em;
}

/* ===== Card ===== */
.tool-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  overflow: hidden;
}

/* ===== Tabs ===== */
.nav-tabs-custom {
  border: none;
  gap: .5rem;
  padding: .5rem;
  background: #fff3e0;
  border-radius: var(--radius-sm);
}
.nav-tabs-custom .nav-link {
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--text-muted);
  padding: .6rem 1.5rem;
  transition: all .25s;
}
.nav-tabs-custom .nav-link:hover {
  color: var(--primary);
  background: rgba(249,115,22,.08);
}
.nav-tabs-custom .nav-link.active {
  background: var(--gradient-btn);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

/* ===== Input Form ===== */
.form-label-custom {
  font-weight: 600;
  font-size: .85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: .35rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(249,115,22,.18);
}
.input-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}
.input-table thead th {
  background: var(--gradient-btn);
  color: #fff;
  font-weight: 600;
  font-size: .85rem;
  padding: .65rem .75rem;
  text-align: center;
  border: none;
}
.input-table thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
.input-table thead th:last-child { border-radius: 0 var(--radius-sm) 0 0; }
.input-table tbody td {
  padding: .35rem .4rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.input-table tbody tr:hover { background: #fff7ed; }
.input-table tbody input {
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  padding: .35rem .5rem;
  border-radius: 6px;
  font-size: .9rem;
  transition: all .2s;
}
.input-table tbody input:focus {
  border-color: var(--primary-light);
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(249,115,22,.15);
}
.input-table tfoot td {
  background: #fef3c7;
  font-weight: 700;
  padding: .65rem .75rem;
  border: none;
}
.input-table tfoot td:first-child { border-radius: 0 0 0 var(--radius-sm); }
.input-table tfoot td:last-child { border-radius: 0 0 var(--radius-sm) 0; }

.btn-add-row {
  background: var(--success);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: .4rem 1.2rem;
  font-weight: 600;
  font-size: .85rem;
  transition: all .2s;
}
.btn-add-row:hover {
  background: #059669;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(16,185,129,.3);
}
.btn-remove-row {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 1.1rem;
  cursor: pointer;
  padding: .2rem .4rem;
  border-radius: 6px;
  transition: all .2s;
}
.btn-remove-row:hover {
  background: #fef2f2;
}
.btn-sort {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 0 2px;
  cursor: pointer;
  font-size: .8rem;
  line-height: 1;
  border-radius: 4px;
  transition: color .2s;
}
.btn-sort:hover {
  color: var(--primary);
}

/* ===== Action Buttons ===== */
.btn-gradient {
  background: var(--gradient-btn);
  color: #fff;
  border: none;
  border-radius: 50px;
  padding: .55rem 1.5rem;
  font-weight: 600;
  transition: all .25s;
  box-shadow: var(--shadow-sm);
}
.btn-gradient:hover {
  color: #fff;
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.btn-outline-danger-custom {
  border: 2px solid var(--danger);
  color: var(--danger);
  border-radius: 50px;
  padding: .5rem 1.5rem;
  font-weight: 600;
  background: transparent;
  transition: all .25s;
}
.btn-outline-danger-custom:hover {
  background: var(--danger);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(239,68,68,.3);
}

/* ===== A4 Preview ===== */
.a4-wrapper {
  display: flex;
  justify-content: center;
  padding: 1.5rem;
  background: #fed7aa;
  border-radius: var(--radius-sm);
}
.a4-page {
  width: 210mm;
  min-height: 297mm;
  background: #fff;
  padding: 15mm 20mm 20mm 20mm;
  box-shadow: 0 4px 30px rgba(0,0,0,.15);
  font-family: 'Times New Roman', Times, serif;
  font-size: 13px;
  color: #000;
  line-height: 1.5;
  position: relative;
}

/* Print header layout */
.print-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4mm;
}
.print-header-left {
  flex: 1;
  font-weight: bold;
}
.print-header-right {
  text-align: right;
  font-size: 12px;
}
.print-header-right .mau-so {
  font-weight: bold;
  font-size: 13px;
  margin-bottom: 2px;
}
.print-header-right .italic-note {
  font-style: italic;
  font-size: 11px;
  line-height: 1.4;
}
.print-info-row {
  font-weight: bold;
  margin-bottom: 1mm;
}
.print-title {
  text-align: center;
  font-weight: bold;
  font-size: 16px;
  text-transform: uppercase;
  margin: 6mm 0 2mm;
}
.print-subtitle {
  text-align: center;
  font-style: italic;
  font-size: 13px;
  margin-bottom: 5mm;
}

/* Print table */
.print-table {
  width: 100%;
  border-collapse: collapse;
  margin: 4mm 0;
}
.print-table th, .print-table td {
  border: 1px solid #000;
  padding: 3px 6px;
  text-align: center;
  font-size: 13px;
}
.print-table th {
  font-weight: bold;
  background: #f0f0f0;
}
.print-table td.text-start { text-align: left; }
.print-table td.text-end { text-align: right; }
.print-table .col-label {
  font-style: italic;
  font-size: 12px;
  color: #555;
}
.print-table tbody td {
  min-height: 8mm;
  height: 8mm;
}
.print-table tfoot td {
  font-weight: bold;
}

.print-footer {
  text-align: right;
  margin-top: 8mm;
  font-style: italic;
  font-size: 13px;
}
.print-sign-block {
  text-align: center;
  margin-top: 4mm;
  float: right;
  width: 55%;
}
.print-sign-block .sign-title {
  font-weight: bold;
  font-size: 13px;
  text-transform: uppercase;
}
.print-sign-block .sign-note {
  font-style: italic;
  font-size: 12px;
  color: #555;
}

/* ===== Print Styles ===== */
@media print {
  @page {
    size: A4;
    margin: 10mm;
  }
  body {
    background: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .no-print {
    display: none !important;
  }
  .a4-wrapper {
    background: none;
    padding: 0;
    box-shadow: none;
  }
  .a4-page {
    box-shadow: none;
    margin: 0;
    padding: 5mm 15mm 15mm 15mm;
    width: 100%;
    min-height: auto;
  }
  .print-table th {
    background: #f0f0f0 !important;
  }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .a4-wrapper { padding: .75rem; overflow-x: auto; }
  .a4-page { transform-origin: top left; zoom: 0.55; }
  .nav-tabs-custom .nav-link { padding: .5rem 1rem; font-size: .9rem; }
}

/* ===== Misc ===== */
.dotted-line {
  border-bottom: 1px dotted #000;
  display: inline-block;
  min-width: 120px;
}
.saved-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .78rem;
  color: var(--success);
  font-weight: 500;
  opacity: 0;
  transition: opacity .3s;
}
.saved-indicator.show { opacity: 1; }
