:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-alt: #eef3f6;
  --text: #172026;
  --muted: #60707c;
  --line: #d9e0e5;
  --primary: #0f6c72;
  --primary-dark: #0a5056;
  --accent: #9b5c15;
  --danger: #b42318;
  --success: #217a3d;
  --warning: #a15c07;
  --radius: 8px;
  --shadow: 0 8px 22px rgba(23, 32, 38, 0.08);
  font-family: "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.cover-image {
  width: 100%;
  height: 300px;
  background-image: url('../assets/cargo_ship_cover.png');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

.app-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 22px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.app-header h1 {
  margin: 2px 0 0;
  font-size: 1.6rem;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.user-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  min-width: 180px;
  color: var(--muted);
}

.user-chip strong {
  color: var(--primary-dark);
}

.app-nav {
  display: flex;
  gap: 8px;
  padding: 12px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.nav-button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  padding: 9px 12px;
  border-radius: var(--radius);
  white-space: nowrap;
}

.nav-button:hover,
.nav-button.is-active {
  background: var(--surface-alt);
  border-color: var(--line);
}

.app-main {
  padding: 24px 28px 40px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.page-header h2 {
  margin: 0 0 4px;
  font-size: 1.35rem;
}

.page-header p {
  margin: 0;
  color: var(--muted);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.stack {
  display: grid;
  gap: 18px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
}

.empty-state {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.82rem;
  background: var(--surface-alt);
}

.status-approved,
.status-completed {
  color: var(--success);
}

.status-rejected {
  color: var(--danger);
}

.status-submitted,
.status-finance-approved {
  color: var(--warning);
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  min-height: 38px;
  padding: 8px 12px;
  border-radius: var(--radius);
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-danger {
  color: #fff;
  border-color: var(--danger);
  background: var(--danger);
}

.btn-ghost {
  background: transparent;
}

.notifications {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 10px;
  z-index: 20;
}

.notice {
  max-width: 360px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--text);
  color: #fff;
  box-shadow: var(--shadow);
}

.notice.error {
  background: var(--danger);
}

.notice.success {
  background: var(--success);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  margin: 0;
  font-size: 1.25rem;
}

.modal-close {
  min-height: 24px;
  padding: 4px 8px;
  border: none;
  font-size: 1.2rem;
  background: transparent;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
}

.modal-message {
  margin-bottom: 0;
}

.modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal-validation-error {
  margin-top: 10px;
  color: var(--danger);
}

/* Detail Table */
.detail-table {
  width: 100%;
  border-collapse: collapse;
}

.detail-table th {
  text-align: left;
  color: var(--muted);
  padding: 8px 0;
  width: 120px;
}

.detail-table td {
  padding: 8px 0;
  font-weight: 500;
}

.detail-row--danger th,
.detail-row--danger td {
  color: var(--danger);
}

/* Loading State */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--muted);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--surface-alt);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Status Chips (Masters) */
.status-chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-chip--active {
  background-color: rgba(46, 204, 113, 0.15);
  color: var(--success);
}

.status-chip--inactive {
  background-color: rgba(149, 165, 166, 0.15);
  color: var(--muted);
}

/* Order Status Badges */
.status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: 600;
}

.status-draft { background-color: var(--line); color: var(--text); }
.status-submitted { background-color: rgba(52, 152, 219, 0.15); color: #2980b9; }
.status-sales-approved { background-color: rgba(155, 89, 182, 0.15); color: #8e44ad; }
.status-finance-approved { background-color: rgba(52, 73, 94, 0.15); color: #2c3e50; }
.status-md-approved { background-color: rgba(241, 196, 15, 0.15); color: #d35400; }
.status-completed { background-color: rgba(46, 204, 113, 0.15); color: var(--success); }
.status-rejected { background-color: rgba(231, 76, 60, 0.15); color: var(--danger); }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-style: italic;
}

/* ─── Badges ─────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-alt);
  color: var(--text);
}

.badge-primary {
  background: rgba(15, 108, 114, 0.15);
  color: var(--primary-dark);
}

.badge-info {
  background: rgba(52, 152, 219, 0.12);
  color: #2471a3;
}

.badge-purple {
  background: rgba(142, 68, 173, 0.12);
  color: #7d3c98;
}

.badge-warning {
  background: rgba(241, 196, 15, 0.15);
  color: var(--warning);
}

.badge-success {
  background: rgba(46, 204, 113, 0.12);
  color: var(--success);
}

.badge-danger {
  background: rgba(231, 76, 60, 0.12);
  color: var(--danger);
}

.badge-count {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: var(--radius);
  background: var(--surface-alt);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.88rem;
}

/* ─── Data Tables (Order Requests) ───────────────────────────────────────── */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: var(--surface-alt);
}

.data-table tbody tr:hover {
  background-color: rgba(15, 108, 114, 0.03);
}

/* ─── Form Sections (Order Requests) ─────────────────────────────────────── */
.form-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.form-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
}

.form-section h3 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  color: var(--primary-dark);
}

