@import url('https://fonts.googleapis.com/css2?family=VT323&family=Courier+Prime:ital,wght@0,400;0,700;1,400&display=swap');

:root {
    /* Paleta — crema cálida base, acentos por lista */
    --bg: #e8dfc8;
    --bg2: #f0e8d4;
    --bg3: #f8f0e0;
    --bg4: #fffaf0;
    --border-d: #8a7055;
    --border-l: #fff8ec;
    --title-bg: #5a3e8a;
    /* morado principal */
    --title-bg2: #3d2a66;
    /* morado oscuro */
    --title-txt: #f0e8ff;
    --text: #2a1a08;
    --text2: #5a4020;
    --text3: #9a8060;
    --accent: #c44820;
    --accent2: #e87040;
    --green: #3a7a28;
    --green2: #5a9a48;
    --selected: #5a3e8a;
    --sel-txt: #ffffff;
    --btn-face: #e8dfc8;
    --shadow: #00000035;
    --mono: 'Courier Prime', 'Courier New', monospace;
    --display: 'VT323', monospace;

    /* Lista colores */
    --c1: #5a3e8a;
    --c2: #c44820;
    --c3: #2a6070;
    --c4: #4a7a30;
    --c5: #8a4020;
    --c6: #2a508a;
    --c7: #7a3060;
    --c8: #3a6030;
    --c9: #5a5a00;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    /* --vh se calcula con JS para altura real en Samsung/Android */
}

body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: var(--mono);
    font-size: 17px;
    -webkit-font-smoothing: none;
}

/* ── Fondo con cuadrícula tipo imagen de referencia ── */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: linear-gradient(rgba(90, 62, 138, .06) 1px, transparent 1px),
        linear-gradient(90deg, rgba(90, 62, 138, .06) 1px, transparent 1px);
    background-size: 24px 24px;
    z-index: 0;
}

::-webkit-scrollbar {
    width: 14px;
}

::-webkit-scrollbar-track {
    background: var(--bg3);
    border-left: 1px solid var(--border-d);
}

::-webkit-scrollbar-thumb {
    background: var(--btn-face);
    border-top: 2px solid var(--border-l);
    border-left: 2px solid var(--border-l);
    border-right: 2px solid var(--border-d);
    border-bottom: 2px solid var(--border-d);
}

/* ── Desktop / Taskbar ── */

#desktop {
    width: 100%;
    /* Usar --vh calculado por JS; si no está disponible, usar 100% */
    height: calc(var(--vh, 1vh) * 100);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

#workspace {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-height: 0;
    z-index: 1;
}

#taskbar {
    height: 38px;
    background: var(--title-bg2);
    border-top: 2px solid rgba(255, 255, 255, .15);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 6px;
    flex-shrink: 0;
    z-index: 1000;
    position: relative;
}

#start-btn {
    height: 28px;
    padding: 0 12px;
    background: var(--title-bg);
    border: 2px solid rgba(255, 255, 255, .2);
    font-family: var(--mono);
    font-size: 16px;
    font-weight: 700;
    color: var(--title-txt);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    user-select: none;
    letter-spacing: .04em;
}

#start-btn:hover {
    background: rgba(255, 255, 255, .15);
}

#start-btn:active {
    background: rgba(0, 0, 0, .2);
}

.taskbar-sep {
    width: 1px;
    height: 24px;
    background: rgba(255, 255, 255, .2);
    margin: 0 2px;
}

#taskbar-windows {
    display: flex;
    gap: 3px;
    flex: 1;
    overflow: hidden;
}

.taskbar-btn {
    height: 28px;
    padding: 0 10px;
    min-width: 100px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: rgba(255, 255, 255, .1);
    font-family: var(--mono);
    font-size: 14px;
    color: rgba(255, 255, 255, .8);
    cursor: pointer;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, .15);
}

.taskbar-btn.active {
    background: var(--title-bg);
    color: #fff;
    border-color: rgba(255, 255, 255, .3);
}

#taskbar-clock {
    margin-left: auto;
    font-size: 16px;
    color: rgba(255, 255, 255, .7);
    padding: 0 10px;
    flex-shrink: 0;
    font-family: var(--display);
}

/* ── Start menu ── */
#start-menu {
    position: absolute;
    bottom: 40px;
    left: 0;
    background: var(--bg2);
    border: 2px solid var(--title-bg);
    min-width: 200px;
    z-index: 2000;
    box-shadow: 3px 3px 0 var(--shadow);
}

