:root {
  --p-primary: #1a3a5c;
  --p-accent:  #2d6a9f;
  --p-success: #28a745;
  --p-danger:  #dc3545;
  --p-warning: #ffc107;
  --p-bg:      #f0f4f8;
  --p-card:    #ffffff;
  --p-nav-h:   60px;
  --p-header-h:56px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--p-bg);
  color: #1a2533;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

/* ── Header ── */
.p-header {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; z-index: 100;
  background: var(--p-primary);
  height: var(--p-header-h);
  display: flex; align-items: center; padding: 0 16px;
  gap: 12px; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.p-header .p-back {
  color: #fff; font-size: 20px; text-decoration: none; line-height: 1;
  padding: 4px; border-radius: 6px;
}
.p-header .p-title { color: #fff; font-weight: 700; font-size: 16px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-header .p-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,.2); display: flex; align-items: center;
  justify-content: center; color: #fff; font-size: 14px; font-weight: 700;
  flex-shrink: 0;
}

/* ── Content ── */
.p-content {
  padding-top: calc(var(--p-header-h) + 12px);
  padding-bottom: calc(var(--p-nav-h) + 16px);
  min-height: 100vh;
}
.p-content.no-nav { padding-bottom: 20px; }
.p-section { padding: 0 14px; margin-bottom: 16px; }

/* ── Cards ── */
.p-card {
  background: var(--p-card); border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.07); overflow: hidden;
  margin-bottom: 12px;
}
.p-card-header {
  background: linear-gradient(135deg, var(--p-primary), var(--p-accent));
  color: #fff; padding: 14px 16px; font-weight: 700; font-size: 14px;
}
.p-card-body { padding: 14px 16px; }

