:root{
  --bg: #e7eaee;
  --bg-soft: #dfe4e8;
  --surface: #ffffff;
  --surface-soft: #f6f6f6;

  --text: #111111;
  --muted: #666666;

  --border: #111111;
  --border-soft: #d7d7d7;
  --border-lighter: #e8e8e8;

  --red: #d00000;
  --red-dark: #9b0000;

  --shadow: 0 8px 24px rgba(0,0,0,.08);
  --shadow-soft: 0 20px 50px rgba(0,0,0,.14);
  --shadow-strong: 0 14px 34px rgba(0,0,0,.10);
}

*{ box-sizing: border-box; }

html, body{ height: 100%; }

body{
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(208,0,0,.06), transparent 24%),
    radial-gradient(circle at top right, rgba(0,0,0,.04), transparent 22%),
    linear-gradient(180deg, #eef1f4 0%, var(--bg) 100%);
  background-attachment: fixed;
}

a{
  color: inherit;
  text-decoration: none;
}

a:hover{
  text-decoration: underline;
}

.container{
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 24px 36px;
}

/* ===== Helpers ===== */

.row{
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.grid-2{
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.small{
  color: var(--muted);
  font-size: 13px;
}

h1, h2, h3{
  margin: 0 0 10px;
}

/* ===== Brand ===== */

.brand{
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.brand-mark{
  width: 14px;
  height: 14px;
  background: var(--red);
  border-radius: 4px;
}

/* ===== Topbar ===== */

.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 16px;
  padding: 16px 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, #161616 0%, #0f0f0f 100%);
  color: #fff;
  border: 1px solid #111;
  box-shadow: 0 10px 26px rgba(0,0,0,.14);
}

.topbar .btn-ghost{
  background: transparent;
  color: #fff;
  border-color: rgba(255,255,255,.85);
}

.topbar .btn-ghost:hover{
  background: #fff;
  color: #111;
}

.topbar .btn-active{
  background: #fff;
  color: #111;
  border-color: #fff;
}

/* ===== Cards ===== */

.card{
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  padding: 20px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card-soft{
  background: var(--surface-soft);
  border: 1px solid #e8e8e8;
}

/* ===== Page shell opcional ===== */

.page-shell{
  background: rgba(255,255,255,.55);
  border: 1px solid rgba(255,255,255,.65);
  border-radius: 22px;
  backdrop-filter: blur(4px);
}

/* ===== Forms ===== */

.form{
  display: grid;
  gap: 14px;
  margin-top: 10px;
}

label{
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

input, select, textarea{
  width: 100%;
  min-height: 44px;
  padding: 11px 12px;
  border: 1px solid #111;
  border-radius: 10px;
  outline: none;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}

textarea{
  min-height: 92px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus{
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(208,0,0,.12);
}

/* ===== Buttons ===== */

.btn{
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #111;
  background: #111;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  transition: all .15s ease;
}

.btn:hover{
  opacity: .95;
  text-decoration: none;
}

.btn:disabled{
  opacity: .6;
  cursor: not-allowed;
}

.btn-red{
  background: var(--red);
  border-color: var(--red);
}

.btn-red:hover{
  background: var(--red-dark);
  border-color: var(--red-dark);
}

.btn-ghost{
  background: #fff;
  color: #111;
  border-color: #111;
}

.btn-ghost:hover{
  background: #f3f3f3;
}

.btn-sm{
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 13px;
}

/* ===== Alerts ===== */

.alert{
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  background: #fafafa;
  font-size: 14px;
}

.alert-error{
  border-color: rgba(208,0,0,.35);
  background: rgba(208,0,0,.06);
}

/* ===== Table ===== */

table,
.table{
  width: 100%;
  border-collapse: collapse;
}

th,
.table th{
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: #111;
  white-space: nowrap;
}

td,
.table td{
  padding: 12px 10px;
  border-bottom: 1px solid var(--border-lighter);
  font-size: 14px;
  vertical-align: middle;
}

tbody tr:hover td,
.table tr:hover td{
  background: #fafafa;
}

/* ===== Pills ===== */

.pill{
  display:inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid #111;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  background: #fff;
}

/* ===== Modal ===== */

.modal{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.35);
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 18px;
  z-index: 50;
}

.modal[hidden]{
  display:none;
}

.modal-box{
  width: min(640px, 100%);
  background: #fff;
  border: 1px solid #111;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

/* ===== MultiSelect ===== */

.ms{
  position: relative;
}

.ms-btn{
  width: 100%;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #111;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font-size: 14px;
  color: var(--text);
}

.ms-btn:focus{
  outline: none;
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(208,0,0,.12);
}

.ms-arrow{
  opacity: .75;
  user-select: none;
}

.ms-placeholder{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.ms-chip{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fafafa;
  font-size: 13px;
  line-height: 1;
}

.ms-chip button{
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0;
  opacity: .7;
}

.ms-chip button:hover{
  opacity: 1;
}

.ms-panel{
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 8px);
  z-index: 30;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 12px 30px rgba(0,0,0,.10);
  padding: 10px;
}

.ms-search{
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  font-size: 14px;
  margin-bottom: 10px;
}

.ms-search:focus{
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(208,0,0,.10);
}

.ms-options{
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border-lighter);
  border-radius: 12px;
}

.ms-opt{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px;
  border-bottom: 1px solid #f1f1f1;
}

.ms-opt:last-child{
  border-bottom: none;
}

.ms-opt:hover{
  background: #fafafa;
}

.ms-opt input{
  width: 16px;
  height: 16px;
  margin: 0;
  min-height: auto;
}

.ms-actions{
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
}

/* ===== Unidades permitidas ===== */

.unidades-grid{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}

.uni-card{
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}

.uni-card:hover{
  background: #fafafa;
}

.uni-card input{
  width: 16px;
  height: 16px;
  margin-top: 2px;
  min-height: auto;
}

.uni-name{
  line-height: 1.2;
  color: var(--text);
  font-size: 14px;
}

/* ===== Menú principal / index ===== */

.menu-card{
  position: relative;
  border: 1px solid #e5e5e5;
  border-radius: 16px;
  padding: 20px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(0,0,0,.045);
  transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}

.menu-card::before{
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 5px;
  background: linear-gradient(90deg, var(--red), #ff3b3b);
  border-radius: 16px 16px 0 0;
  opacity: .95;
}

.menu-card:hover{
  transform: translateY(-2px);
  border-color: rgba(208,0,0,.18);
  box-shadow: 0 16px 34px rgba(0,0,0,.08);
  text-decoration: none;
}

.menu-card:hover .small{
  color: #222;
}

/* ===== Filtros ===== */

.filters-grid{
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.filter-field label{
  display: block;
  margin-bottom: 6px;
}

.filter-field select,
.filter-field input{
  width: 100%;
}

.filters-actions{
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  align-items: center;
  margin-top: 2px;
}

/* ===== Login ===== */

.login-page{
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card{
  width: min(460px, 100%);
  padding: 36px 34px 30px;
  border-radius: 26px;
  background: rgba(255,255,255,.96);
  border: 1px solid #dcdcdc;
  box-shadow: 0 24px 60px rgba(0,0,0,.16);
}

.login-header{
  text-align: center;
  margin-bottom: 22px;
}

/* Logo del header */

.logo-header{
  width:52px;
  height:52px;

  display:flex;
  align-items:center;
  justify-content:center;

  border-radius:12px;

  background:linear-gradient(180deg,#1b1b1b,#0f0f0f);

  border:1px solid #222;

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.05),
    0 6px 14px rgba(0,0,0,.18);
}

.logo-header img{
  width:36px;
  height:auto;

  filter:
    drop-shadow(0 4px 8px rgba(0,0,0,.4))
    contrast(1.05)
    saturate(1.05);
}

.login-logo-wrap{
  width: 240px;
  height: 240px;
  margin: 0 auto 18px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 28px;

  background: linear-gradient(180deg,#1b1b1b,#0f0f0f);

  border: 1px solid #222;

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.06),
    0 20px 40px rgba(0,0,0,.25);
}

.login-logo{
  width: 185px;
  height: auto;
  display: block;

  filter:
    drop-shadow(0 14px 24px rgba(0,0,0,.35))
    contrast(1.05)
    saturate(1.08);
}

.login-title{
  font-weight: 800;
  font-size: 17px;
  letter-spacing: .2px;
  margin-bottom: 6px;
}

.login-card input{
  min-height: 56px;
  font-size: 16px;
  border-radius: 16px;
  border-color: #2a2a2a;
  background: #fff;
}

.login-card .btn-red{
  min-height: 54px;
  font-size: 17px;
  border-radius: 16px;
  box-shadow: 0 14px 24px rgba(208,0,0,.24);
}

.login-logo-wrap{
  transform: translateY(-6px);
}

/* ===== Responsive ===== */

@media (max-width: 980px){
  .filters-grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .unidades-grid{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px){
  .unidades-grid{
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px){
  .container{
    padding: 18px 14px 24px;
  }

  .grid-2{
    grid-template-columns: 1fr;
  }

  .filters-grid{
    grid-template-columns: 1fr;
  }

  .filters-actions{
    justify-content: stretch;
  }

  .filters-actions .btn{
    flex: 1;
  }

  .row{
    flex-wrap: wrap;
  }

  .topbar{
    padding: 14px;
    border-radius: 16px;
  }

  .card{
    padding: 16px;
  }

  .login-card{
    padding: 24px 20px 22px;
  }

  .login-logo-wrap{
    width: 180px;
    height: 180px;
    border-radius: 24px;
  }

  .login-logo{
    width: 138px;
  }
}