.start-menu-header {
    background: var(--title-bg);
    color: var(--title-txt);
    padding: 8px 14px;
    font-family: var(--display);
    font-size: 22px;
    letter-spacing: .04em;
}

.start-menu-item {
    padding: 7px 14px;
    font-size: 16px;
    cursor: pointer;
    color: var(--text);
    border-bottom: 1px solid rgba(0, 0, 0, .06);
}

.start-menu-item:hover {
    background: var(--title-bg);
    color: var(--title-txt);
}

.start-menu-sep {
    height: 1px;
    background: var(--border-d);
    margin: 2px 0;
}

/* ── Ventana genérica ── */
.window {
    position: absolute;
    background: var(--bg2);
    border: 2px solid var(--border-d);
    display: flex;
    flex-direction: column;
    box-shadow: 4px 4px 0 var(--shadow);
    z-index: 10;
    animation: winOpen .12s ease;
}

.window.active {
    z-index: 100;
}

.window.minimized {
    display: none !important;
}

@keyframes winOpen {
    from {
        opacity: 0;
        transform: scale(.97)
    }

    to {
        opacity: 1;
        transform: scale(1)
    }
}

.win-titlebar {
    height: 24px;
    background: var(--title-bg2);
    display: flex;
    align-items: center;
    padding: 0 6px;
    gap: 4px;
    flex-shrink: 0;
    user-select: none;
    cursor: move;
}

.window.active .win-titlebar {
    background: var(--title-bg);
}

.win-title-icon {
    font-size: 17px;
}

.win-title-text {
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 700;
    color: var(--title-txt);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    letter-spacing: .02em;
}

.win-btn {
    width: 16px;
    height: 16px;
    background: rgba(255, 255, 255, .2);
    border: 1px solid rgba(255, 255, 255, .3);
    font-size: 11px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-family: var(--mono);
    color: var(--title-txt);
    border-radius: 1px;
}

.win-btn:hover {
    background: rgba(255, 255, 255, .35);
}

.win-btn.close {
    background: rgba(196, 72, 32, .6);
}

.win-btn.close:hover {
    background: var(--accent);
}

.win-menubar {
    height: 24px;
    background: var(--bg3);
    border-bottom: 1px solid var(--border-d);
    display: flex;
    align-items: stretch;
    padding: 0 2px;
    flex-shrink: 0;
}

.win-menu-item {
    padding: 0 12px;
    display: flex;
    align-items: center;
    font-size: 14px;
    cursor: pointer;
    color: var(--text2);
    white-space: nowrap;
}

.win-menu-item:hover {
    background: var(--title-bg);
    color: #fff;
}

