/* ============================================================
   Quantity Tracker — Apple-inspired UI
   ============================================================ */

:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fbfbfd;
  --border: #d2d2d7;
  --border-soft: #e5e5ea;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: #e8f1fd;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --yellow: #ffcc00;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.08);
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.47;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  letter-spacing: -0.011em;
}

/* ============ TOPBAR (estilo barra de menú Apple) ============ */
.topbar {
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-soft);
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  gap: 36px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar nav {
  display: flex;
  gap: 4px;
}

.topbar nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all var(--transition);
}

.topbar nav a:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.04);
}

.topbar nav a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ============ LAYOUT ============ */
main {
  max-width: 1240px;
  margin: 40px auto 80px;
  padding: 0 32px;
}

/* ============ TYPOGRAPHY ============ */
h1 {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.022em;
  margin: 0 0 6px;
  color: var(--text);
}

h2 {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.014em;
  margin: 28px 0 14px;
  color: var(--text);
}

p {
  color: var(--text-secondary);
  margin: 0 0 12px;
}

.subtitle {
  font-size: 15px;
  color: var(--text-tertiary);
  margin-bottom: 32px;
}

/* ============ CARDS ============ */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-soft);
}

.card h2:first-child {
  margin-top: 0;
}

/* ============ KPI CARDS ============ */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.kpi {
  background: var(--surface);
  padding: 20px 22px;
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), box-shadow var(--transition);
}

.kpi:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.kpi .label {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
  letter-spacing: -0.003em;
  text-transform: none;
}

.kpi .value {
  font-size: 26px;
  font-weight: 600;
  color: var(--text);
  margin-top: 6px;
  letter-spacing: -0.022em;
  font-variant-numeric: tabular-nums;
}

/* ============ TABLES ============ */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

th {
  background: var(--surface-2);
  color: var(--text-secondary);
  text-align: left;
  padding: 11px 16px;
  font-weight: 500;
  font-size: 12px;
  letter-spacing: -0.003em;
  border-bottom: 1px solid var(--border-soft);
  text-transform: none;
}

td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text);
}

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

tr:hover td {
  background: rgba(0, 113, 227, 0.02);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

.total-row td {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text);
  border-top: 1px solid var(--border);
}

/* ============ BUTTONS ============ */
.btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 9px 18px;
  border-radius: 980px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.003em;
  transition: all var(--transition);
  font-family: inherit;
}

.btn:hover {
  background: var(--accent-hover);
  transform: scale(1.02);
}

.btn:active {
  transform: scale(0.98);
}

.btn-light {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-light:hover {
  background: var(--surface-2);
}

.btn-sm {
  padding: 5px 14px;
  font-size: 12.5px;
}

.btn-danger {
  background: var(--red);
}

.btn-danger:hover {
  background: #ff453a;
}

/* ============ FORMS ============ */
input[type=text],
input[type=number],
input[type=file],
select,
textarea {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  width: 100%;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  transition: all var(--transition);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

input[type=file] {
  padding: 6px;
  cursor: pointer;
}

label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
  display: block;
  margin-bottom: 6px;
}

.field {
  margin-bottom: 18px;
}

/* ============ FLASH MESSAGES ============ */
.flash {
  background: var(--surface);
  color: var(--text);
  padding: 14px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--green);
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.flash::before {
  content: "✓";
  color: var(--green);
  font-weight: 700;
  font-size: 16px;
}

/* ============ STATE BADGES (estilo macOS) ============ */
.estado {
  padding: 2px 10px;
  border-radius: 980px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  display: inline-block;
}

.estado-Agregado {
  background: rgba(52, 199, 89, 0.15);
  color: #248a3d;
}

.estado-Eliminado {
  background: rgba(255, 59, 48, 0.12);
  color: #c5160c;
}

.estado-Modificado {
  background: rgba(255, 149, 0, 0.15);
  color: #b25f00;
}

.estado-Igual {
  background: rgba(142, 142, 147, 0.12);
  color: var(--text-tertiary);
}

/* ============ DELTAS ============ */
.delta-pos {
  color: var(--orange);
  font-weight: 600;
}

.delta-neg {
  color: var(--green);
  font-weight: 600;
}

/* ============ FOOTER ============ */
footer {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 12px;
  padding: 24px;
  border-top: 1px solid var(--border-soft);
  margin-top: 60px;
}

/* ============ COMPARE LAYOUT ============ */
.flex-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.flex-row .field {
  flex: 1;
  min-width: 240px;
  margin-bottom: 0;
}

/* ============ KPI con borde de color ============ */
.kpi.kpi-accent { border-left: 3px solid var(--accent); }
.kpi.kpi-green  { border-left: 3px solid var(--green); }
.kpi.kpi-orange { border-left: 3px solid var(--orange); }
.kpi.kpi-red    { border-left: 3px solid var(--red); }

/* ============ TABLA SCROLLABLE ============ */
.table-scroll {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
}

.table-scroll table {
  border-radius: 0;
  border: none;
}

/* ============ HERO ============ */
.hero {
  text-align: center;
  padding: 48px 24px 40px;
}

.hero h1 {
  font-size: 44px;
  font-weight: 600;
  letter-spacing: -0.025em;
  background: linear-gradient(135deg, #1d1d1f 0%, #6e6e73 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero p {
  font-size: 19px;
  color: var(--text-secondary);
  max-width: 620px;
  margin: 0 auto;
}
