/* ===== Sistema Corralón — paletas de color =====
   Selección: html[data-palette="…"] + claro/oscuro (html.dark) */

:root {
  --radius: 0.85rem;
  --header-h: 3.5rem;
  --sidebar-w: 17rem;
  --space-1: 0.5rem;
  --space-2: 0.85rem;
  --space-3: 1.25rem;
  --space-4: 1.75rem;
  --space-5: 2.25rem;
  color-scheme: light;
}

/* —— SGM Matafuegos (default) —— peach / safety orange / mint —— */
:root,
html[data-palette="sgm-matafuegos"] {
  --bg: #f3faf5;
  --bg-elevated: #f8fcf9;
  --surface: #ffffff;
  --surface-2: #fff7ed;
  --ink: #1c1917;
  --ink-soft: #44403c;
  --muted: #78716c;
  --border: #fdba74;
  --border-soft: #fed7aa;
  --accent: #ea580c;
  --accent-hover: #c2410c;
  --accent-soft: rgba(249, 115, 22, 0.12);
  --accent-text: #c2410c;
  --sidebar-bg: #fff7ed;
  --sidebar-mid: #ffedd5;
  --sidebar-deep: #ecfdf5;
  --sidebar-ink: #1c1917;
  --sidebar-muted: #78716c;
  --sidebar-glow: rgba(234, 88, 12, 0.18);
  --sidebar-hover: rgba(234, 88, 12, 0.1);
  --sidebar-active: rgba(249, 115, 22, 0.18);
  --brand-a: #fdba74;
  --brand-b: #ea580c;
  --brand-c: #059669;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --err-bg: #fef2f2;
  --info: #78716c;
  --info-bg: #f5f5f4;
  --warn: #ea580c;
  --warn-bg: #fff7ed;
  --shadow: 0 8px 24px rgba(234, 88, 12, 0.08), 0 1px 3px rgba(28, 25, 23, 0.04);
  --shell-glow-a: rgba(253, 186, 116, 0.35);
  --shell-glow-b: rgba(167, 243, 208, 0.4);
  --login-a: rgba(253, 186, 116, 0.45);
  --login-b: rgba(16, 185, 129, 0.25);
  --login-grad: linear-gradient(165deg, #ea580c 0%, #c2410c 42%, #1c1917 100%);
}

html.dark,
html.dark[data-palette="sgm-matafuegos"] {
  --bg: #1c1917;
  --bg-elevated: #292524;
  --surface: #292524;
  --surface-2: #44403c;
  --ink: #fafaf9;
  --ink-soft: #e7e5e4;
  --muted: #a8a29e;
  --border: #57534e;
  --border-soft: #44403c;
  --accent: #fb923c;
  --accent-hover: #fdba74;
  --accent-soft: rgba(251, 146, 60, 0.18);
  --accent-text: #fdba74;
  --sidebar-bg: #1c1917;
  --sidebar-mid: #292524;
  --sidebar-deep: #0c0a09;
  --sidebar-ink: #fafaf9;
  --sidebar-muted: #a8a29e;
  --sidebar-glow: rgba(251, 146, 60, 0.2);
  --sidebar-hover: rgba(251, 146, 60, 0.12);
  --sidebar-active: rgba(251, 146, 60, 0.22);
  --brand-a: #fdba74;
  --brand-b: #fb923c;
  --brand-c: #34d399;
  --danger: #f87171;
  --danger-soft: #3f2a2a;
  --ok: #34d399;
  --ok-bg: #14433a;
  --err-bg: #3f2a2a;
  --info: #a8a29e;
  --info-bg: #292524;
  --warn: #fb923c;
  --warn-bg: #3a2e20;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  --shell-glow-a: rgba(251, 146, 60, 0.14);
  --shell-glow-b: rgba(52, 211, 153, 0.1);
  --login-a: rgba(251, 146, 60, 0.25);
  --login-b: rgba(52, 211, 153, 0.15);
  --login-grad: linear-gradient(165deg, #1c1917 0%, #292524 48%, #44403c 100%);
  color-scheme: dark;
}

/* —— Sapphire nightfall whisper —— */
html[data-palette="sapphire"] {
  --bg: #eef3fa;
  --bg-elevated: #f6f9fc;
  --surface: #fcfdff;
  --surface-2: #e4ecf7;
  --ink: #262b40;
  --ink-soft: #2c444c;
  --muted: #5379ae;
  --border: #c4d2e6;
  --border-soft: #d9e4f2;
  --accent: #0474c4;
  --accent-hover: #06457f;
  --accent-soft: rgba(4, 116, 196, 0.14);
  --accent-text: #06457f;
  --sidebar-bg: #262b40;
  --sidebar-mid: #2c444c;
  --sidebar-deep: #1e2335;
  --sidebar-ink: #eef3fa;
  --sidebar-muted: #a8c4ec;
  --sidebar-glow: rgba(4, 116, 196, 0.35);
  --sidebar-hover: rgba(168, 196, 236, 0.12);
  --sidebar-active: rgba(4, 116, 196, 0.42);
  --brand-a: #a8c4ec;
  --brand-b: #0474c4;
  --brand-c: #06457f;
  --danger: #c45c6a;
  --danger-soft: #f7e6e9;
  --ok: #3d7a6a;
  --ok-bg: #e5f2ee;
  --err-bg: #f7e6e9;
  --info: #5379ae;
  --info-bg: #e4ecf7;
  --warn: #c48a3d;
  --warn-bg: #f7efdf;
  --shadow: 0 12px 32px rgba(38, 43, 64, 0.14);
  --shell-glow-a: rgba(168, 196, 236, 0.45);
  --shell-glow-b: rgba(4, 116, 196, 0.08);
  --login-a: rgba(168, 196, 236, 0.45);
  --login-b: rgba(4, 116, 196, 0.35);
  --login-grad: linear-gradient(165deg, #06457f 0%, #262b40 48%, #2c444c 100%);
}

html.dark[data-palette="sapphire"] {
  --bg: #1a1e2c;
  --bg-elevated: #222738;
  --surface: #2c444c;
  --surface-2: #344e57;
  --ink: #eef3fa;
  --ink-soft: #c5d4e8;
  --muted: #a8c4ec;
  --border: #3d5560;
  --border-soft: #354a53;
  --accent: #47a0e0;
  --accent-hover: #6bb3e8;
  --accent-soft: rgba(71, 160, 224, 0.2);
  --accent-text: #a8c4ec;
  --sidebar-bg: #262b40;
  --sidebar-mid: #2c444c;
  --sidebar-deep: #1a1e2c;
  --sidebar-ink: #eef3fa;
  --sidebar-muted: #a8c4ec;
  --sidebar-glow: rgba(4, 116, 196, 0.28);
  --sidebar-hover: rgba(168, 196, 236, 0.1);
  --sidebar-active: rgba(4, 116, 196, 0.45);
  --brand-a: #a8c4ec;
  --brand-b: #47a0e0;
  --brand-c: #06457f;
  --danger: #e08a96;
  --danger-soft: #3f2a30;
  --ok: #7eb8a8;
  --ok-bg: #243a36;
  --err-bg: #3f2a30;
  --info: #8fb0d8;
  --info-bg: #243040;
  --warn: #e0b878;
  --warn-bg: #3a3224;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.4);
  --shell-glow-a: rgba(4, 116, 196, 0.18);
  --shell-glow-b: rgba(38, 43, 64, 0.5);
  --login-a: rgba(71, 160, 224, 0.25);
  --login-b: rgba(4, 116, 196, 0.2);
  --login-grad: linear-gradient(165deg, #1a1e2c 0%, #262b40 48%, #2c444c 100%);
  color-scheme: dark;
}

/* —— Autumn luxe —— #E2E1EB #AAAAAE #322D27 #7F7265 #BF8440 */
html[data-palette="autumn-luxe"] {
  --bg: #f4f3f7;
  --bg-elevated: #faf9fb;
  --surface: #ffffff;
  --surface-2: #e2e1eb;
  --ink: #322d27;
  --ink-soft: #4a433c;
  --muted: #7f7265;
  --border: #cfcad3;
  --border-soft: #e2e1eb;
  --accent: #bf8440;
  --accent-hover: #9a6830;
  --accent-soft: rgba(191, 132, 64, 0.16);
  --accent-text: #7a5224;
  --sidebar-bg: #322d27;
  --sidebar-mid: #3f3831;
  --sidebar-deep: #241f1b;
  --sidebar-ink: #f4f3f7;
  --sidebar-muted: #aaaaae;
  --sidebar-glow: rgba(191, 132, 64, 0.35);
  --sidebar-hover: rgba(226, 225, 235, 0.1);
  --sidebar-active: rgba(191, 132, 64, 0.4);
  --brand-a: #e2e1eb;
  --brand-b: #bf8440;
  --brand-c: #7f7265;
  --danger: #b54a4a;
  --danger-soft: #f5e6e6;
  --ok: #5f7a5a;
  --ok-bg: #e8efe6;
  --err-bg: #f5e6e6;
  --info: #7f7265;
  --info-bg: #ebe9ef;
  --warn: #bf8440;
  --warn-bg: #f7eedf;
  --shadow: 0 12px 32px rgba(50, 45, 39, 0.14);
  --shell-glow-a: rgba(226, 225, 235, 0.7);
  --shell-glow-b: rgba(191, 132, 64, 0.1);
  --login-a: rgba(226, 225, 235, 0.35);
  --login-b: rgba(191, 132, 64, 0.3);
  --login-grad: linear-gradient(165deg, #7f7265 0%, #322d27 50%, #241f1b 100%);
}

html.dark[data-palette="autumn-luxe"] {
  --bg: #1f1c19;
  --bg-elevated: #2a2621;
  --surface: #322d27;
  --surface-2: #3f3831;
  --ink: #f0eeef;
  --ink-soft: #d5d2d6;
  --muted: #aaaaae;
  --border: #4a433c;
  --border-soft: #3f3831;
  --accent: #d4a05c;
  --accent-hover: #e2b878;
  --accent-soft: rgba(212, 160, 92, 0.2);
  --accent-text: #e2e1eb;
  --sidebar-bg: #241f1b;
  --sidebar-mid: #322d27;
  --sidebar-deep: #181512;
  --sidebar-ink: #f0eeef;
  --sidebar-muted: #aaaaae;
  --sidebar-glow: rgba(191, 132, 64, 0.28);
  --sidebar-hover: rgba(226, 225, 235, 0.08);
  --sidebar-active: rgba(191, 132, 64, 0.38);
  --brand-a: #e2e1eb;
  --brand-b: #d4a05c;
  --brand-c: #7f7265;
  --danger: #e08a8a;
  --danger-soft: #3a2828;
  --ok: #9bb896;
  --ok-bg: #2a3428;
  --err-bg: #3a2828;
  --info: #c5c0c8;
  --info-bg: #2e2b30;
  --warn: #e0b878;
  --warn-bg: #3a3224;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  --shell-glow-a: rgba(191, 132, 64, 0.12);
  --shell-glow-b: rgba(50, 45, 39, 0.5);
  --login-grad: linear-gradient(165deg, #1f1c19 0%, #322d27 50%, #241f1b 100%);
  color-scheme: dark;
}

/* —— Inked —— #000000 #DFDEDC #464545 #00ACAC #A6A7A2 */
html[data-palette="inked"] {
  --bg: #f3f2f0;
  --bg-elevated: #faf9f8;
  --surface: #ffffff;
  --surface-2: #dfdedc;
  --ink: #000000;
  --ink-soft: #464545;
  --muted: #6e6f6b;
  --border: #c4c4c0;
  --border-soft: #dfdedc;
  --accent: #00acac;
  --accent-hover: #008989;
  --accent-soft: rgba(0, 172, 172, 0.14);
  --accent-text: #006e6e;
  --sidebar-bg: #000000;
  --sidebar-mid: #1a1a1a;
  --sidebar-deep: #000000;
  --sidebar-ink: #dfdedc;
  --sidebar-muted: #a6a7a2;
  --sidebar-glow: rgba(0, 172, 172, 0.4);
  --sidebar-hover: rgba(223, 222, 220, 0.1);
  --sidebar-active: rgba(0, 172, 172, 0.4);
  --brand-a: #dfdedc;
  --brand-b: #00acac;
  --brand-c: #464545;
  --danger: #c44a4a;
  --danger-soft: #f5e6e6;
  --ok: #00acac;
  --ok-bg: #dff5f5;
  --err-bg: #f5e6e6;
  --info: #464545;
  --info-bg: #ebeae8;
  --warn: #c49a3d;
  --warn-bg: #f7efdf;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
  --shell-glow-a: rgba(223, 222, 220, 0.7);
  --shell-glow-b: rgba(0, 172, 172, 0.1);
  --login-a: rgba(0, 172, 172, 0.25);
  --login-b: rgba(70, 69, 69, 0.35);
  --login-grad: linear-gradient(165deg, #464545 0%, #000000 55%, #1a1a1a 100%);
}

html.dark[data-palette="inked"] {
  --bg: #0a0a0a;
  --bg-elevated: #161616;
  --surface: #1e1e1e;
  --surface-2: #2a2a2a;
  --ink: #dfdedc;
  --ink-soft: #c4c4c0;
  --muted: #a6a7a2;
  --border: #3a3a3a;
  --border-soft: #2a2a2a;
  --accent: #22c8c8;
  --accent-hover: #4adada;
  --accent-soft: rgba(34, 200, 200, 0.18);
  --accent-text: #7ee8e8;
  --sidebar-bg: #000000;
  --sidebar-mid: #141414;
  --sidebar-deep: #000000;
  --sidebar-ink: #dfdedc;
  --sidebar-muted: #a6a7a2;
  --sidebar-glow: rgba(0, 172, 172, 0.3);
  --sidebar-hover: rgba(223, 222, 220, 0.08);
  --sidebar-active: rgba(0, 172, 172, 0.38);
  --brand-a: #dfdedc;
  --brand-b: #22c8c8;
  --brand-c: #464545;
  --danger: #e08a8a;
  --danger-soft: #3a2424;
  --ok: #5ecfcf;
  --ok-bg: #143333;
  --err-bg: #3a2424;
  --info: #a6a7a2;
  --info-bg: #222222;
  --warn: #e0b878;
  --warn-bg: #3a3224;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.55);
  --shell-glow-a: rgba(0, 172, 172, 0.12);
  --shell-glow-b: rgba(0, 0, 0, 0.6);
  --login-grad: linear-gradient(165deg, #0a0a0a 0%, #000000 55%, #1a1a1a 100%);
  color-scheme: dark;
}

/* —— Wraith —— #1E1702 #E5E3E4 #8C886B #047C58 #342005 */
html[data-palette="wraith"] {
  --bg: #f2f1ee;
  --bg-elevated: #f8f7f5;
  --surface: #ffffff;
  --surface-2: #e5e3e4;
  --ink: #1e1702;
  --ink-soft: #342005;
  --muted: #8c886b;
  --border: #c8c5b8;
  --border-soft: #e5e3e4;
  --accent: #047c58;
  --accent-hover: #035c42;
  --accent-soft: rgba(4, 124, 88, 0.14);
  --accent-text: #035c42;
  --sidebar-bg: #1e1702;
  --sidebar-mid: #342005;
  --sidebar-deep: #120e01;
  --sidebar-ink: #e5e3e4;
  --sidebar-muted: #8c886b;
  --sidebar-glow: rgba(4, 124, 88, 0.4);
  --sidebar-hover: rgba(229, 227, 228, 0.1);
  --sidebar-active: rgba(4, 124, 88, 0.42);
  --brand-a: #e5e3e4;
  --brand-b: #047c58;
  --brand-c: #342005;
  --danger: #a84838;
  --danger-soft: #f5e8e4;
  --ok: #047c58;
  --ok-bg: #dff2eb;
  --err-bg: #f5e8e4;
  --info: #8c886b;
  --info-bg: #ebeae4;
  --warn: #b8923d;
  --warn-bg: #f5efdf;
  --shadow: 0 12px 32px rgba(30, 23, 2, 0.14);
  --shell-glow-a: rgba(229, 227, 228, 0.7);
  --shell-glow-b: rgba(4, 124, 88, 0.1);
  --login-a: rgba(4, 124, 88, 0.3);
  --login-b: rgba(140, 136, 107, 0.25);
  --login-grad: linear-gradient(165deg, #342005 0%, #1e1702 50%, #120e01 100%);
}

html.dark[data-palette="wraith"] {
  --bg: #141008;
  --bg-elevated: #1e1702;
  --surface: #2a220c;
  --surface-2: #342005;
  --ink: #e5e3e4;
  --ink-soft: #d0cdc4;
  --muted: #8c886b;
  --border: #4a3f24;
  --border-soft: #342005;
  --accent: #2db888;
  --accent-hover: #4fd0a0;
  --accent-soft: rgba(45, 184, 136, 0.2);
  --accent-text: #a8e0cc;
  --sidebar-bg: #1e1702;
  --sidebar-mid: #342005;
  --sidebar-deep: #0e0b01;
  --sidebar-ink: #e5e3e4;
  --sidebar-muted: #8c886b;
  --sidebar-glow: rgba(4, 124, 88, 0.3);
  --sidebar-hover: rgba(229, 227, 228, 0.08);
  --sidebar-active: rgba(4, 124, 88, 0.4);
  --brand-a: #e5e3e4;
  --brand-b: #2db888;
  --brand-c: #342005;
  --danger: #e08a7a;
  --danger-soft: #3a2820;
  --ok: #5ecfa8;
  --ok-bg: #1a3328;
  --err-bg: #3a2820;
  --info: #b0ab90;
  --info-bg: #2a2618;
  --warn: #e0c078;
  --warn-bg: #3a3220;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.5);
  --shell-glow-a: rgba(4, 124, 88, 0.12);
  --shell-glow-b: rgba(30, 23, 2, 0.55);
  --login-grad: linear-gradient(165deg, #141008 0%, #1e1702 50%, #342005 100%);
  color-scheme: dark;
}

/* —— Clockwork —— #919599 #CDCDCB #F8F8F8 #FBA45C #E56515 */
html[data-palette="clockwork"] {
  --bg: #f8f8f8;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #cdcdcb;
  --ink: #3d4043;
  --ink-soft: #5c6064;
  --muted: #919599;
  --border: #c5c5c3;
  --border-soft: #e4e4e2;
  --accent: #e56515;
  --accent-hover: #c45410;
  --accent-soft: rgba(229, 101, 21, 0.14);
  --accent-text: #a8460e;
  --sidebar-bg: #4a4e52;
  --sidebar-mid: #5c6064;
  --sidebar-deep: #383c40;
  --sidebar-ink: #f8f8f8;
  --sidebar-muted: #cdcdcb;
  --sidebar-glow: rgba(229, 101, 21, 0.4);
  --sidebar-hover: rgba(248, 248, 248, 0.1);
  --sidebar-active: rgba(229, 101, 21, 0.42);
  --brand-a: #fba45c;
  --brand-b: #e56515;
  --brand-c: #919599;
  --danger: #c94040;
  --danger-soft: #fce8e8;
  --ok: #4a8a5a;
  --ok-bg: #e6f2e9;
  --err-bg: #fce8e8;
  --info: #919599;
  --info-bg: #ececeb;
  --warn: #e56515;
  --warn-bg: #fff0e4;
  --shadow: 0 12px 32px rgba(61, 64, 67, 0.12);
  --shell-glow-a: rgba(251, 164, 92, 0.3);
  --shell-glow-b: rgba(229, 101, 21, 0.08);
  --login-a: rgba(251, 164, 92, 0.4);
  --login-b: rgba(229, 101, 21, 0.35);
  --login-grad: linear-gradient(165deg, #e56515 0%, #5c6064 48%, #3d4043 100%);
}

html.dark[data-palette="clockwork"] {
  --bg: #242628;
  --bg-elevated: #2e3134;
  --surface: #3a3e42;
  --surface-2: #4a4e52;
  --ink: #f8f8f8;
  --ink-soft: #cdcdcb;
  --muted: #a8abae;
  --border: #5c6064;
  --border-soft: #4a4e52;
  --accent: #fba45c;
  --accent-hover: #ffb878;
  --accent-soft: rgba(251, 164, 92, 0.2);
  --accent-text: #fba45c;
  --sidebar-bg: #2e3134;
  --sidebar-mid: #3a3e42;
  --sidebar-deep: #1e2022;
  --sidebar-ink: #f8f8f8;
  --sidebar-muted: #cdcdcb;
  --sidebar-glow: rgba(229, 101, 21, 0.3);
  --sidebar-hover: rgba(248, 248, 248, 0.08);
  --sidebar-active: rgba(229, 101, 21, 0.4);
  --brand-a: #fba45c;
  --brand-b: #e56515;
  --brand-c: #919599;
  --danger: #f09090;
  --danger-soft: #3a2828;
  --ok: #8ec99a;
  --ok-bg: #243428;
  --err-bg: #3a2828;
  --info: #b8bbbe;
  --info-bg: #323538;
  --warn: #fba45c;
  --warn-bg: #3a2e20;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  --shell-glow-a: rgba(229, 101, 21, 0.15);
  --shell-glow-b: rgba(36, 38, 40, 0.5);
  --login-grad: linear-gradient(165deg, #242628 0%, #3a3e42 48%, #e56515 140%);
  color-scheme: dark;
}

/* —— Tropical jade sunrise —— #FCA47C #F9D779 #23CED9 #A1CCA6 #097C87 */
html[data-palette="tropical"] {
  --bg: #eef8f7;
  --bg-elevated: #f6fcfb;
  --surface: #ffffff;
  --surface-2: #d5efe8;
  --ink: #0a4a52;
  --ink-soft: #097c87;
  --muted: #4a8a90;
  --border: #b5d9d6;
  --border-soft: #d8ebe8;
  --accent: #097c87;
  --accent-hover: #066068;
  --accent-soft: rgba(9, 124, 135, 0.14);
  --accent-text: #066068;
  --sidebar-bg: #097c87;
  --sidebar-mid: #0a8f9b;
  --sidebar-deep: #065a63;
  --sidebar-ink: #eef8f7;
  --sidebar-muted: #a1cca6;
  --sidebar-glow: rgba(35, 206, 217, 0.45);
  --sidebar-hover: rgba(255, 255, 255, 0.12);
  --sidebar-active: rgba(35, 206, 217, 0.4);
  --brand-a: #23ced9;
  --brand-b: #097c87;
  --brand-c: #fca47c;
  --danger: #d45a4a;
  --danger-soft: #fce8e4;
  --ok: #3d9a6a;
  --ok-bg: #e4f5ea;
  --err-bg: #fce8e4;
  --info: #23ced9;
  --info-bg: #dff7f9;
  --warn: #fca47c;
  --warn-bg: #fff0e8;
  --shadow: 0 12px 32px rgba(9, 124, 135, 0.14);
  --shell-glow-a: rgba(35, 206, 217, 0.28);
  --shell-glow-b: rgba(252, 164, 124, 0.15);
  --login-a: rgba(35, 206, 217, 0.4);
  --login-b: rgba(252, 164, 124, 0.3);
  --login-grad: linear-gradient(165deg, #097c87 0%, #066068 45%, #0a4a52 100%);
}

html.dark[data-palette="tropical"] {
  --bg: #0a2e32;
  --bg-elevated: #0e3c42;
  --surface: #124a52;
  --surface-2: #176068;
  --ink: #e8f7f6;
  --ink-soft: #b8e4e2;
  --muted: #7eb8bc;
  --border: #1e6a72;
  --border-soft: #165860;
  --accent: #23ced9;
  --accent-hover: #5adce4;
  --accent-soft: rgba(35, 206, 217, 0.2);
  --accent-text: #a1e8ee;
  --sidebar-bg: #065a63;
  --sidebar-mid: #097c87;
  --sidebar-deep: #043f46;
  --sidebar-ink: #e8f7f6;
  --sidebar-muted: #a1cca6;
  --sidebar-glow: rgba(35, 206, 217, 0.3);
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active: rgba(35, 206, 217, 0.38);
  --brand-a: #23ced9;
  --brand-b: #097c87;
  --brand-c: #fca47c;
  --danger: #f0a090;
  --danger-soft: #3a2824;
  --ok: #8ecfaa;
  --ok-bg: #1a3a2a;
  --err-bg: #3a2824;
  --info: #7edce4;
  --info-bg: #143a40;
  --warn: #fca47c;
  --warn-bg: #3a2e24;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  --shell-glow-a: rgba(35, 206, 217, 0.12);
  --shell-glow-b: rgba(9, 124, 135, 0.25);
  --login-grad: linear-gradient(165deg, #0a2e32 0%, #065a63 50%, #097c87 100%);
  color-scheme: dark;
}

/* —— Turquoise amber autumn —— #304C64 #26788E #A4CCD4 #E2480C #631B08 */
html[data-palette="turquoise-amber"] {
  --bg: #eef4f6;
  --bg-elevated: #f6fafb;
  --surface: #ffffff;
  --surface-2: #a4ccd4;
  --ink: #304c64;
  --ink-soft: #26788e;
  --muted: #5a7a8a;
  --border: #b5cfd6;
  --border-soft: #d6e6ea;
  --accent: #26788e;
  --accent-hover: #1c5c6e;
  --accent-soft: rgba(38, 120, 142, 0.14);
  --accent-text: #1c5c6e;
  --sidebar-bg: #304c64;
  --sidebar-mid: #3a5c78;
  --sidebar-deep: #243a4c;
  --sidebar-ink: #eef4f6;
  --sidebar-muted: #a4ccd4;
  --sidebar-glow: rgba(226, 72, 12, 0.35);
  --sidebar-hover: rgba(164, 204, 212, 0.12);
  --sidebar-active: rgba(38, 120, 142, 0.45);
  --brand-a: #a4ccd4;
  --brand-b: #26788e;
  --brand-c: #e2480c;
  --danger: #e2480c;
  --danger-soft: #fce6dc;
  --ok: #2a8a6a;
  --ok-bg: #e2f2ec;
  --err-bg: #fce6dc;
  --info: #26788e;
  --info-bg: #dff0f4;
  --warn: #e2480c;
  --warn-bg: #fceee6;
  --shadow: 0 12px 32px rgba(48, 76, 100, 0.14);
  --shell-glow-a: rgba(164, 204, 212, 0.5);
  --shell-glow-b: rgba(226, 72, 12, 0.08);
  --login-a: rgba(164, 204, 212, 0.4);
  --login-b: rgba(226, 72, 12, 0.25);
  --login-grad: linear-gradient(165deg, #304c64 0%, #26788e 45%, #631b08 120%);
}

html.dark[data-palette="turquoise-amber"] {
  --bg: #1a2834;
  --bg-elevated: #223344;
  --surface: #304c64;
  --surface-2: #3a5c78;
  --ink: #e8f2f4;
  --ink-soft: #a4ccd4;
  --muted: #7aa0b0;
  --border: #3a5c78;
  --border-soft: #2a4054;
  --accent: #4aa8c0;
  --accent-hover: #6ec0d4;
  --accent-soft: rgba(74, 168, 192, 0.2);
  --accent-text: #a4ccd4;
  --sidebar-bg: #243a4c;
  --sidebar-mid: #304c64;
  --sidebar-deep: #162430;
  --sidebar-ink: #e8f2f4;
  --sidebar-muted: #a4ccd4;
  --sidebar-glow: rgba(226, 72, 12, 0.28);
  --sidebar-hover: rgba(164, 204, 212, 0.1);
  --sidebar-active: rgba(38, 120, 142, 0.42);
  --brand-a: #a4ccd4;
  --brand-b: #4aa8c0;
  --brand-c: #e2480c;
  --danger: #ff7a4a;
  --danger-soft: #3a2418;
  --ok: #6ec8a8;
  --ok-bg: #1a332c;
  --err-bg: #3a2418;
  --info: #7ec8d8;
  --info-bg: #1e3040;
  --warn: #ff8a50;
  --warn-bg: #3a2418;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  --shell-glow-a: rgba(38, 120, 142, 0.15);
  --shell-glow-b: rgba(99, 27, 8, 0.2);
  --login-grad: linear-gradient(165deg, #1a2834 0%, #304c64 50%, #631b08 130%);
  color-scheme: dark;
}

/* —— Moon dust —— #D3D3FF #CEB5FF #8EC1DE #80A8FF */
html[data-palette="moon-dust"] {
  --bg: #f3f3ff;
  --bg-elevated: #fafaff;
  --surface: #ffffff;
  --surface-2: #d3d3ff;
  --ink: #3a4568;
  --ink-soft: #4e5c88;
  --muted: #6e7aa0;
  --border: #c5c8e8;
  --border-soft: #e0e2f5;
  --accent: #80a8ff;
  --accent-hover: #5c8af0;
  --accent-soft: rgba(128, 168, 255, 0.18);
  --accent-text: #3d5fb8;
  --sidebar-bg: #4a5580;
  --sidebar-mid: #5a6690;
  --sidebar-deep: #3a4468;
  --sidebar-ink: #f3f3ff;
  --sidebar-muted: #ceb5ff;
  --sidebar-glow: rgba(206, 181, 255, 0.4);
  --sidebar-hover: rgba(255, 255, 255, 0.12);
  --sidebar-active: rgba(128, 168, 255, 0.4);
  --brand-a: #d3d3ff;
  --brand-b: #80a8ff;
  --brand-c: #ceb5ff;
  --danger: #d45a8a;
  --danger-soft: #fce8f0;
  --ok: #5a9a8a;
  --ok-bg: #e4f4f0;
  --err-bg: #fce8f0;
  --info: #8ec1de;
  --info-bg: #e4f2f8;
  --warn: #ceb5ff;
  --warn-bg: #f4ecff;
  --shadow: 0 12px 32px rgba(58, 69, 104, 0.12);
  --shell-glow-a: rgba(211, 211, 255, 0.6);
  --shell-glow-b: rgba(206, 181, 255, 0.2);
  --login-a: rgba(211, 211, 255, 0.5);
  --login-b: rgba(128, 168, 255, 0.35);
  --login-grad: linear-gradient(165deg, #80a8ff 0%, #4a5580 50%, #3a4568 100%);
}

html.dark[data-palette="moon-dust"] {
  --bg: #1e2438;
  --bg-elevated: #282f48;
  --surface: #343c5c;
  --surface-2: #444e70;
  --ink: #eeeefe;
  --ink-soft: #d3d3ff;
  --muted: #a0a8c8;
  --border: #4a5580;
  --border-soft: #3a4468;
  --accent: #80a8ff;
  --accent-hover: #a0c0ff;
  --accent-soft: rgba(128, 168, 255, 0.22);
  --accent-text: #d3d3ff;
  --sidebar-bg: #3a4468;
  --sidebar-mid: #4a5580;
  --sidebar-deep: #2a3250;
  --sidebar-ink: #eeeefe;
  --sidebar-muted: #ceb5ff;
  --sidebar-glow: rgba(206, 181, 255, 0.3);
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active: rgba(128, 168, 255, 0.38);
  --brand-a: #d3d3ff;
  --brand-b: #80a8ff;
  --brand-c: #ceb5ff;
  --danger: #f0a0c0;
  --danger-soft: #3a2430;
  --ok: #8ec8b8;
  --ok-bg: #1e3330;
  --err-bg: #3a2430;
  --info: #8ec1de;
  --info-bg: #243040;
  --warn: #ceb5ff;
  --warn-bg: #302848;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  --shell-glow-a: rgba(128, 168, 255, 0.12);
  --shell-glow-b: rgba(206, 181, 255, 0.1);
  --login-grad: linear-gradient(165deg, #1e2438 0%, #3a4468 50%, #4a5580 100%);
  color-scheme: dark;
}

/* —— Fireside —— #E76814 #D8D4BC #891A10 #DC8236 #B8210F #714236 */
html[data-palette="fireside"] {
  --bg: #f5f3ea;
  --bg-elevated: #faf8f2;
  --surface: #ffffff;
  --surface-2: #d8d4bc;
  --ink: #714236;
  --ink-soft: #891a10;
  --muted: #8a6a5a;
  --border: #cfc9ae;
  --border-soft: #e5e1cf;
  --accent: #e76814;
  --accent-hover: #b8210f;
  --accent-soft: rgba(231, 104, 20, 0.14);
  --accent-text: #891a10;
  --sidebar-bg: #891a10;
  --sidebar-mid: #a02014;
  --sidebar-deep: #5c120a;
  --sidebar-ink: #f5f3ea;
  --sidebar-muted: #d8d4bc;
  --sidebar-glow: rgba(231, 104, 20, 0.4);
  --sidebar-hover: rgba(216, 212, 188, 0.12);
  --sidebar-active: rgba(231, 104, 20, 0.42);
  --brand-a: #dc8236;
  --brand-b: #e76814;
  --brand-c: #891a10;
  --danger: #b8210f;
  --danger-soft: #fce8e4;
  --ok: #6a7a4a;
  --ok-bg: #eaf0e0;
  --err-bg: #fce8e4;
  --info: #714236;
  --info-bg: #ebe6dc;
  --warn: #dc8236;
  --warn-bg: #fff0e0;
  --shadow: 0 12px 32px rgba(113, 66, 54, 0.14);
  --shell-glow-a: rgba(216, 212, 188, 0.55);
  --shell-glow-b: rgba(231, 104, 20, 0.1);
  --login-a: rgba(220, 130, 54, 0.35);
  --login-b: rgba(231, 104, 20, 0.3);
  --login-grad: linear-gradient(165deg, #e76814 0%, #891a10 48%, #714236 100%);
}

html.dark[data-palette="fireside"] {
  --bg: #2a1814;
  --bg-elevated: #3a221c;
  --surface: #4a2e26;
  --surface-2: #5c3a30;
  --ink: #f5f3ea;
  --ink-soft: #d8d4bc;
  --muted: #c4a090;
  --border: #6a4238;
  --border-soft: #5c3a30;
  --accent: #e76814;
  --accent-hover: #f08a40;
  --accent-soft: rgba(231, 104, 20, 0.22);
  --accent-text: #f0b070;
  --sidebar-bg: #5c120a;
  --sidebar-mid: #891a10;
  --sidebar-deep: #3a0c08;
  --sidebar-ink: #f5f3ea;
  --sidebar-muted: #d8d4bc;
  --sidebar-glow: rgba(231, 104, 20, 0.3);
  --sidebar-hover: rgba(216, 212, 188, 0.1);
  --sidebar-active: rgba(231, 104, 20, 0.4);
  --brand-a: #dc8236;
  --brand-b: #e76814;
  --brand-c: #b8210f;
  --danger: #f07060;
  --danger-soft: #3a2018;
  --ok: #a0b878;
  --ok-bg: #2a3220;
  --err-bg: #3a2018;
  --info: #d8d4bc;
  --info-bg: #3a2a22;
  --warn: #dc8236;
  --warn-bg: #3a2a18;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  --shell-glow-a: rgba(231, 104, 20, 0.15);
  --shell-glow-b: rgba(137, 26, 16, 0.25);
  --login-grad: linear-gradient(165deg, #2a1814 0%, #891a10 50%, #714236 100%);
  color-scheme: dark;
}

html, body {
  background: var(--bg);
  color: var(--ink);
}

[x-cloak] { display: none !important; }

/* Layout shell */
.app-shell {
  min-height: 100dvh;
  display: flex;
  background:
    radial-gradient(1000px 520px at 100% -8%, var(--shell-glow-a), transparent 55%),
    radial-gradient(780px 420px at -8% 30%, var(--shell-glow-b), transparent 50%),
    var(--bg);
  color: var(--ink);
}
.app-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: color-mix(in srgb, var(--ink) 45%, transparent);
}
@media (min-width: 768px) {
  .app-backdrop { display: none !important; }
}
.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(800px 380px at 0% 0%, var(--sidebar-glow), transparent 55%),
    linear-gradient(180deg, var(--sidebar-mid) 0%, var(--sidebar-bg) 48%, var(--sidebar-deep) 100%);
  color: var(--sidebar-ink);
  border-right: 1px solid color-mix(in srgb, var(--sidebar-muted) 20%, transparent);
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  transform: translateX(-105%);
  transition: transform 0.22s ease;
}
html.dark .app-sidebar {
  background:
    radial-gradient(800px 380px at 0% 0%, var(--sidebar-glow), transparent 55%),
    linear-gradient(180deg, var(--sidebar-mid) 0%, var(--sidebar-bg) 55%, var(--sidebar-deep) 100%);
}
.app-sidebar.is-open {
  transform: translateX(0);
  box-shadow: var(--shadow);
}
@media (min-width: 768px) {
  .app-sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    transform: none;
  }
  .app-shell.sidebar-collapsed .app-sidebar {
    display: none;
  }
}
.nav-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.5rem;
  border: 1px solid color-mix(in srgb, var(--sidebar-ink) 22%, transparent);
  background: transparent;
  color: var(--sidebar-ink);
  cursor: pointer;
  flex-shrink: 0;
}
.nav-close-btn:hover { background: var(--sidebar-hover); }
.nav-close-btn svg { width: 1.1rem; height: 1.1rem; }
.app-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  border-bottom: 1px solid color-mix(in srgb, var(--sidebar-ink) 10%, transparent);
}
.app-brand-mark {
  height: 2.35rem;
  width: 2.35rem;
  border-radius: 0.7rem;
  background: linear-gradient(145deg, var(--brand-a) 0%, var(--brand-b) 55%, var(--brand-c) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 40%, transparent);
}
.app-brand-title { font-weight: 650; line-height: 1.15; }
.app-brand-sub { font-size: 0.72rem; color: var(--sidebar-muted); margin-top: 0.1rem; }
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1.1rem;
  padding-top: max(0.7rem, env(safe-area-inset-top));
  padding-left: max(1.1rem, env(safe-area-inset-left));
  padding-right: max(1.1rem, env(safe-area-inset-right));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--border-soft);
  backdrop-filter: blur(8px);
}
.app-topbar-title {
  font-weight: 650;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-content {
  padding: 1.15rem 1rem 2rem;
  padding-bottom: max(2rem, env(safe-area-inset-bottom));
  width: 100%;
  max-width: 74rem;
  margin: 0 auto;
  line-height: 1.45;
}
@media (min-width: 768px) {
  .app-content { padding: 1.75rem 2.25rem 2.75rem; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .app-content { max-width: none; }
}

/* Ritmo visual: menos amontonamiento */
.app-content h1 {
  font-size: clamp(1.45rem, 2.2vw, 1.75rem);
  line-height: 1.25;
  margin-bottom: 0.35rem;
}
.app-content h1 + p {
  margin-bottom: var(--space-4) !important;
  max-width: 42rem;
  line-height: 1.5;
}
.app-content h2,
.app-content h3 {
  line-height: 1.35;
  margin-bottom: 0.55rem;
}
.app-content .rounded-xl.border,
.app-content .card,
.app-content .success-panel {
  padding: 1.35rem 1.45rem !important;
  border-radius: var(--radius) !important;
}
.app-content .rounded-lg.border,
.app-content .metric-compact {
  padding: 0.95rem 1.1rem !important;
}
.app-content .space-y-2 > :not([hidden]) ~ :not([hidden]) { margin-top: 0.75rem !important; }
.app-content .space-y-3 > :not([hidden]) ~ :not([hidden]) { margin-top: 1.05rem !important; }
.app-content .space-y-4 > :not([hidden]) ~ :not([hidden]) { margin-top: 1.4rem !important; }
.app-content .space-y-5 > :not([hidden]) ~ :not([hidden]) { margin-top: 1.65rem !important; }
.app-content .gap-2 { gap: 0.75rem !important; }
.app-content .gap-3 { gap: 1.05rem !important; }
.app-content .gap-4 { gap: 1.35rem !important; }
.app-content .gap-6 { gap: 1.75rem !important; }
.app-content .mb-2 { margin-bottom: 0.7rem !important; }
.app-content .mb-3 { margin-bottom: 1rem !important; }
.app-content .mb-4 { margin-bottom: 1.35rem !important; }
.app-content .mb-6 { margin-bottom: 1.85rem !important; }
.app-content .mb-8 { margin-bottom: 2.25rem !important; }
.app-content .mt-1 { margin-top: 0.4rem !important; }
.app-content .mt-2 { margin-top: 0.65rem !important; }
.app-content .mt-3 { margin-top: 0.95rem !important; }
.app-content .mt-4 { margin-top: 1.25rem !important; }
.app-content label.text-sm:not(.flex),
.app-content label.block:not(.flex) {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.app-content label.text-sm:not(.flex) .mt-1,
.app-content label.block:not(.flex) .mt-1 {
  margin-top: 0 !important;
}
.app-content table th,
.app-content table td {
  padding-top: 0.75rem !important;
  padding-bottom: 0.75rem !important;
}
.app-content thead th {
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 0.55rem;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--surface-2); }
.btn-icon svg { width: 1.15rem; height: 1.15rem; }

/* Nav */
.nav-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 0.65rem 0.55rem;
  font-size: 0.875rem;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  color: var(--sidebar-ink);
  text-decoration: none;
  opacity: 0.92;
}
.nav-link:hover { background: var(--sidebar-hover); opacity: 1; }
.nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 650;
  opacity: 1;
}
.nav-ico {
  display: inline-flex;
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  opacity: 0.9;
}
.nav-ico svg {
  width: 100%;
  height: 100%;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.nav-group {
  margin-top: 0.45rem;
  padding: 0.15rem;
  border-radius: 0.65rem;
}
.nav-group.is-open {
  background: color-mix(in srgb, var(--sidebar-ink) 6%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--sidebar-muted) 22%, transparent);
}
.nav-group-title {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.7rem;
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sidebar-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: 0.5rem;
}
.nav-group-title:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-ink);
}
.nav-group.is-open > .nav-group-title {
  color: var(--sidebar-ink);
  background: color-mix(in srgb, var(--sidebar-active) 55%, transparent);
}
.nav-group.is-open > .nav-group-title:hover {
  background: color-mix(in srgb, var(--sidebar-active) 72%, transparent);
}
.nav-group-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}
.nav-group-title .nav-ico {
  opacity: 0.95;
  width: 1.05rem;
  height: 1.05rem;
}
.nav-chevron {
  width: 0.45rem;
  height: 0.45rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  opacity: 0.75;
  flex-shrink: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
  margin-right: 0.15rem;
}
.nav-group.is-open > .nav-group-title .nav-chevron {
  transform: rotate(45deg);
  opacity: 1;
}
.nav-group-items {
  margin: 0.2rem 0.35rem 0.35rem 0.7rem;
  padding: 0.15rem 0 0.2rem 0.55rem;
  border-left: 2px solid color-mix(in srgb, var(--sidebar-muted) 35%, transparent);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.nav-group-items .nav-link {
  font-size: 0.84rem;
  letter-spacing: normal;
  text-transform: none;
  font-weight: 500;
  padding: 0.42rem 0.65rem;
  opacity: 0.86;
  color: color-mix(in srgb, var(--sidebar-ink) 88%, var(--sidebar-muted));
}
.nav-group-items .nav-link:hover {
  opacity: 1;
  color: var(--sidebar-ink);
}
.nav-group-items .nav-link.active {
  opacity: 1;
  color: #fff;
}
.nav-group-items .nav-ico {
  width: 1rem;
  height: 1rem;
  opacity: 0.75;
}
.nav-group-items .nav-link.active .nav-ico {
  opacity: 1;
}
.nav-footer {
  margin-top: auto;
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.nav-footer button,
.nav-footer .nav-footer-btn {
  width: 100%;
  text-align: left;
  font-size: 0.85rem;
  padding: 0.55rem 0.75rem;
  border-radius: 0.5rem;
  border: none;
  background: transparent;
  color: var(--sidebar-ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}
.nav-footer button:hover,
.nav-footer .nav-footer-btn:hover { background: var(--sidebar-hover); }
.nav-footer .nav-logout { color: #e8a0aa; }

.card {
  border-radius: var(--radius);
  border: 1px solid var(--border-soft);
  background: var(--surface);
  padding: 1.25rem 1.4rem;
  box-shadow: 0 1px 0 rgba(255,255,255,0.4) inset;
}
.card .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.card .value {
  margin-top: 0.45rem;
  font-size: 1.45rem;
  font-weight: 650;
  color: var(--ink);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-radius: 0.55rem;
  padding: 0.65rem 1.15rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* SGM Matafuegos: botón primary con degradé safety orange */
html[data-palette="sgm-matafuegos"] .btn-primary {
  background: linear-gradient(135deg, #fb923c, #ea580c);
  box-shadow: 0 2px 8px rgba(234, 88, 12, 0.25);
  color: #fff7ed;
}
html[data-palette="sgm-matafuegos"] .btn-primary:hover {
  background: linear-gradient(135deg, #f97316, #c2410c);
}
html.dark[data-palette="sgm-matafuegos"] .btn-primary {
  background: linear-gradient(135deg, #fb923c, #ea580c);
  color: #1c1917;
}
html.dark[data-palette="sgm-matafuegos"] .btn-primary:hover {
  background: linear-gradient(135deg, #fdba74, #fb923c);
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.45rem 0.85rem;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--surface);
}
.btn-ghost:hover { background: var(--surface-2); }

.input {
  border: 1px solid var(--border);
  border-radius: 0.55rem;
  padding: 0.6rem 0.85rem;
  background: var(--surface);
  color: var(--ink);
  min-height: 2.55rem;
}
.input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-color: var(--accent);
}
.badge {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  font-weight: 650;
  white-space: nowrap;
}
.badge-ok {
  background: color-mix(in srgb, #16a34a 16%, var(--surface));
  color: #15803d;
}
.badge-muted {
  background: var(--surface-2);
  color: var(--ink-soft);
}
.badge-factura {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  color: var(--accent-text);
}
.badge-nc {
  background: color-mix(in srgb, #e11d48 14%, var(--surface));
  color: #be123c;
}
.badge-nd {
  background: color-mix(in srgb, #7c3aed 14%, var(--surface));
  color: #6d28d9;
}
.dark .badge-ok { color: #86efac; background: color-mix(in srgb, #16a34a 22%, transparent); }
.dark .badge-nc { color: #fda4af; background: color-mix(in srgb, #e11d48 22%, transparent); }
.dark .badge-nd { color: #c4b5fd; background: color-mix(in srgb, #7c3aed 22%, transparent); }
.comprobantes-table tbody tr:nth-child(even) {
  background: color-mix(in srgb, var(--surface-2) 35%, transparent);
}
.comprobantes-grupo {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
  overflow: hidden;
}
.comprobantes-grupo-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
  padding: 0.95rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 55%, var(--surface));
}
.comprobantes-grupo--factura {
  box-shadow: inset 4px 0 0 color-mix(in srgb, var(--accent) 75%, transparent);
}
.comprobantes-grupo--nc {
  box-shadow: inset 4px 0 0 color-mix(in srgb, #e11d48 70%, transparent);
}
.comprobantes-grupo--nd {
  box-shadow: inset 4px 0 0 color-mix(in srgb, #7c3aed 70%, transparent);
}
.comprobantes-grupo-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.comprobantes-grupo-meta {
  margin: 0.2rem 0 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
}
.comprobantes-grupo-total {
  font-size: 1.15rem;
  font-weight: 650;
  color: var(--ink);
}
.comprobantes-grupo .comprobantes-table thead {
  background: transparent;
}
.comprobantes-grupo .comprobantes-table th {
  font-weight: 600;
}
.tabs {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 1.35rem;
}
.tab {
  padding: 0.55rem 1rem;
  border-radius: 0.55rem;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--ink);
}
.tab.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 650;
}

.cta-row {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}
@media (min-width: 768px) {
  .cta-row { grid-template-columns: repeat(3, 1fr); }
}
.cta-action {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.45rem;
  padding: 1.35rem 1.4rem;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 650;
  font-size: 1.05rem;
  border: none;
  line-height: 1.3;
}
.cta-action:hover { background: var(--accent-hover); }
.cta-action span {
  font-size: 0.82rem;
  font-weight: 400;
  opacity: 0.92;
}
.cta-action.cta-secondary {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
}
.cta-action.cta-secondary:hover { background: var(--surface-2); }

.metric-compact {
  padding: 1rem 1.15rem;
  border-radius: 0.7rem;
  border: 1px solid var(--border-soft);
  background: var(--surface);
}
.metric-compact .label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.metric-compact .value {
  margin-top: 0.35rem;
  font-size: 1.2rem;
  font-weight: 650;
}

.toast-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-bottom: 1px solid transparent;
}
.toast-success { background: var(--ok-bg); color: var(--ok); }
.toast-error { background: var(--err-bg); color: var(--danger); }
.toast-info { background: var(--info-bg); color: var(--info); }
.toast-dismiss {
  background: transparent;
  border: none;
  cursor: pointer;
  opacity: 0.7;
  font-size: 1rem;
  line-height: 1;
  color: inherit;
}

.app-modal-root {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
}
.app-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 28, 36, 0.5);
}
.app-modal {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 28rem;
  max-height: min(90dvh, 44rem);
  display: flex;
  flex-direction: column;
  border-radius: 0.85rem;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.app-modal.app-modal-lg { max-width: min(48rem, 96vw); }
.app-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 1.15rem;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.app-modal-title {
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1.3;
}
.app-modal-subtitle {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--muted);
}
.app-modal-body {
  padding: 1.25rem 1.35rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.app-modal-message {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink-soft);
}
.app-modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.65rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.app-modal-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  color: inherit;
  line-height: 1;
}
.app-modal-close:hover { background: var(--accent-soft); }

.typeahead-wrap { position: relative; }
.typeahead-list {
  position: absolute;
  z-index: 50;
  left: 0;
  right: 0;
  margin: 0.15rem 0 0;
  padding: 0.25rem 0;
  list-style: none;
  max-height: 14rem;
  overflow-y: auto;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.typeahead-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.85rem;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  color: inherit;
}
.typeahead-item:hover { background: var(--accent-soft); }

.cliente-picker-list {
  max-height: min(52dvh, 26rem);
  overflow-y: auto;
  border: 1px solid var(--border-soft);
  border-radius: 0.7rem;
  background: var(--surface);
}
.cliente-picker-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  text-align: left;
  padding: 0.85rem 1rem;
  border: none;
  border-bottom: 1px solid var(--border-soft);
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.cliente-picker-item:last-child { border-bottom: none; }
.cliente-picker-item:hover { background: var(--accent-soft); }
.cliente-picker-item.is-selected {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.success-panel {
  padding: 1.35rem 1.5rem;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--ok) 35%, var(--border));
  background: var(--ok-bg);
  color: var(--ok);
}

.cat-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 0.25rem;
}
.cat-chip {
  padding: 0.55rem 0.95rem;
  border-radius: 0.55rem;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--ink);
}
.cat-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 650;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
@media (min-width: 640px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); gap: 0.9rem; }
}
@media (min-width: 1024px) {
  .product-grid { grid-template-columns: repeat(4, 1fr); gap: 1rem; }
}
.product-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.35rem;
  text-align: left;
  padding: 1rem 1.05rem;
  min-height: 4.75rem;
  border-radius: 0.7rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
  color: inherit;
}
.product-tile:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.product-tile:disabled { opacity: 0.5; cursor: not-allowed; }
.product-tile-name {
  font-weight: 650;
  font-size: 0.92rem;
  line-height: 1.3;
}
.product-tile-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
  width: 100%;
}
.product-tile-code {
  font-size: 0.7rem;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}
.product-tile-price {
  font-size: 0.8rem;
  font-weight: 650;
  color: var(--accent-text);
  margin-left: auto;
}

.cart-sticky {
  position: sticky;
  bottom: 0.85rem;
  z-index: 30;
  margin-top: 1.5rem;
  pointer-events: none;
}
.cart-sticky-inner {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.9rem 1.15rem;
  border-radius: 0.95rem;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  box-shadow: var(--shadow);
}
.cart-sticky .btn-ghost {
  color: var(--sidebar-ink);
  border-color: rgba(255,255,255,0.2);
  background: transparent;
}

.product-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-soft);
  border-radius: 0.75rem;
  overflow: hidden;
  max-height: 24rem;
  overflow-y: auto;
  background: var(--surface);
}
.product-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr auto 1.75rem;
  gap: 0.65rem;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 0.75rem 0.9rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-soft);
  cursor: pointer;
  font-size: 0.875rem;
  color: inherit;
}
.product-row:last-child { border-bottom: none; }
.product-row:hover { background: var(--surface-2); }
.product-row:disabled { opacity: 0.5; cursor: not-allowed; }
.product-row-code {
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  color: var(--muted);
}
.product-row-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.product-row-price {
  font-weight: 650;
  color: var(--accent-text);
  font-size: 0.8rem;
  white-space: nowrap;
}
.product-row-add {
  text-align: center;
  font-weight: 700;
  color: var(--accent);
}

/* Tablas más usables en móvil */
.overflow-x-auto {
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
@media (max-width: 767px) {
  .app-modal-root .app-modal {
    max-width: none;
  }
}
@media (max-width: 640px) {
  .btn-primary, .btn-ghost, .tab, .cat-chip {
    min-height: 2.5rem;
  }
  .input { font-size: 16px; } /* evita zoom iOS */
  .product-row {
    grid-template-columns: 4.25rem 1fr auto;
  }
  .product-row-add { display: none; }
}

.login-wrap {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background:
    radial-gradient(900px 480px at 10% -10%, var(--login-a), transparent 55%),
    radial-gradient(700px 400px at 95% 15%, var(--login-b), transparent 50%),
    var(--login-grad);
}
.login-card {
  width: 100%;
  max-width: 24rem;
  border-radius: 1.1rem;
  background: var(--surface);
  color: var(--ink);
  padding: 1.65rem;
  box-shadow: var(--shadow);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, var(--border));
}

/* Selector de paleta (popup) */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  gap: 0.75rem;
}
.palette-card {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.65rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.palette-card:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 18%, transparent);
}
.palette-card.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.palette-card-preview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.25rem;
  height: 2.6rem;
  border-radius: 0.45rem;
  overflow: hidden;
}
.palette-card-preview span {
  display: block;
  min-width: 0;
  height: 100%;
}
.palette-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.palette-card-name {
  font-size: 0.88rem;
  font-weight: 600;
}
.palette-card-check {
  font-size: 0.72rem;
  color: var(--accent-text);
  font-weight: 600;
  white-space: nowrap;
}

/* Compat: páginas con stone/teal de Tailwind → paleta pastel */
.text-stone-400,
.text-stone-500,
.text-stone-600,
.dark .dark\:text-stone-400,
.dark .dark\:text-stone-300 {
  color: var(--muted) !important;
}
.border-stone-100,
.border-stone-200,
.dark .dark\:border-stone-800 {
  border-color: var(--border-soft) !important;
}
.border-stone-300 {
  border-color: var(--border) !important;
}
.bg-white,
.dark .dark\:bg-stone-900 {
  background-color: var(--surface) !important;
}
.bg-stone-50,
.dark .dark\:bg-stone-950 {
  background-color: var(--surface-2) !important;
}
.bg-stone-200,
.dark .dark\:bg-stone-800 {
  background-color: var(--surface-2) !important;
}
.text-teal-700,
.dark .dark\:text-teal-300,
.text-teal-600 {
  color: var(--info) !important;
}
a.text-teal-700:hover,
a.dark\:text-teal-300:hover {
  color: var(--accent-text) !important;
}
.text-amber-700,
.dark .dark\:text-amber-300 {
  color: var(--warn) !important;
}
.text-red-600,
.text-red-700 {
  color: var(--danger) !important;
}
.text-green-700,
.text-emerald-700 {
  color: var(--ok) !important;
}
