.login-page {
    min-height: 100vh;
    height: auto;
    overflow: auto;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-card {
    width: min(100%, 420px);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-card a {
    color: #9bdaff;
}

.login-card .field-help {
    font-size: 0.85rem;
    color: #d0dce5;
}

.login-card ul {
    padding-left: 20px;
}

.login-card .errorlist {
    color: #ffb4b4;
}

.preset-picker {
    position: relative;
    display: flex;
    gap: 8px;
    align-items: flex-start;
}

.preset-picker select {
    flex: 1;
    min-width: 0;
}

.preset-actions summary {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    cursor: pointer;
    list-style: none;
    font-size: 24px;
}

.preset-actions summary::-webkit-details-marker { display: none; }
.preset-actions summary:hover,
.preset-actions[open] summary { background: rgba(255, 255, 255, 0.1); }
.preset-actions summary:focus-visible { outline: 2px solid #9bdaff; outline-offset: 2px; }

.preset-actions-panel {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 10;
    max-width: 100%;
    padding: 8px;
    background: #203a43;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.preset-actions-panel .btn:disabled { opacity: 0.45; cursor: not-allowed; }

.account-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-wrap: anywhere;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
    color: #fff;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    height: 100vh;
    padding: 20px;
    gap: 20px;
}

.workspace-menu { grid-column: 1 / -1; padding: 16px 20px; }
.workspace-menu .account-panel {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.plan-menu { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.menu-group { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.menu-picker { display: flex; gap: 8px; }
.menu-picker select { flex: 1; min-width: 0; }
.menu-picker .btn { flex-shrink: 0; }
.workspace-menu #plan-status:not(:empty) { margin-top: 12px; }
.workspace-menu .btn:disabled { opacity: .45; cursor: not-allowed; }

/* Glassmorphism utility */
.glass-panel {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.sidebar {
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
}

.sidebar h2, .sidebar h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: #e0e0e0;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

input, select {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.2);
    color: #fff;
    font-family: 'Inter', sans-serif;
}

input::placeholder {
    color: #aaa;
}

hr {
    border: none;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin: 10px 0;
}

.btn {
    padding: 10px 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn.primary {
    background: #3498db;
    color: #fff;
}

.btn.primary:hover { background: #2980b9; }

.btn.accent {
    background: #e67e22;
    color: #fff;
}

.btn.accent:hover { background: #d35400; }

.btn.danger {
    background: #e74c3c;
    color: #fff;
}

.btn.danger:hover { background: #c0392b; }

.mt-2 { margin-top: 10px; }

.waiting-area {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 100px;
    border: 1px dashed rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 10px;
}

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
}

.stats {
    display: flex;
    gap: 15px;
    align-items: center;
}

.stat-box {
    background: rgba(0, 0, 0, 0.3);
    padding: 8px 15px;
    border-radius: 8px;
    font-weight: 500;
}

.canvas-wrapper {
    flex: 1;
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.container-box {
    position: relative;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #3498db;
    box-shadow: 0 0 20px rgba(52, 152, 219, 0.2);
    transition: width 0.3s, height 0.3s;
}

.item {
    position: absolute;
    cursor: grab;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    border: 1px solid rgba(255,255,255,0.3);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    user-select: none;
    transition: transform 0.1s;
}

.item:active {
    cursor: grabbing;
    transform: scale(1.02);
    z-index: 1000;
}

.item.waiting {
    position: relative;
    cursor: pointer;
    box-shadow: none;
}

.item-delete-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    display: none;
    justify-content: center;
    align-items: center;
    line-height: 1;
    z-index: 10;
}

.item.waiting:hover .item-delete-btn {
    display: flex;
}

.item-context-menu {
    position: fixed;
    z-index: 2000;
    min-width: 180px;
    max-width: 100vw;
    padding: 6px;
    background: #203a43;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.item-context-menu button {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #fff;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.item-context-menu button:hover,
.item-context-menu button:focus-visible {
    background: rgba(255, 255, 255, 0.12);
}

.item-context-menu .delete-action {
    color: #ffaaa2;
}

.sidebar { flex: 0 0 320px; }
.main-area { min-width: 0; min-height: 0; overflow-y: auto; }
.sidebar { min-height: 0; width: auto; }
.topbar, .stats, .toolbar { flex-wrap: wrap; gap: 10px; }
.toolbar { display: flex; }
.guidance { padding: 12px 20px; font-size: .85rem; }
.guidance p { margin-top: 8px; }
.guidance select { width: auto; margin-left: 10px; }
.canvas-wrapper { min-height: 280px; }
.cargo-actions { position: absolute; right: 0; top: 0; min-width: 28px; min-height: 28px;
    background: #203a43; color: white; border: 0; border-radius: 4px; cursor: pointer; }
.item { touch-action: none; overflow-wrap: anywhere; padding: 3px; }
.item.waiting { padding-right: 8px; }
.item-delete-btn { display: flex; }
.item:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 3px solid #9bdaff; outline-offset: 2px;
}
.item.selected { outline: 3px solid #ffe082; outline-offset: -3px; }
#item-detail { padding: 8px; max-width: 300px; overflow-wrap: anywhere; }
#plan-status, #preset-empty { font-size: .85rem; line-height: 1.4; }
dialog { margin: auto; width: min(90vw, 420px); padding: 24px; border-radius: 16px;
    background: #203a43; color: white; border: 1px solid #9bdaff; }
dialog::backdrop { background: rgba(0,0,0,.6); }
[hidden] { display: none !important; }
.print-only { display: none; }

/* Compact workspace: most of the viewport belongs to the loading plan. */
body[data-user-id] { font-size: 14px; }
.app-container { padding: 8px; gap: 8px; grid-template-columns: 270px minmax(0, 1fr); }
.glass-panel { border-radius: 10px; }
.workspace-menu { position: relative; z-index: 40; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 8px 10px; }
.plan-menu { display: flex; flex: 1; flex-wrap: wrap; align-items: center; gap: 6px; min-width: 0; }
.plan-menu #plan-name { width: 180px; }
.plan-menu #plan-select { width: 170px; }
.workspace-menu .account-panel { display: block; margin: 0; max-width: 180px; }
.workspace-menu #plan-status:not(:empty) { width: 100%; margin-top: 0; font-size: 12px; }
.sidebar { padding: 12px; gap: 8px; }
.sidebar h2, .sidebar h3 { font-size: 14px; }
.sidebar hr { margin: 3px 0; }
.form-group { gap: 5px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.preset-add-row { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 8px; align-items: end; }
.sidebar label { font-size: 12px; color: #d0dce5; }
.sidebar .toolbar { gap: 5px; }
.sidebar .toolbar .btn { flex: 1; }
.sidebar .mt-2 { margin-top: 3px; }
body[data-user-id] input, body[data-user-id] select { min-width: 0; padding: 6px 8px; min-height: 32px; font-size: 13px; }
body[data-user-id] input[type=color] { padding: 3px; }
body[data-user-id] .btn { padding: 7px 10px; font-size: 12px; min-height: 32px; }
.preset-actions summary { width: 32px; height: 32px; font-size: 20px; }
.waiting-area { min-height: 65px; padding: 8px; gap: 8px; }
.main-area { gap: 8px; }
.topbar { position: relative; z-index: 20; padding: 8px 10px; }
.stats { width: 100%; gap: 6px; }
.stat-box { padding: 6px 8px; font-size: 12px; }
.stats label { font-size: 12px; }
.stats #packing-goal { width: 145px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.menu-dropdown { position: relative; }
.menu-dropdown summary { cursor: pointer; padding: 7px 10px; min-height: 32px; border-radius: 6px;
    background: rgba(255,255,255,.09); font-size: 12px; overflow-wrap: anywhere; }
.menu-dropdown summary:focus-visible { outline: 2px solid #9bdaff; outline-offset: 2px; }
.menu-dropdown-panel { position: absolute; right: 0; top: calc(100% + 5px); z-index: 30;
    display: flex; flex-direction: column; gap: 7px; width: 280px; max-width: calc(100vw - 24px);
    background: #203a43; padding: 12px; border: 1px solid rgba(255,255,255,.2); border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.menu-dropdown:not([open]) > .menu-dropdown-panel { display: none; }
.compact-help { margin-left: auto; }
.compact-help .menu-dropdown-panel { width: 360px; font-size: 12px; line-height: 1.5; }

@media (max-width: 1000px) {
    .app-container { grid-template-columns: 250px minmax(0, 1fr); }
    .sidebar { flex-basis: 280px; }
    .topbar { align-items: flex-start; }
    .topbar h1 { font-size: 1.3rem; }
    .stats { font-size: .85rem; }
}
@media (max-width: 700px) {
    body { height: auto; overflow: auto; }
    .app-container { height: auto; display: flex; flex-direction: column; }
    .plan-menu { flex-basis: 100%; }
    .plan-menu #plan-name, .plan-menu #plan-select { flex: 1 1 120px; }
    .workspace-menu { padding: 8px; }
    .sidebar { max-height: 45vh; }
    .menu-dropdown-panel { position: fixed; top: 100px; right: 12px; max-height: 70vh; overflow-y: auto; }
    body[data-user-id] .menu-dropdown-panel .btn { min-height: 40px; }
    .sidebar { width: 100%; flex-basis: auto; max-height: 45vh; }
    .main-area { min-height: 65vh; }
    .canvas-wrapper { min-height: 350px; }
    .item-context-menu button { min-height: 44px; }
}
@media print {
    @page { size: A4; margin: 12mm; }
    .print-only { display: block; }
    table.print-only { display: table; width: 100%; border-collapse: collapse; }
    th, td { padding: 6px; border: 1px solid #aaa; text-align: left; overflow-wrap: anywhere; }
    body { background: white; color: black; height: auto; overflow: visible; }
    .app-container { height: auto; display: block; padding: 0; }
    .workspace-menu, .sidebar, .topbar button, .guidance select, .guidance label, .cargo-actions,
    .item-context-menu { display: none !important; }
    .glass-panel, .canvas-wrapper { background: white; color: black; box-shadow: none; border: 0; }
    .canvas-wrapper { overflow: visible; min-height: 350px; }
    .item { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
    .container-box { box-shadow: none; max-width: 100%; }
}

.brand { color: inherit; text-decoration: none; font-weight: 800; font-size: 18px; white-space: nowrap; }

.demo-access { font-size:12px; display:flex; gap:8px; align-items:center; flex-wrap:wrap; } .demo-access a { color:#75c5f1; }