.win-body {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.win-status {
    height: 22px;
    background: var(--title-bg2);
    border-top: 1px solid rgba(0, 0, 0, .3);
    display: flex;
    align-items: center;
    padding: 0 4px;
    font-size: 13px;
    flex-shrink: 0;
    gap: 3px;
}

.win-status-panel {
    color: rgba(255, 255, 255, .75);
    border: 1px solid rgba(255, 255, 255, .15);
    padding: 1px 8px;
    height: 16px;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

/* ── Admin tabs — solo visibles si eres admin ── */
.win-menubar [data-admin-tab] {
    padding: 0 12px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    color: var(--text2);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.win-menubar [data-admin-tab]:hover {
    color: var(--title-bg);
}

.win-menubar [data-admin-tab].active {
    color: var(--title-bg);
    border-bottom-color: var(--title-bg);
    font-weight: 700;
}

/* ── Botones ── */
.btn {
    height: 26px;
    padding: 0 14px;
    background: var(--btn-face);
    border-top: 2px solid var(--border-l);
    border-left: 2px solid var(--border-l);
    border-right: 2px solid var(--border-d);
    border-bottom: 2px solid var(--border-d);
    font-family: var(--mono);
    font-size: 16px;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

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

.btn:active {
    border-top: 2px solid var(--border-d);
    border-left: 2px solid var(--border-d);
    border-right: 2px solid var(--border-l);
    border-bottom: 2px solid var(--border-l);
}

.btn:disabled {
    opacity: .4;
    cursor: default;
    pointer-events: none;
}

.btn.primary {
    background: var(--title-bg);
    color: #fff;
    border-color: rgba(255, 255, 255, .2) rgba(0, 0, 0, .3) rgba(0, 0, 0, .3) rgba(255, 255, 255, .2);
}

.btn.primary:hover {
    background: var(--title-bg2);
}

.btn.danger {
    color: var(--accent);
}

.btn.sm {
    height: 22px;
    padding: 0 8px;
    font-size: 14px;
}

.btn.full {
    width: 100%;
}

/* ── Inputs ── */
.input {
    height: 24px;
    padding: 2px 6px;
    background: var(--bg4);
    color: var(--text);
    border-top: 2px solid var(--border-d);
    border-left: 2px solid var(--border-d);
    border-right: 2px solid var(--border-l);
    border-bottom: 2px solid var(--border-l);
    font-family: var(--mono);
    font-size: 16px;
    outline: none;
    width: 100%;
}

.input:focus {
    outline: 2px solid var(--title-bg);
    outline-offset: -2px;
}

select.input {
    cursor: pointer;
}

label {
    font-size: 14px;
    color: var(--text2);
    display: block;
    margin-bottom: 3px;
}

fieldset {
    border: 2px solid var(--border-d);
    padding: 8px 10px;
}

legend {
    font-size: 14px;
    padding: 0 4px;
    color: var(--text2);
}

/* ── Login window ── */
.login-form {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.login-tabs {
    display: flex;
    margin-bottom: 4px;
    border-bottom: 2px solid var(--border-d);
}

.login-tab {
    padding: 4px 16px;
    font-size: 14px;
    cursor: pointer;
    color: var(--text3);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.login-tab.active {
    color: var(--title-bg);
    border-bottom-color: var(--title-bg);
    font-weight: 700;
}

.login-error {
    font-size: 14px;
    color: var(--accent);
    min-height: 16px;
}

/* ── App layout ──
   Cadena flex: win-body (flex col) → app-split (flex row) → sidebar + main
   min-height:0 es clave para que flex:1 funcione dentro de overflow:hidden  */
.app-split {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── Sidebar ── */
.app-sidebar {
    width: 240px;
    flex-shrink: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 2px solid var(--border-d);
    background: var(--bg2);
}

.app-sidebar-header {
    padding: 6px 10px;
    background: var(--title-bg2);
    border-bottom: 1px solid rgba(0, 0, 0, .2);
    display: flex;
    align-items: center;
    gap: 6px;
}

.app-sidebar-header span {
    font-size: 13px;
    flex: 1;
    font-weight: 700;
    color: rgba(255, 255, 255, .7);
    text-transform: uppercase;
    letter-spacing: .08em;
}

.app-sidebar-header .btn {
    background: rgba(255, 255, 255, .15);
    color: #fff;
    border-color: rgba(255, 255, 255, .2) rgba(0, 0, 0, .2) rgba(0, 0, 0, .2) rgba(255, 255, 255, .2);
    font-size: 14px;
    height: 22px;
}

.app-sidebar-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.sidebar-group-label {
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: rgba(255, 255, 255, .5);
    background: var(--title-bg2);
    border-bottom: 1px solid rgba(0, 0, 0, .15);
}

.list-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, .08);
    font-size: 16px;
    transition: background .1s;
    border-left: 3px solid transparent;
}

.list-entry:hover {
    background: var(--bg3);
}

.list-entry.selected {
    background: rgba(90, 62, 138, .12);
    border-left-color: var(--title-bg);
}

.list-entry-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.list-entry-info {
    flex: 1;
    overflow: hidden;
}

.list-entry-title {
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 16px;
}

.list-entry-sub {
    font-size: 13px;
    color: var(--text3);
    margin-top: 1px;
}

/* ── Main panel ── */
.app-main {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg3);
    background-image: linear-gradient(rgba(90, 62, 138, .04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(90, 62, 138, .04) 1px, transparent 1px);
    background-size: 20px 20px;
}

.app-main-header {
    padding: 8px 14px;
    background: var(--bg2);
    border-bottom: 2px solid var(--border-d);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    min-height: 42px;
    flex-wrap: wrap;
}

.app-main-title {
    font-family: var(--display);
    font-size: 31px;
    flex: 1;
    min-width: 80px;
}

.app-main-header .btn.sm {
    font-size: 14px;
}

.presence-bar {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 3px 14px;
    background: rgba(90, 62, 138, .06);
    border-bottom: 1px solid rgba(90, 62, 138, .1);
    flex-shrink: 0;
    font-size: 13px;
    color: var(--text3);
    min-height: 20px;
}

.presence-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.progress-wrap {
    padding: 4px 14px;
    background: rgba(0, 0, 0, .04);
    border-bottom: 1px solid rgba(0, 0, 0, .08);
    font-size: 13px;
    color: var(--text3);
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.progress-track {
    background: rgba(0, 0, 0, .1);
    height: 6px;
    flex: 1;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--title-bg);
    border-radius: 3px;
    transition: width .3s ease;
}

/* ── Items ── */
.item-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

.item-row {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px 14px;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    min-height: 36px;
    transition: background .1s;
}

.item-row-main {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.item-row:hover {
    background: rgba(255, 255, 255, .6);
}

.item-row.done .item-text {
    text-decoration: line-through;
    color: var(--text3);
}

.item-check {
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: var(--title-bg);
}

.item-qty {
    background: var(--title-bg);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 2px;
    white-space: nowrap;
    flex-shrink: 0;
}

.item-text {
    flex: 1;
    font-size: 16px;
    word-break: break-word;
}

.item-note {
    background: rgba(0, 0, 0, .07);
    font-size: 14px;
    color: var(--text2);
    padding: 4px 8px;
    border-radius: 3px;
    white-space: normal;
    word-break: break-word;
    line-height: 1.5;
    margin-top: 5px;
    margin-left: 24px;
    display: block;
}

.item-drag {
    cursor: grab;
    color: var(--text3);
    font-size: 17px;
    user-select: none;
    opacity: .4;
}

.item-actions {
    display: flex;
    gap: 3px;
    opacity: 0;
    transition: opacity .1s;
}

.item-row:hover .item-actions {
    opacity: 1;
}

/* ── Add row ── */
.add-item-row {
    display: flex;
    gap: 6px;
    padding: 8px 14px;
    border-top: 2px solid var(--border-d);
    flex-shrink: 0;
    background: var(--bg2);
    flex-wrap: wrap;
}

.add-item-text {
    flex: 1;
    min-width: 120px;
}

.add-item-qty {
    width: 60px;
}

/* ── Dialog ── */
.dialog-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
}

.dialog-overlay.hidden {
    display: none;
}

.dialog {
    background: var(--bg2);
    border: 2px solid var(--border-d);
    min-width: 280px;
    max-width: 480px;
    width: 90%;
    box-shadow: 6px 6px 0 var(--shadow);
}

.dialog-title {
    height: 24px;
    background: var(--title-bg);
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: 14px;
    font-weight: 700;
    color: var(--title-txt);
    font-family: var(--mono);
    gap: 6px;
    letter-spacing: .02em;
}

.dialog-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dialog-msg {
    font-size: 16px;
    line-height: 1.6;
}

.dialog-btns {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 0 16px 14px;
}

/* ── Share ── */
.user-pick-list {
    max-height: 150px;
    overflow-y: auto;
    border: 1px solid var(--border-d);
    margin-top: 2px;
    background: var(--bg4);
}

.user-pick-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    font-size: 16px;
}

.user-pick-row:hover {
    background: rgba(90, 62, 138, .08);
}

.user-pick-row.selected {
    background: var(--title-bg);
    color: #fff;
}

.share-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 0;
    border-bottom: 1px solid rgba(0, 0, 0, .06);
    font-size: 14px;
}

.share-row-name {
    flex: 1;
}

.share-row-perm {
    font-size: 13px;
    color: var(--text3);
}

/* ── Color swatches ── */
.color-swatches {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.swatch {
    width: 24px;
    height: 24px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 2px;
}

.swatch:hover {
    transform: scale(1.15);
}

.swatch.selected {
    border-color: var(--text);
    outline: 2px solid var(--text);
    outline-offset: 1px;
}

.badge {
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    padding: 1px 5px;
    border-radius: 2px;
}

/* ── Admin table ── */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th {
    background: var(--title-bg);
    color: #fff;
    padding: 4px 10px;
    text-align: left;
}

.admin-table td {
    padding: 4px 10px;
    border-bottom: 1px solid rgba(0, 0, 0, .08);
    vertical-align: middle;
}

.admin-table tr:hover td {
    background: rgba(90, 62, 138, .06);
}

/* ── Notif toasts ── */
#notif-root {
    position: absolute;
    bottom: 46px;
    right: 10px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
    align-items: flex-end;
}

.notif {
    background: var(--bg2);
    border: 2px solid var(--border-d);
    padding: 7px 14px;
    font-size: 14px;
    max-width: 290px;
    pointer-events: all;
    animation: winOpen .15s ease;
    box-shadow: 3px 3px 0 var(--shadow);
    border-left: 4px solid var(--border-d);
}

.notif.error {
    border-left-color: var(--accent);
}

.notif.success {
    border-left-color: var(--green);
}

.notif.warn {
    border-left-color: var(--accent2);
}

.notif.info {
    border-left-color: var(--title-bg);
}

/* ── System alert ── */
.sysalert {
    position: absolute;
    bottom: 50px;
    right: 12px;
    z-index: 9990;
    width: 300px;
    box-shadow: 4px 4px 0 var(--shadow);
    animation: winOpen .15s ease;
}

.sysalert .win-titlebar {
    cursor: default;
}

.sysalert-body {
    padding: 12px 14px;
    font-size: 14px;
    line-height: 1.7;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    background: var(--bg2);
}

.sysalert-icon {
    font-size: 31px;
    flex-shrink: 0;
}

.sysalert-btns {
    display: flex;
    gap: 6px;
    padding: 0 14px 12px;
    background: var(--bg2);
    justify-content: flex-end;
    border-top: 1px solid rgba(0, 0, 0, .08);
    padding-top: 8px;
}

/* ── Status bar main window ── */
#win-main .win-status {
    background: var(--title-bg2);
}

/* ── Lista sin acceso ── */
.no-access-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 12px;
    color: var(--text3);
    padding: 40px;
    text-align: center;
}

.no-access-screen .icon {
    font-size: 67px;
    opacity: .5;
}

/* ── Misc ── */
.row {
    display: flex;
    align-items: center;
    gap: 6px;
}

.col {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.flex1 {
    flex: 1;
}

.spacer {
    flex: 1;
}

.hidden {
    display: none !important;
}

.dim {
    color: var(--text3);
}

.small {
    font-size: 13px;
}

hr.win {
    border: none;
    border-top: 1px solid rgba(0, 0, 0, .1);
    margin: 4px 0;
}

/* ── Welcome screen ── */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 14px;
    color: var(--text3);
    padding: 40px;
    text-align: center;
}

.welcome-screen .icon {
    font-size: 77px;
    opacity: .3;
}

.welcome-screen p {
    font-size: 16px;
    line-height: 1.6;
}

/* ── Móvil ── */
@media (max-width: 700px) {
    #win-main {
        font-size: 16px;
    }

    .app-sidebar {
        width: 200px;
    }

    .app-main-title {
        font-size: 24px;
    }

    .win-menubar {
        overflow-x: auto;
    }

    .win-status {
        font-size: 12px;
    }

    .win-status-panel {
        padding: 1px 5px;
    }

    .item-row {
        padding: 5px 10px;
    }

    .add-item-row {
        padding: 6px 10px;
        gap: 4px;
    }

    .add-item-qty {
        width: 50px;
    }

    /* Taskbar más alta en móvil para ser tappable */
    #taskbar {
        height: 44px;
        padding: 0 8px;
    }

    #start-btn {
        height: 34px;
        padding: 0 12px;
        font-size: 17px;
    }

    .taskbar-btn {
        height: 34px;
        min-width: 80px;
    }

    #taskbar-clock {
        font-size: 17px;
    }

    /* Start menu desde abajo */
    #start-menu {
        bottom: 46px;
    }
}

