:root{
  --bg:#f3f6f4;
  --bg-2:#edf2ef;
  --card:#ffffff;
  --card-2:#f8faf9;
  --surface:#ffffff;
  --text:#2b2f33;
  --muted:#67716d;
  --line:#d6e0dc;
  --brand:#0e5a4f;
  --brand-2:#0a463e;
  --brand-button:#0e5a4f;
  --sidebar:#0e5a4f;
  --accent:#c8b89a;
  --accent-dark:#9f8c69;
  --accent-soft:#f2eee6;
  --ok:#198754;
  --warn:#d79b37;
  --bad:#c9434f;
  --danger:#c9434f;
  --info:#16796c;
  --soft:#edf4f1;
  --soft-2:#f7faf8;
  --shadow:0 12px 32px rgba(14,90,79,.09);
  --radius:16px;
  --radius-sm:10px;
  --sidebar-w:280px;
  --topbar-h:72px;
}

html[data-theme="dark"]{
  --bg:#121715;
  --bg-2:#171d1b;
  --card:#1b2320;
  --card-2:#161d1a;
  --surface:#1b2320;
  --text:#edf1ef;
  --muted:#aab4b0;
  --line:#35423d;
  --brand:#64b7aa;
  --brand-2:#0e5a4f;
  --brand-button:#0e5a4f;
  --sidebar:#083f37;
  --accent:#d3c4a7;
  --accent-dark:#b7a17b;
  --accent-soft:#302d27;
  --ok:#36a46d;
  --warn:#e0aa4f;
  --bad:#e0616b;
  --danger:#e0616b;
  --info:#69b9ad;
  --soft:#202b27;
  --soft-2:#17211d;
  --shadow:0 12px 32px rgba(0,0,0,.30);
}

*{
  box-sizing:border-box;
}

html, body{
  margin:0;
  padding:0;
  min-height:100%;
}

body{
  font-family:Arial, Helvetica, sans-serif;
  background:var(--bg);
  color:var(--text);
  accent-color:var(--brand-button);
}

button,
input,
select,
textarea{
  font:inherit;
}

a{
  color:var(--info);
  text-decoration:none;
}

a:hover{
  text-decoration:underline;
}

img{
  max-width:100%;
  display:block;
}

.hidden{
  display:none !important;
}

.small{
  font-size:12px;
}

.muted{
  color:var(--muted);
}

.soft{
  background:var(--soft);
}

.noscript-banner{
  padding:14px 16px;
  background:#fff3cd;
  color:#664d03;
  border-bottom:1px solid #ffecb5;
}

.app-root{
  min-height:100vh;
}

.app-overlay{
  position:fixed;
  inset:0;
  background:rgba(15,23,42,.48);
  z-index:90;
}

/* login */

.login-page{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:24px;
  background:
    radial-gradient(circle at 12% 18%, rgba(200,184,154,.24), transparent 30%),
    linear-gradient(145deg, var(--bg) 0%, var(--bg-2) 100%);
}

.login-card{
  width:min(520px,100%);
  background:var(--card);
  border:1px solid var(--line);
  border-top:5px solid var(--accent);
  border-radius:24px;
  box-shadow:var(--shadow);
  padding:28px;
}

.login-logo-wrap{
  width:min(360px,100%);
  height:124px;
  margin:0 auto 18px;
  border-radius:18px;
  background:#ffffff;
  border:1px solid var(--line);
  display:grid;
  place-items:center;
  overflow:hidden;
  padding:14px 18px;
}

.login-logo{
  width:100%;
  height:100%;
  object-fit:contain;
}

.login-logo-fallback{
  font-weight:700;
  color:var(--brand);
  font-size:18px;
  letter-spacing:.08em;
}

.login-title{
  margin:0 0 8px;
  text-align:center;
  font-size:28px;
  line-height:1.15;
  color:var(--brand);
}

.login-subtitle{
  margin:0 0 18px;
  text-align:center;
  color:var(--muted);
}

.login-demo{
  margin-top:16px;
}

