:root {
  --eai-primary: #0d9488;
  --eai-primary-dark: #0f766e;
  --eai-deep: #134e4a;
  --eai-darker: #0b3b38;
  --eai-light: #ccfbf1;
  --eai-soft: #f0fdfa;
  --eai-bg: #f1f6f6;
  --eai-text: #1f2d2d;
  --bs-primary: #0d9488;
  --bs-primary-rgb: 13, 148, 136;
  --bs-link-color: #0f766e;
  --bs-link-hover-color: #134e4a;
}

body { background: var(--eai-bg); color: var(--eai-text); font-size: 0.925rem; font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif; }
a { text-decoration: none; }

.btn-primary { --bs-btn-bg: var(--eai-primary); --bs-btn-border-color: var(--eai-primary); --bs-btn-hover-bg: var(--eai-primary-dark); --bs-btn-hover-border-color: var(--eai-primary-dark);
  --bs-btn-active-bg: var(--eai-deep); --bs-btn-active-border-color: var(--eai-deep); --bs-btn-disabled-bg: var(--eai-primary); --bs-btn-disabled-border-color: var(--eai-primary); }
.btn-outline-primary { --bs-btn-color: var(--eai-primary-dark); --bs-btn-border-color: var(--eai-primary); --bs-btn-hover-bg: var(--eai-primary); --bs-btn-hover-border-color: var(--eai-primary);
  --bs-btn-active-bg: var(--eai-primary-dark); --bs-btn-active-border-color: var(--eai-primary-dark); }
.text-primary { color: var(--eai-primary) !important; }
.bg-primary { background-color: var(--eai-primary) !important; }
.form-control:focus, .form-select:focus, .ts-wrapper.focus .ts-control { border-color: var(--eai-primary); box-shadow: 0 0 0 .2rem rgba(13,148,136,.18); }
.form-check-input:checked { background-color: var(--eai-primary); border-color: var(--eai-primary); }
.page-item.active .page-link { background: var(--eai-primary); border-color: var(--eai-primary); }
.page-link { color: var(--eai-primary-dark); }

