:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg-main: #f8fafc;
  --bg-sidebar: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --sidebar-width: 260px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --radius: 12px;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* Sidebar */
aside {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem;
  box-shadow: 4px 0 10px rgba(0, 0, 0, 0.02);
  z-index: 10;
}

.logo {
  font-weight: 800;
  font-size: 1.25rem;
  color: var(--primary);
  margin-bottom: 3rem;
  line-height: 1.2;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  border-radius: var(--radius);
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  background: none;
  text-align: left;
  font-size: 0.95rem;
}

.nav-item:hover {
  background-color: #f1f5f9;
  color: var(--text-main);
}

.nav-item.active {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

/* Main Content */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 2rem 3rem;
}

header {
  margin-bottom: 2rem;
}

h1 {
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.025em;
}

/* Table Card */
.card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 0;
  overflow: auto;
  max-height: calc(100vh - 180px);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.72rem;
}

thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

th {
  background-color: #f1f5f9;
  padding: 0.6rem 0.5rem;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: none;
}

/* Existing styles */

/* Modal Styles */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-content {
  background: #1e1e1e;
  padding: 2rem;
  border-radius: 8px;
  text-align: center;
  width: 300px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
  margin-bottom: 1.5rem;
  color: #fff;
}

.modal-content input {
  width: 100%;
  padding: 10px;
  margin-bottom: 1rem;
  border: 1px solid #333;
  background: #2d2d2d;
  color: #fff;
  border-radius: 4px;
}

.modal-content button {
  width: 100%;
  padding: 10px;
  background: #4A90E2;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

.modal-content button:hover {
  background: #357ABD;
}

tr:hover td {
  background-color: #fcfdfe;
}

.status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-waiting {
  background-color: #fef3c7;
  color: #92400e;
}

.status-confirmed {
  background-color: #dcfce7;
  color: #166534;
}

/* Settings Page Styles */
.settings-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
  padding: 1rem 0;
}

.settings-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: var(--shadow);
}

.settings-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
  border-color: var(--primary);
}

.settings-card h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.settings-card p {
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* Manage View Header */
.manage-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.manage-header h2 {
  flex: 1;
  font-size: 1.5rem;
}

/* Buttons */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.2s;
}

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

.btn-secondary {
  background: #e2e8f0;
  color: var(--text-main);
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.75rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  margin-right: 0.25rem;
}

.btn-edit {
  background: #3b82f6;
  color: white;
}

.btn-edit:hover {
  background: #2563eb;
}

.btn-delete {
  background: #ef4444;
  color: white;
}

.btn-delete:hover {
  background: #dc2626;
}

/* Container and Sidebar fix */
.container {
  display: flex;
  width: 100%;
  height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 2rem 1.5rem;
}

.main-content {
  flex: 1;
  padding: 2rem 3rem;
  overflow-y: auto;
}

#page-title {
  font-size: 1.875rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
}

/* Review Invoice Page Styles */
.review-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.review-tab {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  background: #e2e8f0;
  color: #64748b;
}

.review-tab.active {
  background: var(--primary);
  color: white;
}

.review-tab:not(.active):hover {
  background: #cbd5e1;
}

.review-split-layout {
  display: flex;
  gap: 1rem;
  height: calc(100vh - 200px);
}

.review-left-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}

.review-records-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
}

.review-records-header h3 {
  margin: 0;
  font-size: 1rem;
}

.review-records-header span {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.review-table-container {
  flex: 1;
  overflow: auto;
}

.review-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.review-table th {
  background: #f8fafc;
  padding: 0.75rem 0.5rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.review-table td {
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.review-row {
  cursor: pointer;
  transition: background 0.15s;
}

.review-row:hover {
  background: #f1f5f9;
}

.review-row.selected {
  background: #e0f2fe;
}

.review-row.reviewed {
  opacity: 0.6;
}

.review-row.submit-selected {
  background: #dcfce7;
}

.review-row.submit-selected:hover {
  background: #bbf7d0;
}

.review-row.reviewed .review-btn {
  background: #94a3b8;
}

.review-record-item {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 0.5rem;
  transition: all 0.2s;
}

.review-record-item:hover {
  background: #f1f5f9;
}

.review-record-item.selected {
  background: #e0f2fe;
  border-color: var(--primary);
}

.review-record-item.reviewed {
  opacity: 0.6;
}

.review-record-item.reviewed .review-btn {
  background: #94a3b8;
}

.review-btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.75rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  background: var(--primary);
  color: white;
  margin-right: 0.75rem;
  white-space: nowrap;
}

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

.review-record-info {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  font-size: 0.8rem;
}

.review-record-info .record-field {
  min-width: 100px;
}

.review-record-info .field-label {
  color: var(--text-muted);
  font-size: 0.7rem;
}

.review-record-info span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.review-right-panel {
  width: 400px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.review-detail-form {
  flex: 1;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1rem;
  overflow-y: auto;
}

.review-detail-form h3 {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.review-attachment-preview {
  height: 400px;
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.review-attachment-preview h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
}

#attachment-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  cursor: grab;
}

#attachment-container:active {
  cursor: grabbing;
}

#attachment-container iframe {
  width: 100%;
  height: 100%;
  border: none;
}

#attachment-container img {
  max-width: 100%;
  max-height: 100%;
  transition: transform 0.1s ease-out;
  user-select: none;
  pointer-events: none;
  /* Let parent handle events */
}

.detail-field {
  margin-bottom: 0.75rem;
}

.detail-field label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.detail-field input,
.detail-field select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.875rem;
}

.detail-field input:focus,
.detail-field select:focus {
  outline: none;
  border-color: var(--primary);
}

/* Progress Modal Styles */
.progress-container {
  margin: 1.5rem 0;
}

.progress-bar {
  width: 100%;
  height: 24px;
  background: #2d2d2d;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4A90E2, #67B26F);
  border-radius: 12px;
  transition: width 0.3s ease;
  position: relative;
}

.progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.2),
    transparent
  );
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.progress-text {
  margin-top: 0.75rem;
  color: #ccc;
  font-size: 1rem;
  font-weight: 600;
}

.progress-status {
  color: #4A90E2;
  font-size: 0.9rem;
  margin-top: 1rem;
  min-height: 1.5rem;
}

.progress-details {
  margin-top: 1rem;
  max-height: 120px;
  overflow-y: auto;
  text-align: left;
  font-size: 0.75rem;
  color: #888;
  background: #252525;
  border-radius: 6px;
  padding: 0.5rem;
}

.progress-details .success {
  color: #67B26F;
}

.progress-details .error {
  color: #ef4444;
}

.progress-details .item {
  padding: 0.25rem 0;
  border-bottom: 1px solid #333;
}

.progress-details .item:last-child {
  border-bottom: none;
}