@media (max-width: 480px) {
    .app-sidebar {
        width: 160px;
    }

    .app-main-header {
        padding: 6px 10px;
        min-height: 38px;
    }

    .app-main-title {
        font-size: 20px;
    }

    .app-main-header .btn.sm {
        font-size: 13px;
        height: 22px;
        padding: 0 7px;
    }

    .list-entry {
        padding: 6px 8px;
    }

    .list-entry-icon {
        font-size: 19px;
    }

    .list-entry-title {
        font-size: 14px;
    }
}

/* ── Sidebar fondo degradado ── */
.app-sidebar-header {
    background: var(--title-bg2);
}

/* ── Welcome screen mejor ── */
.welcome-screen {
    background: var(--bg3);
}

.welcome-screen .btn.primary {
    margin-top: 4px;
}

/* ── Admin panel responsive para móvil ── */
@media (max-width: 900px) {
    #win-admin {
        left: 4px !important;
        top: 4px !important;
        width: calc(100vw - 8px) !important;
        height: calc(100% - 52px) !important;
    }

    .admin-table {
        font-size: 13px;
    }

    .admin-table td,
    .admin-table th {
        padding: 3px 5px;
    }

    .admin-table .row {
        flex-wrap: wrap;
        gap: 3px;
    }

    .admin-table .btn.sm {
        font-size: 12px;
        height: 20px;
        padding: 0 5px;
    }
}