/* layout */
.eai-wrap { display: flex; min-height: 100vh; }
.eai-sidebar { width: 252px; flex: 0 0 252px; background: linear-gradient(180deg, var(--eai-deep) 0%, var(--eai-darker) 100%); color: #cfeeea; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 1030; transition: margin .2s; }
.eai-brand { display: flex; align-items: center; gap: .6rem; padding: 1.05rem 1.25rem; color: #fff; font-weight: 700; letter-spacing: .6px; font-size: 1.15rem; border-bottom: 1px solid rgba(255,255,255,.08); }
.eai-brand .logo { width: 34px; height: 34px; border-radius: 9px; background: var(--eai-primary); display: grid; place-items: center; color: #fff; font-size: 1.1rem; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.eai-brand small { display: block; font-weight: 400; font-size: .68rem; letter-spacing: 0; color: #8fcfc6; margin-top: -2px; }
.eai-nav { list-style: none; padding: .6rem .6rem 2rem; margin: 0; }
.eai-nav > li { margin-bottom: 2px; }
.eai-nav a.nav-main { display: flex; align-items: center; gap: .7rem; padding: .55rem .8rem; border-radius: 8px; color: #cfeeea; font-weight: 500; }
.eai-nav a.nav-main:hover { background: rgba(255,255,255,.07); color: #fff; }
.eai-nav a.nav-main.active { background: var(--eai-primary); color: #fff; }
.eai-nav a.nav-main .caret { margin-left: auto; font-size: .7rem; transition: transform .2s; }
.eai-nav a.nav-main[aria-expanded="true"] .caret { transform: rotate(90deg); }
.eai-nav .sub { list-style: none; margin: 2px 0 6px; padding: 0 0 0 2.4rem; }
.eai-nav .sub a { display: block; padding: .32rem .7rem; border-radius: 6px; color: #9cd0c8; font-size: .86rem; }
.eai-nav .sub a:hover { color: #fff; background: rgba(255,255,255,.05); }
.eai-nav .sub a.active { color: #fff; background: rgba(13,148,136,.55); }

.eai-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.eai-top { background: #fff; border-bottom: 1px solid #dde8e7; padding: .6rem 1.25rem; display: flex; align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 1020; }
.eai-top .co-name { font-weight: 600; color: var(--eai-deep); }
.eai-content { padding: 1.4rem 1.5rem 2rem; flex: 1; }
.eai-footer { padding: .8rem 1.5rem; color: #6b8381; font-size: .8rem; border-top: 1px solid #dde8e7; background: #fff; }

@media (max-width: 991px) {
  .eai-sidebar { position: fixed; margin-left: -252px; }
  body.nav-open .eai-sidebar { margin-left: 0; box-shadow: 0 0 40px rgba(0,0,0,.4); }
  .eai-content { padding: 1rem; }
}

/* cards & tables */
.card { border: 1px solid #dde8e7; border-radius: 12px; box-shadow: 0 1px 3px rgba(19,78,74,.05); }
.card-header { background: #fff; border-bottom: 1px solid #e6efee; font-weight: 600; border-radius: 12px 12px 0 0 !important; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .6rem; margin-bottom: 1.1rem; }
.page-head h1 { font-size: 1.35rem; margin: 0; font-weight: 700; color: var(--eai-deep); }
.table > :not(caption) > * > * { padding: .55rem .75rem; }
.table thead th { background: var(--eai-soft); color: var(--eai-deep); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; border-bottom: 2px solid var(--eai-light); white-space: nowrap; }
.table-hover > tbody > tr:hover > * { background: #f4fbfa; }
.table .num, .table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tr.group-row td { background: #f6fbfa; font-weight: 600; }
.table tr.total-row td { background: var(--eai-soft); font-weight: 700; border-top: 2px solid var(--eai-primary); }

.kpi { border-radius: 12px; padding: 1rem 1.1rem; color: #fff; position: relative; overflow: hidden; height: 100%; }
.kpi .label { font-size: .78rem; opacity: .9; text-transform: uppercase; letter-spacing: .5px; }
.kpi .value { font-size: 1.45rem; font-weight: 700; margin-top: .15rem; }
.kpi i.bg { position: absolute; right: -6px; bottom: -12px; font-size: 4rem; opacity: .16; }
.kpi.k1 { background: linear-gradient(135deg, #0d9488, #14b8a6); }
.kpi.k2 { background: linear-gradient(135deg, #0f766e, #0d9488); }
.kpi.k3 { background: linear-gradient(135deg, #134e4a, #0f766e); }
.kpi.k4 { background: linear-gradient(135deg, #0e7490, #06b6d4); }
.kpi.k5 { background: linear-gradient(135deg, #b45309, #f59e0b); }
.kpi.k6 { background: linear-gradient(135deg, #be123c, #f43f5e); }
.stat-mini { background: #fff; border: 1px solid #dde8e7; border-radius: 12px; padding: .8rem 1rem; }
.stat-mini .v { font-size: 1.15rem; font-weight: 700; color: var(--eai-deep); }

.form-label { font-weight: 600; font-size: .82rem; color: #3b5452; margin-bottom: .25rem; }
.filter-bar { background: #fff; border: 1px solid #dde8e7; border-radius: 12px; padding: .7rem .9rem; margin-bottom: 1rem; }
.ts-control { border-radius: .375rem; padding: .38rem .6rem; }

/* documents */
.items-table input.form-control, .items-table select { min-width: 70px; }
.items-table td { vertical-align: middle; }
.doc-paper { background: #fff; border: 1px solid #dde8e7; border-radius: 12px; padding: 2rem; max-width: 900px; margin: 0 auto; }
.doc-paper .doc-title { font-size: 1.6rem; font-weight: 800; color: var(--eai-primary-dark); letter-spacing: 1px; text-transform: uppercase; }
.doc-paper .co-logo { max-height: 70px; max-width: 200px; }
.totals-box { min-width: 280px; }
.totals-box td { padding: .25rem .5rem; }
.totals-box tr.grand td { font-size: 1.1rem; font-weight: 700; border-top: 2px solid var(--eai-primary); color: var(--eai-deep); }

/* kanban */
.kanban { display: flex; gap: .9rem; overflow-x: auto; padding-bottom: .8rem; }
.kanban .col-k { flex: 0 0 250px; background: #e6f1f0; border-radius: 12px; padding: .7rem; }
.kanban .col-k h6 { font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; color: var(--eai-deep); display: flex; justify-content: space-between; }
.kanban .lead-card { background: #fff; border-radius: 9px; padding: .65rem .75rem; margin-bottom: .55rem; border-left: 3px solid var(--eai-primary); box-shadow: 0 1px 2px rgba(0,0,0,.06); }

/* POS */
.pos-wrap { display: grid; grid-template-columns: 1fr 440px; gap: 1rem; align-items: start; }
.pos-products { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .65rem; max-height: calc(100vh - 250px); overflow-y: auto; padding: 2px; }
.pos-item { background: #fff; border: 1px solid #dde8e7; border-radius: 10px; padding: .7rem; cursor: pointer; transition: all .12s; display: flex; flex-direction: column; gap: .2rem; user-select: none; }
.pos-item:hover { border-color: var(--eai-primary); box-shadow: 0 4px 12px rgba(13,148,136,.18); transform: translateY(-1px); }
.pos-item .nm { font-weight: 600; font-size: .85rem; line-height: 1.2; min-height: 2.1em; }
.pos-item .pr { color: var(--eai-primary-dark); font-weight: 700; }
.pos-item .st { font-size: .72rem; color: #6b8381; }
.pos-item.out { opacity: .5; }
.pos-cart { position: sticky; top: 70px; }
.pos-cart .cart-lines { max-height: calc(100vh - 470px); min-height: 120px; overflow-y: auto; }
.pos-cart .qty-box { display: inline-flex; align-items: center; gap: 2px; }
.pos-cart .qty-box input { width: 54px; text-align: center; padding: .15rem .25rem; }
.pos-total { font-size: 1.7rem; font-weight: 800; color: var(--eai-primary-dark); }
@media (max-width: 1100px) { .pos-wrap { grid-template-columns: 1fr; } .pos-cart { position: static; } .pos-products { max-height: 420px; } }

/* auth */
.auth-bg { min-height: 100vh; background: linear-gradient(135deg, var(--eai-deep) 0%, var(--eai-primary-dark) 55%, var(--eai-primary) 100%); display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.auth-card { background: #fff; border-radius: 16px; padding: 2.2rem; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,.28); }
.auth-card.wide { max-width: 640px; }
.auth-logo { width: 56px; height: 56px; border-radius: 14px; background: var(--eai-primary); color: #fff; display: grid; place-items: center; font-size: 1.7rem; margin: 0 auto .8rem; box-shadow: 0 6px 16px rgba(13,148,136,.4); }

@media print {
  .eai-sidebar, .eai-top, .eai-footer, .no-print, .page-head .btn, .filter-bar, .alert { display: none !important; }
  body { background: #fff !important; }
  .eai-content { padding: 0 !important; }
  .card, .doc-paper { border: none !important; box-shadow: none !important; }
  .doc-paper { max-width: 100%; padding: 0; }
}