.form-control {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  min-height: 38px;
  padding: 8px 10px;
  color: var(--text);
  font: inherit;
}

.form-control:focus {
  outline: 3px solid rgba(15, 108, 114, 0.22);
  outline-offset: 2px;
}

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

.full-width {
  grid-column: 1 / -1;
}

.order-form .form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

/* ─── Page Layout ────────────────────────────────────────────────────────── */
.page-container {
  width: 100%;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-header h2 {
  margin: 0 0 4px;
  font-size: 1.35rem;
}

.subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ─── Tab Buttons ────────────────────────────────────────────────────────── */
.tab-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── Button Variants ────────────────────────────────────────────────────── */
.btn-secondary {
  background: var(--surface-alt);
  border-color: var(--line);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--line);
}

.btn-sm {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 0.82rem;
}

/* ─── Helper Text ────────────────────────────────────────────────────────── */
.help-text {
  color: var(--muted);
  font-size: 0.82rem;
}

.required {
  color: var(--danger);
  font-weight: 700;
}

.required-mark {
  color: var(--danger);
}

/* ─── Additional Status Badges ───────────────────────────────────────────── */
.status-request-pending { background-color: rgba(243, 156, 18, 0.15); color: #d68910; }
.status-order-created { background-color: rgba(46, 204, 113, 0.15); color: var(--success); }
.status-cancelled { background-color: rgba(149, 165, 166, 0.15); color: var(--muted); }

/* ─── Muted Text ─────────────────────────────────────────────────────────── */
.muted {
  color: var(--muted);
}

/* ─── Rejection Reason Truncation ────────────────────────────────────────── */
.rejection-reason {
  font-size: 0.85rem;
  color: var(--danger);
  cursor: help;
}

/* ─── Radio Group ────────────────────────────────────────────────────────── */
.radio-group label {
  font-weight: normal;
}

/* ─── Form Actions ───────────────────────────────────────────────────────── */
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 12px;
}

/* ─── Modal Card (order-requests view detail) ────────────────────────────── */
.modal-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  max-width: 560px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-card h3 {
  margin: 0 0 1rem;
}

.modal-card h4 {
  margin: 0 0 0.5rem;
}

/* ─── Approval Chips (Sales approval/rejection inline labels) ─────────────── */
.approval-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.6rem;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  animation: chip-fade-in 0.3s ease;
}

.approval-chip--approved {
  background: rgba(33, 122, 61, 0.12);
  color: var(--success);
  border: 1px solid rgba(33, 122, 61, 0.25);
}

.approval-chip--rejected {
  background: rgba(180, 35, 24, 0.10);
  color: var(--danger);
  border: 1px solid rgba(180, 35, 24, 0.22);
}

.approval-chip--pending {
  background: rgba(161, 92, 7, 0.10);
  color: var(--warning);
  border: 1px solid rgba(161, 92, 7, 0.22);
}

.approval-chip__time {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
}

/* ─── Finance Pending Badge ───────────────────────────────────────────────── */
.badge-finance-pending {
  background: rgba(13, 148, 136, 0.13);
  color: #0d9488;
  border: 1px solid rgba(13, 148, 136, 0.28);
}

/* ─── Danger Badge ────────────────────────────────────────────────────────── */
.badge-danger {
  background: rgba(180, 35, 24, 0.10);
  color: var(--danger);
  border: 1px solid rgba(180, 35, 24, 0.22);
}

/* ─── Real-time update animation on status labels ─────────────────────────── */
@keyframes chip-fade-in {
  from { opacity: 0; transform: translateY(-4px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0)   scale(1); }
}

@keyframes status-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(15, 108, 114, 0.45); }
  60%  { box-shadow: 0 0 0 6px rgba(15, 108, 114, 0);   }
  100% { box-shadow: 0 0 0 0 rgba(15, 108, 114, 0);     }
}

.status--updated {
  animation: status-pulse 1.1s ease;
}

.badge--updated {
  animation: status-pulse 1.1s ease;
}

/* ─── Row fade-out (when order leaves queue after action) ─────────────────── */
@keyframes row-fade-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(40px); }
}

.row--fading {
  animation: row-fade-out 0.45s ease forwards;
  pointer-events: none;
}

/* ─── Responsible list in order requests table ────────────────────────────── */
.responsible-list {
  font-size: 0.85rem;
  color: var(--text);
  transition: color 0.3s;
}