@media (max-width: 700px) {

    /* Sidebar más estrecha, texto reducido */
    .app-sidebar {
        width: 160px !important;
        min-width: 0;
    }

    .list-entry-title {
        font-size: 14px;
    }

    .list-entry-sub {
        font-size: 12px;
    }

    .list-entry-icon {
        font-size: 18px;
    }

    /* Header lista */
    .app-main-title {
        font-size: 22px;
    }

    .app-main-header {
        padding: 5px 8px;
        min-height: 36px;
    }

    .app-main-header .btn.sm {
        font-size: 13px;
        height: 22px;
        padding: 0 6px;
    }

    /* Items */
    .item-row {
        padding: 5px 8px;
    }

    .item-qty {
        font-size: 12px;
        padding: 1px 4px;
    }

    .item-note {
        font-size: 14px;
        white-space: normal;
    }

    /* Add row */
    .add-item-row {
        padding: 5px 8px;
        gap: 3px;
    }

    .add-item-qty {
        width: 46px;
    }

    /* Diálogos: pantalla completa en móvil */
    .dialog {
        width: calc(100vw - 16px) !important;
        max-width: none;
    }

    .dialog-overlay {
        align-items: flex-end;
        padding-bottom: 8px;
    }

    /* Menú barra más visible */
    .win-menubar {
        height: 28px;
    }

    .win-menu-item {
        padding: 0 10px;
        font-size: 14px;
    }

    /* Status bar */
    .win-status {
        height: 24px;
        font-size: 12px;
    }

    .win-status-panel {
        padding: 1px 5px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .app-sidebar {
        width: 130px !important;
    }

    .list-entry {
        padding: 5px 6px;
        gap: 5px;
    }

    .app-main-header {
        flex-wrap: wrap;
    }

    .item-text {
        font-size: 14px;
    }

    /* Solo icono en header de lista, sin botones extra */
    .app-main-header .btn.sm.danger {
        display: none;
    }
}


/* ── Permiso badge en compartir ── */
.share-row-perm {
    font-size: 13px;
    min-width: 70px;
}

.share-row .btn[title] {
    font-size: 17px;
    padding: 0 5px;
}

/* ── Fix: win-body.app-split — row gana sobre column ── */
.win-body.app-split {
    flex-direction: row !important;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.win-body.app-split .app-sidebar {
    height: 100%;
}

.win-body.app-split .app-main {
    height: 100%;
}

/* ── Fix Android / móvil: taskbar siempre visible ── */

/* Soporte para safe area (iOS notch + Android nav bar) */
:root {
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}





/* Taskbar: altura con padding para safe area de Android */
#taskbar {
    padding-bottom: var(--safe-bottom);
    height: calc(38px + var(--safe-bottom));
}

/* Start menu y notifs suben sobre la safe area */
#start-menu {
    bottom: calc(40px + var(--safe-bottom));
}

