/* ===================== VARIABLES ===================== */
:root {
  --primary:        #4f46e5;
  --primary-hover:  #4338ca;
  --success:        #10b981;
  --danger:         #ef4444;
  --warning:        #f59e0b;
  --info:           #3b82f6;
  --cyan:           #06b6d4;

  --bg:             #f0f4f8;
  --card:           #ffffff;
  --border:         #e2e8f0;
  --text:           #1e293b;
  --muted:          #64748b;
  --placeholder:    #94a3b8;

  --radius:         8px;
  --radius-sm:      5px;
  --shadow:         0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:      0 4px 12px rgba(0,0,0,.1);
}

/* ===================== RESET ===================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
code { font-family: 'SF Mono', 'Fira Code', monospace; }

/* ===================== HEADER ===================== */
header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 40px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.logo {
  font-size: 18px;
  color: var(--text);
  white-space: nowrap;
  padding: 16px 0;
}
.logo strong { color: var(--primary); }

nav { display: flex; gap: 2px; }

.nav-btn {
  padding: 18px 16px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.nav-btn:hover  { color: var(--text); }
.nav-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ===================== LAYOUT ===================== */
main {
  max-width: 1300px;
  margin: 0 auto;
  padding: 28px 24px;
}

.section-header { margin-bottom: 22px; }
.section-header h2 { font-size: 22px; font-weight: 700; }
.section-desc { color: var(--muted); font-size: 13px; margin-top: 4px; }

.content-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 20px;
  align-items: start;
}

/* ===================== CARD ===================== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
  margin-bottom: 16px;
}
.card-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-toolbar h3 { margin-bottom: 0; }

/* ===================== FORMS ===================== */
.form-group { margin-bottom: 12px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .4px;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
input::placeholder { color: var(--placeholder); }
input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
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='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; cursor: pointer; }

.form-actions { display: flex; gap: 8px; margin-top: 4px; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 6px; font-style: italic; }

.order-total-preview {
  background: #f8f9ff;
  border: 1px solid #e0e7ff;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
  margin-top: 8px;
}

/* ===================== BUTTONS ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }

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

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

.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.btn-add-item {
  width: 100%;
  margin-top: 6px;
  border-style: dashed;
  color: var(--primary);
  border-color: #c7d2fe;
}
.btn-add-item:hover { background: #eef2ff; }

/* ===================== ORDER ITEMS ===================== */
.items-list { display: flex; flex-direction: column; gap: 8px; }

.item-row {
  display: grid;
  grid-template-columns: 1fr 70px 30px;
  gap: 6px;
  align-items: center;
}

.item-remove {
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: #fee2e2;
  color: var(--danger);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.item-remove:hover { background: #fecaca; }

/* ===================== TABLE ===================== */
.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  background: #fafbfc;
}
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8faff; }

.table-actions { display: flex; gap: 5px; }

/* ===================== BADGES ===================== */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-cyan   { background: #cffafe; color: #155e75; }

/* ===================== EMPTY STATE ===================== */
.empty-state {
  padding: 40px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.empty-state-icon { font-size: 32px; margin-bottom: 8px; opacity: .5; }

/* ===================== TOAST ===================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  box-shadow: var(--shadow-md);
  z-index: 9999;
  max-width: 320px;
  animation: toast-in .25s ease;
}
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--info); }

@keyframes toast-in {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ===================== MODAL ===================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .45);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in .2s ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal-box {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 580px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  animation: modal-in .2s ease;
}
@keyframes modal-in { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 17px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  line-height: 1;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

/* ===================== ORDER DETAIL ===================== */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}
.detail-item { background: var(--bg); border-radius: var(--radius-sm); padding: 10px 12px; }
.detail-item label { font-size: 11px; display: block; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 3px; }
.detail-item span { font-size: 14px; font-weight: 600; }

.detail-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: 10px;
}

/* ===================== PRODUCT NAME CELL ===================== */
.product-name-cell strong { display: block; }
.product-name-cell small { color: var(--muted); font-size: 12px; }

/* ===================== RESPONSIVE ===================== */
@media (max-width: 900px) {
  .content-grid { grid-template-columns: 1fr; }
  .detail-grid   { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  header { padding: 0 16px; gap: 16px; }
  .logo  { font-size: 15px; }
  .nav-btn { padding: 16px 10px; font-size: 13px; }
  main   { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
}
