.admin-body { background: #f4f6f8; }

/* ===== Layout: Sidebar + Main ===== */
.admin-layout {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}
.admin-sidebar {
  width: 220px;
  background: #1f4f5b;
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 50;
}
.admin-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 49;
}
.admin-sidebar-overlay.visible {
  display: block;
}
.sidebar-head {
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sidebar-brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.5px;
}
.sidebar-close {
  display: none;
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.85);
  font-family: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  border-left: 3px solid transparent;
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.nav-item.active {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-left-color: #ffc857;
  font-weight: 600;
}
.nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}
.sidebar-divider {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  padding: 14px 18px 4px;
  letter-spacing: 1px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: 8px;
}
.sidebar-foot {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 0;
}
.sidebar-link {
  display: block;
  padding: 8px 18px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  font-size: 12px;
}
.sidebar-link:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.admin-main {
  flex: 1;
  min-width: 0;
}
.admin-page.hidden {
  display: none;
}
.sidebar-toggle {
  display: none;
  background: transparent;
  border: 0;
  font-size: 22px;
  line-height: 1;
  padding: 6px 10px;
  cursor: pointer;
  color: #1f4f5b;
}

@media (max-width: 900px) {
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: -260px;
    width: 260px;
    height: 100vh;
    transition: left 0.2s ease;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  }
  .admin-sidebar.open {
    left: 0;
  }
  .sidebar-close {
    display: inline-block;
  }
  .sidebar-toggle {
    display: inline-block;
  }
}

.admin-section {
  background: #fff;
  margin: 14px 20px;
  padding: 18px 22px;
  border-radius: 10px;
  border: 1px solid #e3e6ea;
}

.admin-section .section-title {
  font-size: 15px; font-weight: 600;
  margin: 0 0 14px; color: #333;
}

