/* ============================================================================
   Koisend - Hoja de estilos principal
   Paleta inspirada en el logo: verde + naranja, con acento de bandera cubana.
   ============================================================================ */

:root {
  --green-700: #2f7a1f;
  --green-600: #3f9a26;
  --green-500: #5cb82f;
  --green-400: #7ac142;
  --green-100: #e9f7e0;
  --orange-700: #c85400;
  --orange-600: #e6690a;
  --orange-500: #f7931e;
  --orange-400: #ffab3f;
  --orange-100: #fff1e0;
  --blue-cuba: #0033a0;
  --red-cuba: #cc0000;

  --bg: #f3f6f2;
  --surface: #ffffff;
  --text: #23281f;
  --text-muted: #6b7568;
  --border: #e4e9df;
  --danger: #d64545;
  --danger-100: #fdeaea;
  --warning: #e6a400;
  --warning-100: #fff6df;
  --success: #2f9e44;
  --success-100: #e6f7ea;
  --info: #1c7ed6;
  --info-100: #e7f3fc;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(30, 40, 20, 0.06);
  --shadow-lg: 0 12px 32px rgba(30, 40, 20, 0.16);
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
img { max-width: 100%; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #cfd9c8; border-radius: 10px; }

/* ---------------------------------------------------------------- Layout */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, #1f3d16 0%, #16290f 100%);
  color: #eef5ea;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  transition: transform .25s ease;
}

.sidebar-brand {
  padding: 18px 16px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-brand img { max-width: 175px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.35)); }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #cfe0c7;
  font-weight: 500;
  transition: background .15s, color .15s;
}
.nav-item svg { width: 19px; height: 19px; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, var(--orange-500), var(--orange-600));
  color: #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,.25);
}