#notif-root {
    bottom: calc(46px + var(--safe-bottom));
}

.sysalert {
    bottom: calc(50px + var(--safe-bottom));
}

/* En móvil: workspace no puede crecer más allá del contenedor */
@media (max-width: 900px) {
    #workspace {
        min-height: 0;
        overflow: hidden;
    }

    #win-main {
        height: 100% !important;
        max-height: 100% !important;
    }
}

@media (max-width: 700px) {
    #taskbar {
        height: calc(44px + var(--safe-bottom));
    }

    #start-menu {
        bottom: calc(46px + var(--safe-bottom));
    }
}

/* ── Diálogos y alertas en móvil ── */

/* En móvil los diálogos salen centrados y con buen tamaño */
@media (max-width: 700px) {

    /* Dialog overlay: centrado vertical con margen */
    .dialog-overlay {
        align-items: center !important;
        justify-content: center !important;
        padding: 16px !important;
        padding-bottom: calc(16px + var(--safe-bottom)) !important;
    }

    /* Dialog: casi pantalla completa, scroll interno si necesario */
    .dialog {
        width: calc(100vw - 32px) !important;
        max-width: 420px !important;
        max-height: calc(calc(var(--vh, 1vh) * 100) - 80px) !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
    }

    .dialog-body {
        overflow-y: auto !important;
        flex: 1 !important;
        -webkit-overflow-scrolling: touch;
    }

    .dialog-btns {
        flex-shrink: 0 !important;
        padding: 10px 16px 14px !important;
        gap: 10px !important;
    }

    /* Botones del dialog más grandes para touch */
    .dialog-btns .btn {
        height: 36px !important;
        font-size: 17px !important;
        flex: 1 !important;
        justify-content: center !important;
    }
}