html[data-theme="dark"] .login-logo-wrap,
html[data-theme="dark"] .brand-logo-wrap{
  background:#ffffff;
}

.login-card::after{
  content:"";
  display:block;
  width:72px;
  height:3px;
  margin:18px auto 0;
  border-radius:999px;
  background:var(--accent);
}

/* shell */

.shell{
  display:grid;
  grid-template-columns:var(--sidebar-w) 1fr;
  min-height:100vh;
}

.sidebar{
  background:linear-gradient(180deg, var(--sidebar) 0%, var(--brand-2) 100%);
  color:#fff;
  padding:18px;
  position:sticky;
  top:0;
  height:100vh;
  overflow:auto;
  z-index:80;
}

.sidebar-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom:18px;
}

.brand-block{
  display:flex;
  gap:12px;
  align-items:center;
  min-width:0;
}

.brand-logo-wrap{
  width:52px;
  height:52px;
  border-radius:14px;
  background:#fff;
  border:1px solid rgba(255,255,255,.28);
  display:grid;
  place-items:center;
  overflow:hidden;
  flex:0 0 auto;
}

.brand-logo{
  width:100%;
  height:100%;
  object-fit:contain;
}

.brand-logo-fallback{
  font-weight:700;
  font-size:15px;
}

.brand-texts{
  min-width:0;
}

.brand-title{
  margin:0 0 4px;
  font-size:17px;
  line-height:1.2;
  color:#fff;
}

.brand-subtitle{
  font-size:12px;
  opacity:.82;
  line-height:1.35;
}

.sidebar-nav{
  display:grid;
  gap:6px;
}

.sidebar-nav button{
  width:100%;
  text-align:left;
  border:none;
  background:transparent;
  color:#fff;
  padding:11px 12px;
  border-radius:10px;
  cursor:pointer;
  transition:background .15s ease;
}

.sidebar-nav button:hover,
.sidebar-nav button.active{
  background:rgba(200,184,154,.22);
  box-shadow:inset 3px 0 0 var(--accent);
}

.shell-main{
  min-width:0;
}

.topbar{
  height:var(--topbar-h);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 18px;
  position:sticky;
  top:0;
  z-index:40;
  background:rgba(243,246,244,.88);
  backdrop-filter:blur(10px);
  border-bottom:1px solid var(--line);
}

html[data-theme="dark"] .topbar{
  background:rgba(18,23,21,.88);
}

.topbar-left,
.topbar-right{
  display:flex;
  align-items:center;
  gap:10px;
  min-width:0;
}

.topbar-search{
  width:min(420px, calc(100vw - 220px));
}

.topbar-search input{
  width:100%;
}

.topbar-badge{
  position:absolute;
  top:-4px;
  right:-4px;
  min-width:18px;
  height:18px;
  padding:0 5px;
  border-radius:999px;
  background:var(--bad);
  color:#fff;
  font-size:11px;
  line-height:18px;
  text-align:center;
}

.main-content{
  padding:18px;
}

.page-header{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  flex-wrap:wrap;
  margin-bottom:16px;
}

.page-title{
  margin:0 0 4px;
  font-size:28px;
  line-height:1.1;
  color:var(--brand);
}

.page-subtitle{
  margin:0;
  color:var(--muted);
}

.view-root{
  min-height:400px;
}

/* layout helpers */

.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:16px;
  margin-bottom:16px;
}

.grid{
  display:grid;
  gap:14px;
}

.grid.cards{
  grid-template-columns:repeat(auto-fit, minmax(180px,1fr));
}

.two{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}

.three{
  display:grid;
  grid-template-columns:repeat(3, 1fr);
  gap:12px;
}

.row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}

.row.end{
  justify-content:flex-end;
}

/* stats */

.stat{
  padding:14px;
  border-radius:14px;
  background:var(--soft);
  border:1px solid var(--line);
}

.stat .num{
  font-size:28px;
  font-weight:700;
  margin-top:4px;
}

/* forms */

.form-grid{
  display:grid;
  gap:12px;
}