.sidebar-footer {
  padding: 14px;
  border-top: 1px solid rgba(255,255,255,.1);
}
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green-500), var(--green-700));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.25; overflow: hidden; }
.user-meta strong { font-size: 13px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { font-size: 11.5px; color: #a9bfa0; }

.btn-logout {
  display: block; text-align: center;
  width: 100%; padding: 8px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,.08); color: #f1d9c8; font-size: 13px; font-weight: 600;
  border: 1px solid rgba(255,255,255,.12);
}
.btn-logout:hover { background: rgba(214,69,69,.85); color: #fff; }

.main-wrap {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 62px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.page-title { font-size: 19px; font-weight: 700; margin: 0; flex: 1; color: #1f3d16; }
.hamburger {
  display: none;
  background: none; border: none; cursor: pointer; color: var(--text);
  padding: 6px;
}
.hamburger svg { width: 22px; height: 22px; }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.badge-role { padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .3px; }
.badge-admin { background: var(--orange-100); color: var(--orange-700); }
.badge-worker { background: var(--green-100); color: var(--green-700); }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35;
}

.content { padding: 22px; flex: 1; }

/* ---------------------------------------------------------------- Cards */

.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-header h2, .card-header h3 { margin: 0; font-size: 16px; font-weight: 700; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 5px;
  background: linear-gradient(180deg, var(--green-500), var(--orange-500));
}
.stat-icon {
  width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--green-100); color: var(--green-700);
}
.stat-icon.orange { background: var(--orange-100); color: var(--orange-700); }
.stat-icon.danger { background: var(--danger-100); color: var(--danger); }
.stat-icon.info { background: var(--info-100); color: var(--info); }
.stat-icon svg { width: 24px; height: 24px; }
.stat-value { font-size: 21px; font-weight: 800; color: #1f2a17; line-height: 1.1; }
.stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- Forms */

label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
.form-group { margin-bottom: 14px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

input[type=text], input[type=number], input[type=password], input[type=date],
input[type=search], input[type=email], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  font-size: 14px;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(92, 184, 47, .15);
}
textarea { resize: vertical; min-height: 70px; }
.input-group { display: flex; gap: 8px; }
.input-group > * { flex: 1; }

.form-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; display: none; }

/* ---------------------------------------------------------------- Buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  transition: filter .15s, transform .05s;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: linear-gradient(135deg, var(--green-500), var(--green-700)); color: #fff; }
.btn-accent { background: linear-gradient(135deg, var(--orange-500), var(--orange-700)); color: #fff; }
.btn-outline { background: #fff; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--green-500); color: var(--green-700); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-icon { padding: 8px; }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- Table */

.table-responsive { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; min-width: 640px; background: #fff; }
thead th {
  background: #f5f8f2;
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text-muted);
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid #f0f2ec; font-size: 13.5px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafcf8; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.mono { font-variant-numeric: tabular-nums; }

.tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.tag-green { background: var(--success-100); color: var(--success); }
.tag-orange { background: var(--warning-100); color: var(--warning); }
.tag-red { background: var(--danger-100); color: var(--danger); }
.tag-gray { background: #eef1ec; color: var(--text-muted); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .search-box { position: relative; flex: 1; min-width: 200px; }
.toolbar .search-box svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-muted); }
.toolbar .search-box input { padding-left: 34px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state svg { width: 46px; height: 46px; margin-bottom: 10px; opacity: .5; }

/* ---------------------------------------------------------------- Modal */

.modal-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(20, 25, 15, .5);
  z-index: 100; align-items: flex-start; justify-content: center; padding: 30px 14px; overflow-y: auto;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius); width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg); animation: modalIn .18s ease;
}
.modal.modal-lg { max-width: 820px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(-10px);} to { opacity: 1; transform: translateY(0);} }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { margin: 0; font-size: 16px; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-muted); padding: 4px; }
.modal-close svg { width: 20px; height: 20px; }
.modal-body { padding: 20px; max-height: 72vh; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------------------------------------------------------------- Toasts */

.toast-container { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 260px; max-width: 340px; padding: 12px 16px; border-radius: var(--radius-sm);
  background: #fff; box-shadow: var(--shadow-lg); border-left: 4px solid var(--green-500);
  font-size: 13.5px; animation: toastIn .2s ease;
}
.toast.toast-error { border-color: var(--danger); }
.toast.toast-warning { border-color: var(--warning); }
@keyframes toastIn { from { opacity: 0; transform: translateX(20px);} to { opacity:1; transform: translateX(0);} }

/* ---------------------------------------------------------------- Alerts */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 14px; }
.alert-error { background: var(--danger-100); color: var(--danger); }
.alert-success { background: var(--success-100); color: var(--success); }
.alert-warning { background: var(--warning-100); color: #8a6400; }
.alert-info { background: var(--info-100); color: var(--info); }

/* ---------------------------------------------------------------- Login */

.auth-body {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, #dff0d3, transparent 45%),
              radial-gradient(circle at 80% 80%, #ffe3bf, transparent 45%), var(--bg);
  padding: 20px;
}
.auth-card {
  background: #fff; border-radius: 18px; box-shadow: var(--shadow-lg);
  padding: 34px 32px; width: 100%; max-width: 380px;
}
.auth-logo { text-align: center; margin-bottom: 18px; }
.auth-logo img { max-width: 230px; }
.auth-card h2 { text-align: center; margin: 0 0 4px; font-size: 18px; color: #1f3d16; }
.auth-card .sub { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 22px; }

/* ---------------------------------------------------------------- Misc */

.divider { height: 1px; background: var(--border); margin: 16px 0; }
.chip-currency { font-weight: 700; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #eef1ec; color: var(--text-muted); }
.help-block { background: var(--info-100); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 12.5px; color: #244d78; }
.pos-search-result { padding: 10px 12px; border-bottom: 1px solid #f0f2ec; cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.pos-search-result:hover { background: var(--green-100); }
.pos-search-result:last-child { border-bottom: none; }
.pos-results { max-height: 260px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 6px; display: none; background: #fff; position: absolute; width: 100%; z-index: 30; box-shadow: var(--shadow-lg); }
.relative { position: relative; }
canvas { max-width: 100%; }
.small { font-size: 12px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* ---------------------------------------------------------------- Responsive */

@media (max-width: 980px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrap { margin-left: 0; }
  .hamburger { display: inline-flex; }
  .sidebar-overlay.open { display: block; }
}

@media (max-width: 640px) {
  .content { padding: 14px; }
  .card { padding: 14px; }
  .stat-value { font-size: 18px; }
  .modal-body { padding: 14px; }
  .page-title { font-size: 16px; }
  thead th, tbody td { padding: 9px 10px; font-size: 12.5px; }
}
