/* ===== Reset & Variables ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #7c3aed;
  --primary-light: #ede9fe;
  --accent:        #ec4899;
  --success:       #10b981;
  --success-light: #d1fae5;
  --warning:       #f59e0b;
  --warning-light: #fef3c7;
  --danger:        #ef4444;
  --danger-light:  #fee2e2;
  --info:          #3b82f6;
  --info-light:    #dbeafe;
  --text:          #1e293b;
  --text-muted:    #64748b;
  --border:        #e2e8f0;
  --bg:            #f1f5f9;
  --card-bg:       #ffffff;
  --header-bg:     #0f172a;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:     0 4px 12px rgba(0,0,0,.1);
}

body {
  font-family: 'Pretendard', 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 14px;
}

/* ===== Header ===== */
.header {
  background: var(--header-bg);
  color: white;
  padding: 0 24px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.4);
}
.header-left { display: flex; align-items: center; gap: 14px; }
.logo { font-size: 30px; line-height: 1; }
.brand-info h1 { font-size: 17px; font-weight: 700; letter-spacing: -.3px; }
.date-badge { font-size: 11px; color: #94a3b8; }
.header-right { display: flex; gap: 8px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 8px 16px; border-radius: 7px; border: none;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all .15s; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: #6d28d9; }
.btn-secondary { background: #334155; color: white; }
.btn-secondary:hover { background: #475569; }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 5px; }

/* ===== Tab Navigation ===== */
.tab-nav {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  gap: 2px;
  position: sticky;
  top: 62px;
  z-index: 90;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}
.tab-btn {
  background: none; border: none; cursor: pointer;
  padding: 15px 22px; font-size: 13px; font-weight: 500;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  transition: all .15s;
}
.tab-btn:hover { color: var(--primary); background: var(--primary-light); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 700; }

/* ===== Main Content ===== */
.main-content { padding: 24px; max-width: 1680px; margin: 0 auto; }
.tab-panel { display: none; animation: fadeIn .2s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ===== Section Header ===== */
.section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px;
}
.section-header h2 { font-size: 19px; font-weight: 800; }

/* ===== KPI Cards ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }

.kpi-card {
  background: var(--card-bg); border-radius: 12px;
  padding: 20px 22px; box-shadow: var(--shadow);
  border-left: 5px solid var(--primary);
  position: relative; overflow: hidden;
}
.kpi-card::after {
  content: '';
  position: absolute; top: -20px; right: -20px;
  width: 80px; height: 80px; border-radius: 50%;
  background: var(--primary); opacity: .04;
}
.kpi-card.kpi-warning { border-left-color: var(--warning); }
.kpi-card.kpi-warning::after { background: var(--warning); }
.kpi-card.kpi-danger  { border-left-color: var(--danger); }
.kpi-card.kpi-danger::after  { background: var(--danger); }
.kpi-card.kpi-info    { border-left-color: var(--info); }
.kpi-card.kpi-info::after    { background: var(--info); }
.kpi-card.kpi-success { border-left-color: var(--success); }

.kpi-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 10px; }
.kpi-value { font-size: 40px; font-weight: 900; line-height: 1; margin-bottom: 8px; }
.kpi-sub   { font-size: 12px; color: var(--text-muted); }

/* ===== Grid layouts ===== */
.charts-grid   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.charts-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }

/* ===== Cards ===== */
.card {
  background: var(--card-bg); border-radius: 12px;
  padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.card-title { font-size: 14px; font-weight: 700; margin-bottom: 16px; color: var(--text); }

/* ===== Table Toolbar ===== */
.table-toolbar { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.search-input, .select-input {
  padding: 8px 12px; border: 1.5px solid var(--border);
  border-radius: 7px; font-size: 13px; outline: none;
  transition: border-color .15s; background: white;
}
.search-input { flex: 1; min-width: 180px; }
.search-input:focus, .select-input:focus { border-color: var(--primary); }

/* ===== Tables ===== */
.table-wrapper { overflow-x: auto; border-radius: 8px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  background: #f8fafc; padding: 11px 14px;
  text-align: left; font-weight: 700; font-size: 11px;
  color: var(--text-muted); border-bottom: 1.5px solid var(--border);
  white-space: nowrap; letter-spacing: .3px;
}
.data-table td { padding: 11px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.data-table tr:hover td { background: #fafafa; }
.data-table tr:last-child td { border-bottom: none; }

/* ===== Badges ===== */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700; white-space: nowrap;
}
.badge-planning     { background: #f1f5f9; color: #64748b; }
.badge-developing   { background: var(--info-light); color: #1d4ed8; }
.badge-approval     { background: var(--warning-light); color: #92400e; }
.badge-producing    { background: var(--primary-light); color: #5b21b6; }
.badge-active       { background: var(--success-light); color: #065f46; }
.badge-discontinued { background: #f1f5f9; color: #cbd5e1; text-decoration: line-through; }
.badge-ordered      { background: #e0f2fe; color: #0369a1; }
.badge-completed    { background: var(--success-light); color: #065f46; }
.badge-delayed      { background: var(--danger-light); color: #991b1b; }
.badge-ok           { background: var(--success-light); color: #065f46; }
.badge-low          { background: var(--warning-light); color: #92400e; }
.badge-critical     { background: var(--danger-light); color: #991b1b; }
.badge-fda-none     { background: #f1f5f9; color: #94a3b8; }
.badge-fda-pending  { background: var(--warning-light); color: #92400e; }
.badge-fda-approved { background: var(--success-light); color: #065f46; }

/* ===== Alert List (Overview) ===== */
.alert-list { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.alert-item { display: flex; align-items: flex-start; gap: 10px; padding: 11px 13px; border-radius: 8px; font-size: 13px; }
.alert-item.danger  { background: var(--danger-light); }
.alert-item.warning { background: var(--warning-light); }
.alert-item.info    { background: var(--info-light); }
.alert-item-icon  { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.alert-item-text  { flex: 1; }
.alert-item-title { font-weight: 700; margin-bottom: 2px; }
.alert-item-desc  { color: var(--text-muted); font-size: 12px; }

/* ===== Inventory Alert Grid ===== */
.alert-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; padding-top: 4px; }
.alert-chip {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 14px; border-radius: 10px; border: 1.5px solid;
}
.alert-chip.critical { background: var(--danger-light);  border-color: #fca5a5; }
.alert-chip.warning  { background: var(--warning-light); border-color: #fcd34d; }
.alert-chip-name   { font-weight: 700; font-size: 13px; }
.alert-chip-detail { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.alert-chip-value  { font-weight: 900; font-size: 18px; }

/* ===== Modals ===== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.55);
  z-index: 200; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  background: white; border-radius: 14px;
  width: 100%; max-width: 680px; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
}
.modal-sm { max-width: 460px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 22px 26px 0; }
.modal-header h3 { font-size: 16px; font-weight: 800; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--text-muted); padding: 4px; border-radius: 5px; }
.modal-close:hover { background: #f1f5f9; color: var(--text); }
.modal-body { padding: 20px 26px; }
.modal-footer { padding: 0 26px 22px; display: flex; justify-content: flex-end; gap: 8px; }

/* ===== Forms ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.form-input {
  padding: 9px 11px; border: 1.5px solid var(--border);
  border-radius: 7px; font-size: 13px; width: 100%; outline: none;
  transition: border-color .15s; color: var(--text);
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }

/* ===== Upload ===== */
.upload-desc { color: var(--text-muted); font-size: 13px; margin-bottom: 14px; }
.upload-type-select { margin-bottom: 14px; }
.upload-drop-zone {
  border: 2px dashed var(--border); border-radius: 12px;
  padding: 32px 20px; text-align: center; color: var(--text-muted);
  font-size: 13px; transition: border-color .15s; cursor: pointer;
}
.upload-drop-zone:hover { border-color: var(--primary); background: var(--primary-light); }
.drop-zone-icon { font-size: 38px; margin-bottom: 10px; }
#upload-preview { margin-top: 16px; }
#upload-preview h4 { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
#upload-preview-table { overflow-x: auto; max-height: 200px; overflow-y: auto; border-radius: 8px; border: 1px solid var(--border); }
#upload-count { font-size: 12px; color: var(--text-muted); margin-top: 8px; }

/* ===== Toast ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1e293b; color: white;
  padding: 12px 20px; border-radius: 10px;
  font-size: 13px; z-index: 300; font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toastIn .25s ease;
}
@keyframes toastIn { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  .charts-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .charts-grid, .charts-grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .main-content { padding: 12px; }
  .header { padding: 0 14px; }
  .tab-btn { padding: 12px 14px; font-size: 12px; }
}