/* System alerts en móvil */
@media (max-width: 700px) {
    .sysalert {
        width: calc(100vw - 24px) !important;
        right: 12px !important;
        left: 12px !important;
        bottom: calc(50px + var(--safe-bottom, 0px)) !important;
        max-width: 420px !important;
    }

    .sysalert-body {
        font-size: 16px !important;
        line-height: 1.5 !important;
    }

    .sysalert-btns {
        gap: 8px !important;
        padding: 8px 12px 12px !important;
    }

    .sysalert-btns .btn {
        height: 34px !important;
        font-size: 16px !important;
        flex: 1 !important;
        justify-content: center !important;
    }
}

/* Confirm dialog específicamente */
@media (max-width: 700px) {
    #dlg-confirm .dialog {
        width: calc(100vw - 40px) !important;
        max-width: 360px !important;
    }

    #dlg-confirm .dialog-msg {
        font-size: 16px !important;
        padding: 4px 0 !important;
    }

    /* Select dentro del confirm (transferir autoría) */
    #dlg-confirm .input {
        height: 36px !important;
        font-size: 17px !important;
    }
}

/* ── Mobile: safe area + taskbar ── */
:root {
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 900px) {
    #win-admin {
        left: 4px !important;
        top: 4px !important;
        width: calc(100vw - 8px) !important;
        height: calc(100% - 52px) !important;
    }
}

@media (max-width: 700px) {
    #taskbar {
        height: calc(44px + var(--safe-bottom));
        padding-bottom: var(--safe-bottom);
    }

    #start-menu {
        bottom: calc(46px + var(--safe-bottom));
    }

    #notif-root {
        bottom: calc(46px + var(--safe-bottom));
    }

    .sysalert {
        bottom: calc(50px + var(--safe-bottom));
    }
}

/* ── Mobile: safe area ── */
:root {
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 700px) {
    #taskbar {
        height: calc(44px + var(--safe-bottom));
        padding-bottom: var(--safe-bottom);
    }

    #start-menu {
        bottom: calc(46px + var(--safe-bottom));
    }

    #notif-root {
        bottom: calc(46px + var(--safe-bottom));
    }

    .sysalert {
        bottom: calc(50px + var(--safe-bottom));
    }
}

/* ── Selector de idioma ── */
.lang-select {
    background: rgba(255, 255, 255, .15);
    border: 1px solid rgba(255, 255, 255, .25);
    color: var(--title-txt);
    font-family: var(--mono);
    font-size: 13px;
    padding: 1px 4px;
    cursor: pointer;
    border-radius: 2px;
    height: 18px;
    outline: none;
    margin-left: 4px;
}

.lang-select:focus {
    border-color: rgba(255, 255, 255, .5);
}

.lang-select option {
    background: var(--title-bg2);
    color: var(--title-txt);
}

/* Selector inline en el menubar (dentro de win-menu-item) */
#menu-lang {
    display: flex;
    align-items: center;
    cursor: default;
    padding: 0 6px;
}

.lang-select-inline {
    background: transparent;
    border: none;
    color: var(--text2);
    font-family: var(--mono);
    font-size: 14px;
    cursor: pointer;
    outline: none;
    padding: 0;
    max-width: 130px;
}

.lang-select-inline:hover {
    color: var(--title-bg);
}

