@font-face { font-family: "IBM Plex Sans"; font-weight: 400; src: url("fonts/IBMPlexSans-Regular.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 500; src: url("fonts/IBMPlexSans-Medium.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; src: url("fonts/IBMPlexSans-SemiBold.woff2") format("woff2"); }

/* ------------------------------------------------------------------
   Tokens
------------------------------------------------------------------ */
:root {
  --ink:      #00395E;   /* navy del logo: títulos, login */
  --ink-2:    #00558D;   /* azul del logotipo: links */
  --ink-soft: #33719A;
  --sky:      #99C6E4;   /* celeste del logo */
  --sky-bg:   #EAF3FA;
  --paper:    #EEF4F9;   /* fondo */
  --card:     #FFFFFF;
  --line:     #DCE4EC;
  --text:     #15283A;
  --muted:    #5E7389;
  --amber:    #0071BC;   /* acción principal (azul vivo del logo) */
  --amber-d:  #00558D;
  --amber-bg: #EAF3FA;
  --red:      #B3261E;
  --red-bg:   #FBE9E7;
  --blue:     #1D5FA8;  --blue-bg:  #E3EDFB;
  --green:    #1E7A48;  --green-bg: #E0F3E8;
  --grey:     #5B6B70;  --grey-bg:  #E7ECEB;
  --radius:   10px;
  --radius-s: 6px;
}

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0; min-height: 100%;
  font-family: "IBM Plex Sans", -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; line-height: 1.5;
  background: var(--paper); color: var(--text);
}
.num, .money, .amount-big, td input[type=number] { font-variant-numeric: tabular-nums; }
a { color: var(--ink-2); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ------------------------------------------------------------------
   Layout: barra lateral + contenido
------------------------------------------------------------------ */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--ink) 0%, #002A47 100%);
  color: #fff;
  display: flex; flex-direction: column;
  padding: 22px 16px 24px;
}
.sidebar .brand { display: block; background: #fff; border-radius: 8px; padding: 12px 14px; }
.sidebar .brand img { display: block; width: 100%; height: auto; }
.sidebar .brand-sub { font-size: 12px; color: var(--sky); padding: 10px 4px 18px; margin-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,.14); letter-spacing: .02em; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  color: rgba(255,255,255,.72); padding: 10px 12px; border-radius: var(--radius-s);
  margin-bottom: 3px; font-weight: 500;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.sidebar nav a.active { background: var(--amber); color: #fff; }
.sidebar nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar .spacer { flex: 1; }
.sidebar .logout { color: rgba(255,255,255,.5); font-size: 13px; font-weight: 400; }

.content { flex: 1; min-width: 0; padding: 36px 44px 60px; }
.container { max-width: 960px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
h1 { font-size: 26px; font-weight: 600; letter-spacing: -.02em; margin: 0; color: var(--ink); display: flex; align-items: center; gap: 12px; }
h2 { font-size: 14px; font-weight: 600; color: var(--muted); margin: 0 0 12px; }

/* ------------------------------------------------------------------
   Componentes
------------------------------------------------------------------ */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 18px; }
.card.narrow { max-width: 540px; }
.card.accent { background: linear-gradient(135deg, var(--ink) 0%, var(--ink-2) 100%); border-color: transparent; color: #fff; }
.card.accent h2 { color: var(--sky); }
.card.accent .amount-big { color: #fff; }
.card.accent .sub { margin: 6px 0 0; color: rgba(255,255,255,.7); }
.card.table { padding: 0; overflow: hidden; }
.card.table table { margin: 0; }
.card.table th:first-child, .card.table td:first-child { padding-left: 22px; }
.card.table th:last-child, .card.table td:last-child { padding-right: 22px; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 13px; font-weight: 500; color: var(--ink-2); background: var(--sky-bg); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #F7FAFD; }
td a strong, td:nth-child(2) { white-space: nowrap; }
tfoot td { border-bottom: none; border-top: 2px solid var(--line); font-weight: 600; }
.num { text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
.empty a { font-weight: 500; }

label { display: block; margin-bottom: 14px; font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.hint { font-weight: 400; color: var(--muted); }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: var(--radius-s);
  font: inherit; color: var(--text); background: #fff;
  transition: border-color .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--ink-soft); outline: none; box-shadow: 0 0 0 3px rgba(28,84,102,.12); }
td input { margin: 0; padding: 7px 9px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border: 1px solid var(--line); background: #fff;
  border-radius: var(--radius-s); color: var(--text); font: inherit; font-weight: 500;
  cursor: pointer; transition: background .12s, border-color .12s;
}
.btn:hover { background: #F4F7F6; text-decoration: none; }
.btn.primary { background: var(--amber); border-color: var(--amber); color: #fff; }
.btn.primary:hover { background: var(--amber-d); border-color: var(--amber-d); }
.btn.danger { color: var(--red); border-color: #EBC2BE; }
.btn.danger:hover { background: var(--red-bg); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn:disabled { opacity: .55; cursor: default; }
.status-buttons .btn.active:disabled { opacity: 1; }

.actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; white-space: nowrap; }
.actions form { margin: 0; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.status-buttons { display: flex; gap: 8px; flex-wrap: wrap; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid3 { display: grid; grid-template-columns: 1.4fr 1fr 1.4fr; gap: 16px; }

.tabs { display: flex; gap: 2px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--amber); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px; border-radius: 20px; font-size: 13px; font-weight: 500; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.draft { background: var(--grey-bg);  color: var(--grey); }
.badge.sent  { background: var(--blue-bg);  color: var(--blue); }
.badge.paid  { background: var(--green-bg); color: var(--green); }
.badge.void  { background: var(--red-bg);   color: var(--red); }

code.code { background: var(--ink); color: #fff; padding: 2px 8px; border-radius: 4px; font-weight: 600; letter-spacing: .06em; font-family: inherit; }
.money { font-weight: 500; }
.amount-big { font-size: 28px; font-weight: 600; color: var(--ink); letter-spacing: -.02em; }

.flash { padding: 11px 14px; border-radius: var(--radius-s); margin-bottom: 16px; border-left: 3px solid; }
.flash.ok { background: var(--green-bg); color: var(--green); border-color: var(--green); }
.flash.error { background: var(--red-bg); color: var(--red); border-color: var(--red); }

/* ------------------------------------------------------------------
   Login
------------------------------------------------------------------ */
body.login-page { background: var(--ink); display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-box { width: 100%; max-width: 380px; background: #fff; border-radius: 14px; padding: 36px 32px 28px; }
.login-box .brand img { width: 100%; max-width: 280px; display: block; margin: 0 auto 16px; }
.login-box .sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; text-align: center; }
.login-box .btn { width: 100%; justify-content: center; padding: 11px; margin-top: 6px; }

/* ------------------------------------------------------------------
   Responsive
------------------------------------------------------------------ */
@media (max-width: 760px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; flex-direction: row; align-items: center; padding: 12px 16px; gap: 8px; }
  .sidebar .brand { padding: 6px 8px; margin: 0; width: 150px; flex-shrink: 0; }
  .sidebar .brand-sub { display: none; }
  .sidebar .brand small { display: none; }
  .sidebar nav { display: flex; }
  .sidebar nav a { padding: 6px 10px; margin: 0; white-space: nowrap; }
  .sidebar .logout { font-size: 12px; }
  .card.table { overflow-x: auto; }
  .card.table table { min-width: 640px; }
  .tabs { overflow-x: auto; }
  .tabs a { white-space: nowrap; }
  .sidebar nav a svg { display: none; }
  .content { padding: 20px 16px 40px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  h1 { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