/* ── Summary boxes ── */
.p-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.p-stat {
  background: var(--p-card); border-radius: 12px; padding: 14px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.07); text-align: center;
}
.p-stat .val { font-size: 22px; font-weight: 800; color: var(--p-primary); line-height: 1.1; }
.p-stat .lbl { font-size: 11px; color: #7a8a9a; margin-top: 2px; }
.p-stat.danger .val  { color: var(--p-danger); }
.p-stat.warning .val { color: var(--p-warning); }

/* ── Invoice items ── */
.p-invoice-item {
  background: var(--p-card); border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,.07);
  padding: 14px 16px; margin-bottom: 10px;
  display: flex; justify-content: space-between; align-items: flex-start;
  text-decoration: none; color: inherit;
  border-left: 4px solid #dde4ec;
  transition: transform .1s;
}
.p-invoice-item:active { transform: scale(.98); }
.p-invoice-item.status-overdue  { border-left-color: var(--p-danger); }
.p-invoice-item.status-sent     { border-left-color: var(--p-accent); }
.p-invoice-item.status-partial  { border-left-color: var(--p-warning); }
.p-invoice-item.status-paid     { border-left-color: var(--p-success); }
.p-invoice-item.status-cancelled{ border-left-color: #aaa; }
.p-invoice-item .inv-num  { font-weight: 700; font-size: 14px; }
.p-invoice-item .inv-date { font-size: 11px; color: #8a9aaa; margin-top: 2px; }
.p-invoice-item .inv-amt  { font-weight: 800; font-size: 15px; color: var(--p-primary); }
.p-invoice-item .inv-due  { font-size: 11px; color: #8a9aaa; margin-top: 2px; text-align: right; }

/* ── Badges ── */
.p-badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px;
}
.p-badge-sent     { background: #e3f0ff; color: var(--p-accent); }
.p-badge-paid     { background: #e6f9ee; color: var(--p-success); }
.p-badge-overdue  { background: #fff0f0; color: var(--p-danger); }
.p-badge-partial  { background: #fff8e1; color: #e5a300; }
.p-badge-cancelled{ background: #f0f0f0; color: #777; }
.p-badge-draft    { background: #f0f0f0; color: #777; }
.p-badge-open         { background: #e3f0ff; color: var(--p-accent); }
.p-badge-in_progress  { background: #fff8e1; color: #e5a300; }
.p-badge-resolved     { background: #e6f9ee; color: var(--p-success); }
.p-badge-closed       { background: #f0f0f0; color: #777; }
.p-badge-pending      { background: #fff8e1; color: #e5a300; }
.p-badge-approved     { background: #e6f9ee; color: var(--p-success); }
.p-badge-rejected     { background: #fff0f0; color: var(--p-danger); }

/* ── Form elements ── */
.p-form-group { margin-bottom: 14px; }
.p-form-group label { display: block; font-size: 13px; font-weight: 600; color: #4a5a6a; margin-bottom: 5px; }
.p-input {
  width: 100%; padding: 12px 14px; border: 1.5px solid #dde4ec;
  border-radius: 10px; font-size: 15px; background: #fff;
  transition: border-color .2s; outline: none; -webkit-appearance: none;
}
.p-input:focus { border-color: var(--p-accent); }
.p-input.p-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.p-textarea { min-height: 90px; resize: vertical; }

/* ── Buttons ── */
.p-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 14px; border: none; border-radius: 12px;
  font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: none;
  transition: opacity .15s, transform .1s;
}
.p-btn:active { transform: scale(.98); opacity: .9; }
.p-btn-primary  { background: linear-gradient(135deg, var(--p-primary), var(--p-accent)); color: #fff; }
.p-btn-success  { background: var(--p-success); color: #fff; }
.p-btn-outline  { background: transparent; border: 1.5px solid var(--p-accent); color: var(--p-accent); }
.p-btn-danger   { background: var(--p-danger); color: #fff; }
.p-btn-sm { padding: 9px 14px; font-size: 13px; border-radius: 9px; }

/* ── Alert ── */
.p-alert {
  border-radius: 10px; padding: 12px 14px; margin-bottom: 12px;
  font-size: 13px; display: flex; align-items: flex-start; gap: 8px;
}
.p-alert-success { background: #e6f9ee; color: #1a7a3a; border: 1px solid #b3ecc7; }
.p-alert-danger  { background: #fff0f0; color: #c0392b; border: 1px solid #f5b7b1; }
.p-alert-info    { background: #e3f0ff; color: #1a4a7a; border: 1px solid #aed4f5; }
.p-alert-warning { background: #fff8e1; color: #7a5500; border: 1px solid #ffe082; }

/* ── Bottom nav ── */
.p-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; height: var(--p-nav-h);
  background: var(--p-card); border-top: 1px solid #e8edf3;
  display: flex; z-index: 100; box-shadow: 0 -2px 10px rgba(0,0,0,.08);
}
.p-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-decoration: none; color: #9aa0ab;
  font-size: 10px; font-weight: 600; gap: 3px; transition: color .15s;
}
.p-nav a i { font-size: 20px; }
.p-nav a.active { color: var(--p-accent); }
.p-nav a.active i { color: var(--p-accent); }

/* ── Divider ── */
.p-divider { height: 1px; background: #edf0f5; margin: 12px 0; }

/* ── Table ── */
.p-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.p-table td { padding: 8px 4px; vertical-align: top; }
.p-table td:last-child { text-align: right; font-weight: 700; }
.p-table tr.total td { border-top: 1.5px solid #dde4ec; font-size: 15px; font-weight: 800; color: var(--p-primary); padding-top: 10px; }

/* ── Complaint item ── */
.p-ticket {
  background: var(--p-card); border-radius: 12px; padding: 14px 16px;
  margin-bottom: 10px; box-shadow: 0 1px 6px rgba(0,0,0,.07);
  text-decoration: none; color: inherit; display: block;
}
.p-ticket .tk-num  { font-size: 11px; color: #8a9aaa; }
.p-ticket .tk-subj { font-weight: 700; font-size: 14px; margin: 3px 0; }
.p-ticket .tk-date { font-size: 11px; color: #aab; }

/* ── Proof upload ── */
.p-upload-box {
  border: 2px dashed #ccd4dc; border-radius: 12px; padding: 20px;
  text-align: center; color: #8a9aaa; font-size: 13px; cursor: pointer;
  transition: border-color .2s;
}
.p-upload-box:hover { border-color: var(--p-accent); }

/* ── Empty state ── */
.p-empty { text-align: center; padding: 48px 20px; color: #9aa0ab; }
.p-empty i { font-size: 48px; margin-bottom: 12px; display: block; }
.p-empty p { font-size: 14px; margin: 0; }

/* ── Login ── */
.p-login-wrap { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 20px; background: linear-gradient(160deg, var(--p-primary) 0%, var(--p-accent) 100%); }
.p-login-logo { text-align: center; margin-bottom: 28px; color: #fff; }
.p-login-logo i { font-size: 48px; display: block; margin-bottom: 10px; }
.p-login-logo h1 { font-size: 22px; font-weight: 800; margin: 0; }
.p-login-logo p  { margin: 4px 0 0; font-size: 13px; opacity: .75; }
.p-login-card { background: #fff; border-radius: 20px; padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }

/* ── Detail rows ── */
.p-detail-row { display: flex; justify-content: space-between; padding: 9px 0; font-size: 14px; border-bottom: 1px solid #f0f3f7; }
.p-detail-row:last-child { border-bottom: none; }
.p-detail-row .lbl { color: #6a7a8a; }
.p-detail-row .val { font-weight: 600; text-align: right; max-width: 60%; }