.lang-select-inline option {
    background: var(--bg3);
    color: var(--text);
}

/* ── Login: centrado fijo, estático ── */
#win-login {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
    width: 340px !important;
    max-width: calc(100vw - 32px) !important;
    cursor: default !important;
}

/* Quitar cursor de arrastre en el titlebar del login */
#win-login .win-titlebar {
    cursor: default !important;
}

/* Móvil: login más grande y cómodo */
@media (max-width: 700px) {
    #win-login {
        width: calc(100vw - 32px) !important;
        max-width: 420px !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
    }

    #win-login .login-form {
        padding: 22px 20px;
        gap: 14px;
    }

    #win-login .input {
        height: 38px !important;
        font-size: 18px !important;
        padding: 4px 10px !important;
    }

    #win-login .btn.primary {
        height: 38px !important;
        font-size: 18px !important;
        padding: 0 20px !important;
    }

    #win-login label {
        font-size: 16px !important;
    }

    #win-login .login-tab {
        padding: 6px 18px !important;
        font-size: 16px !important;
    }

    #win-login .lang-select {
        font-size: 14px !important;
        height: 20px !important;
    }
}

/* ══════════════════════════════════════════════════
   MÓVIL — Sidebar colapsable (estilo app de notas)
   ══════════════════════════════════════════════════ */

@media (max-width: 700px) {

    /* Sidebar: oculta por defecto en móvil */
    .app-sidebar {
        position: absolute !important;
        left: 0;
        top: 0;
        height: 100%;
        z-index: 500;
        width: 80vw !important;
        max-width: 300px !important;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 4px 0 16px rgba(0, 0, 0, .25);
    }

    /* Sidebar visible cuando tiene .sidebar-open */
    .app-sidebar.sidebar-open {
        transform: translateX(0);
    }

    /* Overlay oscuro detrás del sidebar abierto */
    #sidebar-overlay {
        display: none;
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, .4);
        z-index: 499;
    }

    #sidebar-overlay.visible {
        display: block;
    }

    /* app-main ocupa todo el ancho */
    .app-main {
        width: 100% !important;
        flex: 1 !important;
    }

    /* Botón hamburguesa en el menubar */
    #btn-sidebar-toggle {
        display: flex !important;
    }

    /* Menubar más alto en móvil para que el botón sea fácil de tocar */
    .win-menubar {
        height: 48px !important;
    }

    .win-menu-item {
        font-size: 16px !important;
    }

    /* Items más grandes para touch */
    .item-row {
        min-height: 44px !important;
        padding: 8px 12px !important;
    }

    .item-check {
        width: 20px !important;
        height: 20px !important;
    }

    /* Botones de acción de item siempre visibles en móvil */
    .item-actions {
        opacity: 1 !important;
    }

    .item-actions .btn.sm {
        height: 30px !important;
        padding: 0 10px !important;
        font-size: 16px !important;
    }

    /* Add row más alto */
    .add-item-row {
        padding: 10px 12px !important;
        gap: 6px !important;
    }

    .add-item-text {
        height: 36px !important;
        font-size: 17px !important;
    }

    #btn-quick-add {
        height: 36px !important;
        font-size: 17px !important;
    }

    /* Header lista */
    .app-main-header {
        padding: 8px 12px !important;
    }

    .app-main-title {
        font-size: 24px !important;
    }

    /* Progress wrap */
    .progress-wrap {
        padding: 5px 12px !important;
        font-size: 14px !important;
    }

    /* Presence bar */
    .presence-bar {
        padding: 4px 12px !important;
        font-size: 14px !important;
    }

}

/* Botón hamburguesa — oculto en desktop */
#btn-sidebar-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    cursor: pointer;
    color: var(--text2);
    font-size: 19px;
    border: none;
    background: none;
    font-family: var(--mono);
    height: 100%;
}

#btn-sidebar-toggle:hover {
    background: var(--title-bg);
    color: #fff;
}

/* Móvil: botón hamburguesa grande y fácil de tocar */
@media (max-width: 700px) {
    #btn-sidebar-toggle {
        font-size: 36px;
        padding: 0 18px;
        min-width: 60px;
        color: var(--title-bg);
        font-weight: 700;
    }

    #btn-sidebar-toggle:active {
        background: var(--title-bg);
        color: #fff;
    }
}