.form-field{
  display:grid;
  gap:5px;
}

label{
  display:block;
  font-size:13px;
  color:var(--muted);
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="number"],
input[type="email"],
input[type="file"],
textarea,
select{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:10px;
  background:var(--card);
  color:var(--text);
}

textarea{
  min-height:90px;
  resize:vertical;
}

input:focus,
select:focus,
textarea:focus{
  outline:3px solid rgba(14,90,79,.14);
  border-color:var(--brand);
}

/* buttons */

.btn{
  padding:10px 14px;
  border:none;
  border-radius:10px;
  cursor:pointer;
  transition:opacity .15s ease, transform .15s ease;
}

.btn:hover{
  opacity:.94;
}

.btn:active{
  transform:translateY(1px);
}

.btn.primary{
  background:var(--brand-button);
  color:#fff;
}

.btn.secondary{
  background:var(--accent-soft);
  color:var(--text);
  border:1px solid rgba(159,140,105,.28);
}

html[data-theme="dark"] .btn.secondary{
  background:var(--accent-soft);
  color:var(--text);
}

.btn.success{
  background:var(--ok);
  color:#fff;
}

.btn.warn{
  background:var(--warn);
  color:#111827;
}

.btn.danger{
  background:var(--bad);
  color:#fff;
}

.icon-btn{
  border:none;
  background:var(--card);
  color:var(--text);
  width:40px;
  height:40px;
  border-radius:10px;
  display:grid;
  place-items:center;
  cursor:pointer;
  border:1px solid var(--line);
  position:relative;
}

.icon-btn:hover{
  background:var(--soft);
}

.has-badge{
  overflow:visible;
}

/* tables */

.table-wrap{
  overflow:auto;
}

table{
  width:100%;
  border-collapse:collapse;
  font-size:14px;
}

th,
td{
  padding:10px;
  border-bottom:1px solid var(--line);
  vertical-align:top;
  text-align:left;
}

th{
  background:var(--soft-2);
  font-weight:700;
}

tr[data-open-incident]{
  cursor:pointer;
}

tr[data-open-incident]:hover{
  background:var(--soft-2);
}

/* badges */

.badge{
  display:inline-block;
  padding:4px 8px;
  border-radius:999px;
  font-size:12px;
  font-weight:700;
}

.status-sin_programar{
  background:#e5e7eb;
  color:#111827;
}

.status-programada{
  background:#dbeafe;
  color:#1e3a8a;
}

.status-en_proceso{
  background:#ffedd5;
  color:#9a3412;
}

.status-cotizacion{
  background:#fef3c7;
  color:#854d0e;
}

.status-revision{
  background:#ede9fe;
  color:#5b21b6;
}

.status-terminada{
  background:#dcfce7;
  color:#166534;
}

.status-vencida{
  background:#fecaca;
  color:#991b1b;
}

.status-en_espera{
  background:#fde68a;
  color:#78350f;
}

.status-cancelada{
  background:#e5e7eb;
  color:#374151;
}

/* detail */

.kv{
  display:grid;
  grid-template-columns:180px 1fr;
  gap:8px;
  font-size:14px;
}

.kv div:nth-child(odd){
  color:var(--muted);
}

details{
  border:1px solid var(--line);
  border-radius:12px;
  padding:8px 12px;
  background:var(--card);
  margin-bottom:8px;
}

summary{
  cursor:pointer;
  font-weight:700;
}

/* board */

.board{
  display:grid;
  grid-template-columns:repeat(3, minmax(240px, 1fr));
  gap:12px;
}

.column{
  background:var(--soft-2);
  border:1px solid var(--line);
  border-radius:12px;
  padding:10px;
  min-height:250px;
}

.ticket{
  background:var(--card);
  border:1px solid var(--line);
  border-left:5px solid var(--brand);
  border-radius:12px;
  padding:10px;
  margin-bottom:10px;
  cursor:pointer;
}

.ticket.vencida{
  border-left-color:var(--bad);
}

/* notes / messages */