/* KPI cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.sum-card {
  background: #fafbfc;
  border: 1px solid #e3e6ea;
  border-radius: 8px;
  padding: 14px 16px;
}
.sum-label {
  font-size: 12px;
  color: #666;
  margin-bottom: 6px;
}
.sum-value {
  font-size: 26px;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.2;
}
.sum-sub {
  font-size: 11px;
  color: #888;
  margin-top: 6px;
}

/* Comparison cards */
.compare-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}
.compare-card {
  background: #fafbfc;
  border: 1px solid #e3e6ea;
  border-radius: 8px;
  padding: 14px 16px;
}
.compare-label {
  font-size: 12px; color: #666; margin-bottom: 6px;
}
.compare-amount {
  font-size: 20px; font-weight: 700;
}
.compare-amount.up { color: #c53929; }
.compare-amount.down { color: #1e7a3a; }
.compare-amount.flat { color: #555; }
.compare-detail {
  font-size: 12px; color: #777; margin-top: 4px;
}

/* Payroll table */
.payroll-table, .staff-settings-table, .special-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.payroll-table th, .payroll-table td,
.staff-settings-table th, .staff-settings-table td,
.special-table th, .special-table td {
  border: 1px solid #d8dbe0;
  padding: 8px 10px;
  text-align: right;
}
.payroll-table th, .staff-settings-table th, .special-table th {
  background: #f0f3f6;
  font-weight: 600;
  text-align: center;
}
.payroll-table td:nth-child(1),
.payroll-table td:nth-child(2),
.staff-settings-table td:nth-child(1),
.staff-settings-table td:nth-child(2) {
  text-align: left;
}
.payroll-table td:nth-child(1),
.staff-settings-table td:nth-child(1) {
  width: 36px; text-align: center; color: #999;
}
.payroll-table tfoot td {
  background: #f7f9fb;
  font-weight: 700;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}
.section-header .section-title { margin: 0; }
.header-right-inline { display: flex; align-items: center; gap: 10px; }
.confirm-status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
}
.confirm-status.confirmed {
  background: #d6ecdd; color: #1e7a3a;
}
.confirm-status.pending {
  background: #fde7c6; color: #a05c00;
}

.editable {
  cursor: pointer;
  position: relative;
}
.editable:hover {
  background: #fff7e0;
}
.editable.overridden {
  background: #fff3d0;
  color: #8b5a00;
}
.editable.overridden::after {
  content: " ✎";
  font-size: 10px;
  color: #c97b00;
}
.editable input {
  width: 90%;
  padding: 4px 6px;
  border: 1px solid #1f4f5b;
  border-radius: 4px;
  text-align: right;
  font-size: 13px;
  font-family: inherit;
}
.reset-btn {
  border: none;
  background: transparent;
  color: #c97b00;
  cursor: pointer;
  font-size: 14px;
  padding: 2px 6px;
  font-family: inherit;
}
.reset-btn:hover { color: #8b5a00; }
.payslip-btn {
  border: 1px solid #cfd4da;
  background: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  text-decoration: none;
  color: #222;
}
.payslip-btn:hover { background: #f6f7f9; }
.edit-detail-btn {
  border: 1px solid #1f4f5b;
  background: #1f4f5b;
  color: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  margin-right: 4px;
}
.edit-detail-btn:hover { background: #163942; }

/* Punch table in admin */
.punch-date-picker {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.punch-date-picker label { font-size: 13px; color: #555; }
.punch-date-picker input[type=date] {
  padding: 6px 8px; max-width: 160px;
}
.punch-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.punch-table th, .punch-table td {
  border: 1px solid #d8dbe0;
  padding: 6px 8px;
  text-align: center;
}
.punch-table th {
  background: #f0f3f6;
  font-weight: 600;
}
.punch-table td:nth-child(2) { text-align: left; }
.punch-table td:nth-child(1) { width: 36px; color: #999; }
.punch-table input[type=time] {
  width: 90px;
  padding: 4px 6px;
  border: 1px solid #cfd4da;
  border-radius: 4px;
  font-family: inherit;
}
.punch-table .save-btn {
  border: 1px solid #1f4f5b;
  background: #1f4f5b;
  color: #fff;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
}
.punch-table .save-btn:hover { background: #163942; }
.punch-table .punch-actions {
  display: flex; flex-direction: column; gap: 4px; align-items: stretch;
  min-width: 64px;
}
.punch-table .clear-btn {
  display: none;
  border: 1px solid #c0392b;
  background: #fff;
  color: #c0392b;
  border-radius: 4px;
  padding: 4px 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
}
.punch-table .clear-btn:hover:not(:disabled) { background: #fdecea; }
.punch-table .clear-btn:disabled {
  opacity: 0.4; cursor: not-allowed;
}
@media (max-width: 720px) {
  .punch-table .clear-btn { display: inline-block; }
}
.break-edit-wrap {
  display: flex; flex-direction: column;
  gap: 4px; align-items: stretch;
}
.break-edit-row {
  display: flex; align-items: center; gap: 4px;
  justify-content: center;
}
.break-edit-row .sep { color: #888; font-size: 12px; }
.break-edit-row .br-del {
  border: 1px solid #c97b00;
  background: #fff;
  color: #c97b00;
  border-radius: 4px;
  padding: 2px 6px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
}
.break-edit-row .br-del:hover { background: #fff5e0; }
.br-add {
  align-self: center;
  border: 1px dashed #999;
  background: transparent;
  color: #555;
  border-radius: 4px;
  padding: 3px 10px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
}
.br-add:hover { background: #f4f4f4; }

/* Staff settings inputs */
.staff-settings-table input[type=number] {
  width: 100px;
  padding: 6px 8px;
  border: 1px solid #cfd4da;
  border-radius: 6px;
  text-align: right;
  font-family: inherit;
}
.staff-settings-table td:nth-child(4) {
  text-align: center;
}
.staff-settings-table td:nth-child(5) {
  text-align: center; width: 180px;
}
.staff-settings-table td:nth-child(6) {
  text-align: center; width: 80px;
}
.account-info {
  background: #fafbfc;
  border: 1px solid #e3e6ea;
  border-radius: 8px;
  padding: 14px 18px;
  margin: 14px 0;
}
.account-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid #eee;
}
.account-row:last-child { border-bottom: none; }
.account-label { font-size: 13px; color: #555; }
.account-value { font-weight: 600; }
.account-value.password {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 18px;
  letter-spacing: 1px;
  color: #b3261e;
  user-select: all;
}
.acct-issue-btn {
  border: 1px solid #1f4f5b;
  background: #fff;
  color: #1f4f5b;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
}
.acct-issue-btn:hover { background: #f0f5f6; }
.acct-revoke-btn {
  border: 1px solid #b3261e;
  background: #fff;
  color: #b3261e;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  margin-left: 4px;
}
.acct-revoke-btn:hover { background: #fff5f5; }
.acct-status-ok {
  color: #1e7a3a;
  font-size: 12px;
}
.acct-status-none {
  color: #888;
  font-size: 12px;
}

/* Rules grid */
.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.rules-status {
  margin-left: 10px;
  font-size: 13px;
  color: #1e7a3a;
}

/* Special days */
.special-add {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.special-add input, .special-add select {
  padding: 8px 10px;
  border: 1px solid #cfd4da;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
}
.special-add #sp-date { width: 150px; }
.special-add #sp-label { flex: 1; min-width: 140px; }
.special-add #sp-type { width: 170px; }
.special-add #sp-value { width: 110px; }
.special-table td:nth-child(1) { text-align: center; width: 130px; }
.special-table td:nth-child(2) { text-align: left; }
.special-table td:nth-child(3) { text-align: center; width: 130px; }
.special-table td:nth-child(4) { width: 110px; }
.special-table td:nth-child(5) { width: 80px; text-align: center; }
.del-btn {
  background: none; border: none; color: #b3261e;
  cursor: pointer; font-size: 13px;
  font-family: inherit;
}
.del-btn:hover { text-decoration: underline; }

/* Hours detail modal */
.hours-cell {
  cursor: pointer;
  position: relative;
}
.hours-cell:hover {
  background: #eef4f8;
  text-decoration: underline dotted #1f4f5b;
  text-underline-offset: 3px;
}
.hd-modal-content {
  max-width: 640px;
  width: 92%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding-bottom: 8px;
}
.hd-table-wrap {
  overflow-y: auto;
  max-height: 35vh;
  border: 1px solid #e3e6ea;
  border-radius: 6px;
  margin: 8px 0 12px;
}
.hd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.hd-table th, .hd-table td {
  padding: 8px 10px;
  border-bottom: 1px solid #eef0f3;
  text-align: left;
}
.hd-table thead th {
  background: #f4f6f8;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}
.hd-table tbody tr:hover { background: #fafbfc; }
.hd-table td.hd-sun { color: #c00; font-weight: 600; }
.hd-table td.hd-sat { color: #1f4e78; font-weight: 600; }
.hd-table td.hd-time { font-family: ui-monospace, Consolas, monospace; }
.hd-table td.hd-mins { font-weight: 700; text-align: right; font-family: ui-monospace, Consolas, monospace; }
.hd-src {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.hd-src.punch { background: #e8f7ee; color: #1e7a3a; }
.hd-src.shift { background: #fff8e0; color: #a05c00; }
.hd-special {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  background: #f3e8ff;
  color: #6c2dbd;
}
.hd-total {
  text-align: right;
  font-weight: 600;
  color: #1f4f5b;
  padding: 4px 4px 8px;
  font-size: 13px;
}
.hd-empty {
  text-align: center;
  padding: 30px 10px;
  color: #888;
  font-size: 13px;
}

/* Bonus section in payroll detail modal */
.hd-bonus-section {
  border-top: 1px solid #e3e6ea;
  margin-top: 12px;
  padding-top: 12px;
}
.hd-bonus-title {
  margin: 0 0 8px 0;
  font-size: 13px;
  color: #1f4f5b;
  font-weight: 600;
}
.hd-bonus-empty {
  color: #888;
  font-size: 12px;
  padding: 6px 0;
}
.hd-bonus-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.hd-bonus-row {
  display: grid;
  grid-template-columns: 56px 1fr 110px auto auto;
  gap: 6px;
  align-items: center;
}
.hd-bonus-row input {
  padding: 4px 6px;
  border: 1px solid #cfd4da;
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
  width: 100%;
  box-sizing: border-box;
}
.hd-bonus-row .b-amount { text-align: right; }
.hd-bonus-row .b-save {
  border: 1px solid #1f4f5b; background: #fff; color: #1f4f5b;
  border-radius: 4px; padding: 4px 8px; cursor: pointer;
  font-family: inherit; font-size: 11px;
}
.hd-bonus-row .b-save:hover { background: #f0f7f9; }
.hd-bonus-row .b-del {
  border: 1px solid #c0392b; background: #fff; color: #c0392b;
  border-radius: 4px; padding: 4px 8px; cursor: pointer;
  font-family: inherit; font-size: 12px;
}
.hd-bonus-row .b-del:hover { background: #fdecea; }
.hd-bonus-row.hd-allowance-row {
  grid-template-columns: 50px 80px 1fr 100px auto auto;
}
.hd-bonus-row.hd-allowance-row select {
  padding: 4px 6px; border: 1px solid #cfd4da; border-radius: 4px;
  font-family: inherit; font-size: 12px; width: 100%; box-sizing: border-box;
}
.hd-allowance-add {
  display: grid;
  grid-template-columns: 60px 90px 1fr 100px auto;
  gap: 6px;
  align-items: end;
  background: #fafbfc;
  padding: 8px;
  border: 1px solid #e3e6ea;
  border-radius: 6px;
  margin-bottom: 8px;
}
.hd-allowance-add label {
  display: flex; flex-direction: column;
  font-size: 11px; color: #555; gap: 2px;
}
.hd-allowance-add input, .hd-allowance-add select {
  padding: 4px 6px;
  border: 1px solid #cfd4da;
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
}
@media (max-width: 720px) {
  .hd-bonus-row.hd-allowance-row {
    grid-template-columns: 50px 80px 1fr 80px;
    grid-template-rows: auto auto;
  }
  .hd-bonus-row.hd-allowance-row .b-save { grid-column: 3; grid-row: 2; }
  .hd-bonus-row.hd-allowance-row .b-del { grid-column: 4; grid-row: 2; }
  .hd-allowance-add {
    grid-template-columns: 60px 90px 1fr;
    grid-template-rows: auto auto auto;
  }
  .hd-allowance-add .btn { grid-column: 1 / -1; grid-row: 3; }
}
.hd-bonus-add {
  display: grid;
  grid-template-columns: 70px 1fr 110px auto;
  gap: 6px;
  align-items: end;
  background: #fafbfc;
  padding: 8px;
  border: 1px solid #e3e6ea;
  border-radius: 6px;
  margin-bottom: 8px;
}
.hd-bonus-add label {
  display: flex; flex-direction: column;
  font-size: 11px; color: #555; gap: 2px;
}
.hd-bonus-add input {
  padding: 4px 6px;
  border: 1px solid #cfd4da;
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
}
.hd-bonus-add .btn { padding: 6px 12px; }
.hd-bonus-total {
  text-align: right;
  font-weight: 600;
  color: #c97b00;
  font-size: 13px;
  padding-top: 4px;
}

.hd-extras-section {
  border-top: 1px solid #e3e6ea;
  margin-top: 12px;
  padding-top: 12px;
}
.hd-extras-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.hd-extras-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: #555;
}
.hd-extras-grid input {
  padding: 6px 8px;
  border: 1px solid #cfd4da;
  border-radius: 4px;
  font-family: inherit;
  font-size: 13px;
  text-align: right;
}
.hd-extras-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.hd-extras-status { font-size: 12px; color: #1f7a3a; }

@media (max-width: 720px) {
  .hd-extras-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.payroll-table .bonus-cell {
  cursor: pointer;
  color: #c97b00;
  text-align: right;
}
.payroll-table .bonus-cell:hover { background: #fff7e6; }
.payroll-table .advance-cell {
  cursor: pointer;
  color: #b3261e;
  text-align: right;
}
.payroll-table .advance-cell:hover { background: #fdecea; }

@media (max-width: 720px) {
  .hd-bonus-row {
    grid-template-columns: 50px 1fr 90px;
    grid-template-rows: auto auto;
    gap: 4px;
  }
  .hd-bonus-row .b-save,
  .hd-bonus-row .b-del {
    grid-column: span 1;
  }
  .hd-bonus-row .b-save { grid-column: 2; grid-row: 2; }
  .hd-bonus-row .b-del { grid-column: 3; grid-row: 2; }
  .hd-bonus-add {
    grid-template-columns: 60px 1fr 90px;
    grid-template-rows: auto auto;
  }
  .hd-bonus-add .btn { grid-column: 1 / -1; grid-row: 2; }
}

/* ===== Invoice admin ===== */
.invoice-list-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.invoice-list-table th, .invoice-list-table td { border: 1px solid #d8dbe0; padding: 6px 10px; }
.invoice-list-table th { background: #f0f3f6; font-weight: 600; }
.invoice-list-table td.amt { text-align: right; font-family: ui-monospace, Consolas, monospace; }
.invoice-list-table .row-actions { text-align: right; }
.invoice-list-table .row-actions button {
  border: 1px solid #1f4f5b; background: #fff; color: #1f4f5b;
  border-radius: 4px; padding: 4px 8px; cursor: pointer; font-size: 11px; margin-left: 4px;
  font-family: inherit;
}
.invoice-list-table .row-actions .danger { border-color: #c0392b; color: #c0392b; }

.inv-form { display: flex; flex-direction: column; gap: 12px; }
.inv-form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.inv-form-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #555; min-width: 180px; }
.inv-form-row label.grow { flex: 1; }
.inv-form-row input, .inv-form-row select {
  padding: 6px 8px; border: 1px solid #cfd4da; border-radius: 6px;
  font-family: inherit; font-size: 13px;
}
.inv-sub-title { margin: 14px 0 6px; font-size: 13px; color: #1f4f5b; font-weight: 600; }
.inv-items-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.inv-items-table th, .inv-items-table td { border: 1px solid #d8dbe0; padding: 4px 6px; }
.inv-items-table th { background: #f0f3f6; font-weight: 600; }
.inv-items-table input {
  width: 100%; box-sizing: border-box;
  padding: 5px 6px; border: 1px solid transparent; border-radius: 4px;
  font-family: inherit; font-size: 13px; background: #fafbfc;
}
.inv-items-table input:focus { border-color: #1f4f5b; background: #fff; outline: 0; }
.inv-items-table .ii-amount { text-align: right; font-family: ui-monospace, Consolas, monospace; }
.inv-items-table .ii-remove {
  border: 1px solid #c0392b; background: #fff; color: #c0392b;
  border-radius: 4px; padding: 2px 6px; cursor: pointer; font-size: 11px;
}
.inv-preview-totals {
  background: #fafbfc; border: 1px solid #e3e6ea; border-radius: 6px;
  padding: 12px 14px; margin-top: 8px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; font-size: 13px;
}
.inv-preview-totals .pt-label { color: #555; }
.inv-preview-totals .pt-value { text-align: right; font-family: ui-monospace, Consolas, monospace; font-weight: 600; }
.inv-preview-totals .pt-grand { color: #b3261e; font-size: 16px; padding-top: 6px; border-top: 1px solid #ddd; margin-top: 4px; }

/* ===== Sales table ===== */
.sales-wrap { overflow-x: auto; }
.sales-table { width: 100%; border-collapse: collapse; font-size: 12px; min-width: 920px; }
.sales-table th, .sales-table td { border: 1px solid #d8dbe0; padding: 4px 6px; }
.sales-table th { background: #f0f3f6; font-weight: 600; font-size: 11px; text-align: center; }
.sales-table td { text-align: right; }
.sales-table td:first-child { background: #fafbfc; font-weight: 600; text-align: center; }
.sales-table input {
  width: 100%; box-sizing: border-box;
  padding: 3px 4px; border: 1px solid transparent; border-radius: 3px;
  font-family: ui-monospace, Consolas, monospace; font-size: 12px;
  text-align: right; background: transparent;
}
.sales-table input:focus { border-color: #1f4f5b; background: #fff; outline: 0; }
.sales-table tfoot td { background: #fffbe6; font-weight: 700; }
.sales-table .computed { background: #f4f7fa; font-family: ui-monospace, Consolas, monospace; }
.sales-table .var-neg { color: #b3261e; }

/* ===== Cash journal ===== */
.journal-opening {
  display: flex; align-items: center; gap: 12px; margin-bottom: 12px;
  background: #fafbfc; border: 1px solid #e3e6ea; border-radius: 6px; padding: 10px 14px;
}
.journal-opening label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #555; }
.journal-opening input {
  padding: 5px 8px; border: 1px solid #cfd4da; border-radius: 4px;
  font-family: ui-monospace, Consolas, monospace; font-size: 13px; text-align: right; width: 140px;
}
#journal-opening-status { font-size: 12px; color: #1f7a3a; }
.journal-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.journal-table th, .journal-table td { border: 1px solid #d8dbe0; padding: 4px 6px; }
.journal-table th { background: #f0f3f6; font-weight: 600; }
.journal-table td.amt { text-align: right; font-family: ui-monospace, Consolas, monospace; }
.journal-table td.balance { background: #fafbfc; font-weight: 600; text-align: right; }
.journal-table input {
  width: 100%; box-sizing: border-box;
  padding: 4px 6px; border: 1px solid #cfd4da; border-radius: 4px;
  font-family: inherit; font-size: 12px;
}
.journal-table input[type="number"] { text-align: right; font-family: ui-monospace, Consolas, monospace; }
.journal-table .row-del {
  border: 1px solid #c0392b; background: #fff; color: #c0392b;
  border-radius: 4px; padding: 2px 6px; cursor: pointer; font-size: 11px;
}
.journal-add-row td { background: #fafbfc; }

/* ===== LOCOFFICE-style admin tables / forms ===== */
.loco-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.loco-table th, .loco-table td { border: 1px solid #d8dbe0; padding: 6px 10px; }
.loco-table th { background: #f0f3f6; font-weight: 600; }
.loco-table td.amt { text-align: right; font-family: ui-monospace, Consolas, monospace; }
.loco-table .row-actions { text-align: right; }
.loco-table .row-actions button {
  border: 1px solid #1f4f5b; background: #fff; color: #1f4f5b;
  border-radius: 4px; padding: 4px 8px; cursor: pointer; font-size: 11px; margin-left: 4px;
  font-family: inherit;
}
.loco-table .row-actions .danger { border-color: #c0392b; color: #c0392b; }
.loco-table .row-actions .primary { background: #1f4f5b; color: #fff; }
.loco-table .stat-pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600;
}
.loco-table .stat-pill.draft   { background: #eee; color: #555; }
.loco-table .stat-pill.sent    { background: #d6e3ec; color: #1f4f5b; }
.loco-table .stat-pill.accepted, .loco-table .stat-pill.paid, .loco-table .stat-pill.delivered, .loco-table .stat-pill.confirmed { background: #d6ecdd; color: #1e7a3a; }
.loco-table .stat-pill.rejected, .loco-table .stat-pill.canceled, .loco-table .stat-pill.expired, .loco-table .stat-pill.returned { background: #f5d6d6; color: #b3261e; }
.loco-table .stat-pill.received, .loco-table .stat-pill.in_progress, .loco-table .stat-pill.scheduled, .loco-table .stat-pill.issued { background: #fde7c6; color: #a05c00; }

.loco-form { display: flex; flex-direction: column; gap: 12px; }
.loco-form .lf-row { display: flex; gap: 12px; flex-wrap: wrap; }
.loco-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #555; min-width: 180px; }
.loco-form label.lf-grow { flex: 1; }
.loco-form input, .loco-form select, .loco-form textarea {
  padding: 6px 8px; border: 1px solid #cfd4da; border-radius: 6px;
  font-family: inherit; font-size: 13px;
}
.loco-form textarea { resize: vertical; min-height: 60px; }
.loco-form input[type=number] { text-align: right; font-family: ui-monospace, Consolas, monospace; }

/* Document items table (estimates/orders/deliveries) */
.doc-items-wrap { margin: 8px 0; }
.doc-items-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-bottom: 6px; }
.doc-items-table th, .doc-items-table td { border: 1px solid #d8dbe0; padding: 3px 5px; }
.doc-items-table th { background: #f0f3f6; font-weight: 600; }
.doc-items-table input, .doc-items-table select {
  width: 100%; box-sizing: border-box;
  padding: 4px 6px; border: 1px solid transparent; border-radius: 4px;
  font-family: inherit; font-size: 12px; background: #fafbfc;
}
.doc-items-table input:focus, .doc-items-table select:focus { border-color: #1f4f5b; background: #fff; outline: 0; }
.doc-items-table input[type=number] { text-align: right; font-family: ui-monospace, Consolas, monospace; }
.doc-items-table .di-line-amt { text-align: right; font-family: ui-monospace, Consolas, monospace; }
.doc-items-table .di-remove {
  border: 1px solid #c0392b; background: #fff; color: #c0392b;
  border-radius: 4px; padding: 2px 6px; cursor: pointer; font-size: 11px;
}
.doc-items-foot { display: flex; justify-content: flex-end; gap: 14px; font-size: 13px; }
.doc-items-foot .lbl { color: #555; margin-right: 4px; }
.doc-items-foot .val { font-family: ui-monospace, Consolas, monospace; font-weight: 600; }
.doc-items-foot .grand { color: #b3261e; font-size: 15px; }

/* ===== Company logo upload ===== */
.co-logo-row {
  display: flex; gap: 18px; align-items: flex-start;
  background: #fafbfc; border: 1px solid #e3e6ea;
  border-radius: 8px; padding: 14px 16px; margin-bottom: 14px;
}
.co-logo-preview-wrap {
  width: 120px; height: 120px;
  background: #fff; border: 1px dashed #cfd4da; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.co-logo-preview-wrap img { max-width: 100%; max-height: 100%; object-fit: contain; }
.co-logo-empty { color: #999; font-size: 12px; }
.co-logo-actions { flex: 1; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.co-logo-hint { font-size: 11px; color: #888; }
.co-logo-status { font-size: 12px; color: #1f7a3a; }
.co-logo-status.error { color: #b3261e; }

/* ===== Sales label editor ===== */
.sales-labels-editor {
  background: #fafbfc; border: 1px solid #e3e6ea;
  border-radius: 8px; padding: 14px 16px; margin-bottom: 14px;
}
.sales-labels-editor h4 { margin: 0 0 4px; font-size: 13px; color: #1f4f5b; }
.sales-labels-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin: 12px 0;
}
.sales-labels-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: #555; }
.sales-labels-grid input {
  padding: 6px 8px; border: 1px solid #cfd4da; border-radius: 4px;
  font-family: inherit; font-size: 13px;
}
.sales-labels-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#sales-labels-status { font-size: 12px; color: #1f7a3a; }
.sales-table th.col-hidden, .sales-table td.col-hidden { display: none; }
@media (max-width: 720px) {
  .sales-labels-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ===== 経費申請 ===== */
.exp-form { display: flex; flex-direction: column; gap: 12px; }
.exp-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: #555; }
.exp-form input, .exp-form select, .exp-form textarea {
  padding: 6px 8px; border: 1px solid #cfd4da; border-radius: 6px;
  font-family: inherit; font-size: 13px;
}
.exp-form textarea { resize: vertical; min-height: 60px; }
.exp-upload-area {
  display: block;
  border: 2px dashed #a8b3c0;
  border-radius: 10px;
  background: #fafbfc;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.exp-upload-area.has-image { padding: 8px; border-style: solid; }
.exp-upload-hint { font-size: 12px; color: #666; margin-bottom: 10px; }
.exp-upload-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.exp-status { font-size: 12px; color: #1f4f5b; padding: 4px 0; min-height: 18px; }
.exp-status.error { color: #b3261e; }
.exp-status.success { color: #1e7a3a; }
.exp-ai-info {
  background: #fff8e1; border: 1px solid #f5d77a;
  border-radius: 6px; padding: 8px 12px; font-size: 12px; color: #6b5400;
}
.expense-receipt-thumb {
  width: 48px; height: 48px;
  border: 1px solid #d8dbe0; border-radius: 4px;
  object-fit: cover; cursor: pointer;
  background: #f0f3f6;
}
.expense-receipt-thumb.placeholder {
  display: inline-flex; align-items: center; justify-content: center;
  color: #999; font-size: 11px;
}
.expense-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.85);
  z-index: 200; display: none; align-items: center; justify-content: center;
}
.expense-modal.open { display: flex; }
.expense-modal img { max-width: 90vw; max-height: 90vh; object-fit: contain; }
.expense-modal .close-btn {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,0.2); border: 0; color: #fff;
  font-size: 24px; padding: 4px 12px; cursor: pointer; border-radius: 6px;
}

/* Hide the 前払い column when the store disabled it in settings */
body.hide-advance-col .col-advance { display: none !important; }

@media print {
  body { display: none !important; }
}