.notice{
  padding:10px 12px;
  background:var(--soft);
  border:1px solid var(--line);
  border-left:4px solid var(--brand);
  border-radius:10px;
}

.warningBox{
  padding:10px 12px;
  background:#fff7ed;
  border:1px solid #fdba74;
  border-radius:10px;
}

.dangerBox{
  padding:10px 12px;
  background:#fef2f2;
  border:1px solid #fecaca;
  border-radius:10px;
}

.note{
  border-left:4px solid var(--brand);
  padding-left:10px;
  margin:8px 0;
}

/* modal / drawer */

.modal-backdrop{
  position:fixed;
  inset:0;
  background:rgba(15,23,42,.48);
  display:grid;
  place-items:center;
  z-index:120;
  padding:20px;
}

.modal-card{
  width:min(720px, 100%);
  max-height:90vh;
  overflow:auto;
  background:var(--card);
  border:1px solid var(--line);
  border-radius:18px;
  box-shadow:var(--shadow);
}

.modal-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:16px 16px 8px;
  border-bottom:1px solid var(--line);
}

.modal-title{
  margin:0;
  color:var(--brand);
}

.modal-body{
  padding:16px;
}

.modal-footer{
  padding:0 16px 16px;
  display:flex;
  justify-content:flex-end;
  gap:10px;
  flex-wrap:wrap;
}

.drawer-panel{
  position:fixed;
  top:0;
  right:0;
  width:min(520px, 100%);
  height:100vh;
  background:var(--card);
  border-left:1px solid var(--line);
  box-shadow:var(--shadow);
  z-index:130;
  display:flex;
  flex-direction:column;
}

.drawer-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:16px;
  border-bottom:1px solid var(--line);
}

.drawer-title{
  margin:0;
  color:var(--brand);
}

.drawer-body{
  padding:16px;
  overflow:auto;
  flex:1;
}

/* toasts */

.toast-root{
  position:fixed;
  right:16px;
  bottom:16px;
  z-index:140;
  display:grid;
  gap:10px;
  max-width:min(360px, calc(100vw - 32px));
}

.toast{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:14px;
  box-shadow:var(--shadow);
  padding:12px 14px;
}

.toast.success{
  border-left:5px solid var(--ok);
}

.toast.warn{
  border-left:5px solid var(--warn);
}

.toast.danger{
  border-left:5px solid var(--bad);
}

.toast.info{
  border-left:5px solid var(--info);
}

/* utilities */

.mobile-only{
  display:none;
}

.desktop-only{
  display:initial;
}

hr{
  border:none;
  border-top:1px solid var(--line);
  margin:14px 0;
}

/* responsive */

@media (max-width:1024px){
  .board{
    grid-template-columns:1fr 1fr;
  }

  .three{
    grid-template-columns:1fr 1fr;
  }
}

@media (max-width:860px){
  .shell{
    grid-template-columns:1fr;
  }

  .sidebar{
    position:fixed;
    left:0;
    top:0;
    width:min(86vw, 320px);
    max-width:320px;
    transform:translateX(-100%);
    transition:transform .22s ease;
    height:100vh;
  }

  .sidebar.open{
    transform:translateX(0);
  }

  .mobile-only{
    display:grid;
  }

  .topbar{
    padding:12px 14px;
  }

  .main-content{
    padding:14px;
  }

  .topbar-search{
    width:min(100%, 320px);
  }

  .board{
    grid-template-columns:1fr;
  }

  .two,
  .three,
  .kv{
    grid-template-columns:1fr;
  }

  .page-title{
    font-size:24px;
  }
}

@media (max-width:520px){
  .login-card{
    padding:18px;
    border-radius:18px;
  }

  .login-logo-wrap{
    height:104px;
    padding:12px;
  }

  .login-title{
    font-size:24px;
  }

  .main-content{
    padding:12px;
  }

  .card{
    padding:14px;
  }

  .topbar-right{
    gap:8px;
  }

  .icon-btn{
    width:38px;
    height:38px;
  }
}