/* Dropdown: default hidden */
.nav-dropdown-content {
    display: none;
    position: absolute;
    left: 0;
    top: 100%;
    background: #222b3a;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    min-width: 180px;
    z-index: 1000;
}
/* Show on hover of container for drag-to-select behavior */
.nav-dropdown:hover .nav-dropdown-content,
.nav-dropdown-content.show-dropdown {
    display: block;
}
/* Make items easy to drag onto */
.nav-dropdown-content .nav-btn {
    display: block;
    width: 100%;
    text-align: left;
}
body {
        background-image: url('space-background.jpg');
        background-size: cover;
        color: white;
        font-family: Arial, sans-serif;
    }

    /* Standardized module layout classes */
    .module-panel {
        width: 95vw;
        max-width: 2000px;
        margin: 0 auto;
        background: #1f2937;
        border: 1px solid #2b374a;
        border-radius: 8px;
        padding: 16px;
    }

    .module-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 16px;
    }

    .module-card,
    .char-card,
    .corp-card {
        background: #192131;
        border: 1px solid #2b374a;
        border-radius: 8px;
        overflow: hidden;
    }

    .module-card-header,
    .char-header,
    .corp-header {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px;
        background: #202a3a;
    }

    .module-card-body,
    .char-body,
    .corp-body {
        padding: 12px;
    }

    .module-info-grid,
    .info-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px 12px;
    }

    .module-info-key,
    .info-key { color: #9aa3b2; }
    .module-info-val,
    .info-val { color: #e0e6ee; }
    .module-sep,
    .sep { color: #6f7b8c; }

    .char-portrait { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; }
    .corp-logo { width: 64px; height: 64px; border-radius: 8px; object-fit: cover; background: #111; }
    .char-title .char-name, .corp-title .corp-name { font-weight: 600; color: #fff; }
    .char-aff, .corp-aff { color: #b8c0cc; font-size: 13px; }

    /* Module section title standardization */
    .module-section-title {
        font-size: 1.6em;
        font-weight: 600;
        color: #fff;
        margin: 0 0 8px 0;
    }

    /* Layout grouping titles within modules */
    .layout-group-title {
        font-size: 1.2em;
        font-weight: 600;
        color: #fff;
        margin: 8px 0;
    }

    .layout-group { margin: 10px 0 18px; }
    .layout-group .module-grid {
        transition: border-color 0.2s, background 0.2s;
    }
    .layout-group-empty .module-grid {
        min-height: 48px;
        padding: 8px;
        border: 1px dashed #2b374a;
        border-radius: 6px;
        background: rgba(31,41,55,0.3);
    }
    .layout-drop-target .module-grid {
        border-color: #3b82f6;
        background: rgba(59,130,246,0.08);
    }
    /* Live insert preview when dragging cards */
    .layout-insert-preview {
        border: 2px dashed #3b82f6;
        background: rgba(59,130,246,0.12);
        border-radius: 6px;
        height: 12px;
        margin: 6px 0;
        pointer-events: none; /* avoid capturing hover/drag target */
    }

    /* Drag handle on cards */
    .drag-handle {
        margin-left: auto;
        font-size: 18px;
        color: #9aa3b2;
        cursor: grab;
        user-select: none;
    }
    .drag-handle:active { cursor: grabbing; }

    /* Overview totals row styling (avoid table row collisions) */
    .overview-totals-row {
        display: flex;
        flex-wrap: wrap;
        gap: 12px;
        align-items: stretch;
    }
    .total-card {
        flex: 1 1 220px;
        min-width: 220px;
        border-radius: 10px;
        padding: 12px 14px;
        color: #fff;
        box-shadow: 0 3px 10px rgba(0,0,0,0.25);
    }
    .total-card .label { font-weight: 600; opacity: 0.9; }
    .total-card .value { font-size: 1.4em; font-weight: 700; margin-top: 6px; }
    .total-wallet { background: linear-gradient(135deg, #2563eb, #0ea5e9); }
    .total-assets { background: linear-gradient(135deg, #16a34a, #22c55e); }
    .total-sp { background: linear-gradient(135deg, #7c3aed, #a855f7); }
    .total-omega { background: linear-gradient(135deg, #f59e0b, #f97316); }
    .total-muted { background: linear-gradient(135deg, #374151, #1f2937); }

    /* Clone state toggle */
    .clone-toggle {
        display: inline-flex;
        gap: 6px;
        margin-top: 6px;
    }
    .clone-toggle .toggle-btn {
        padding: 4px 8px;
        border-radius: 6px;
        background: #2b374a;
        color: #fff;
        font-size: 12px;
        line-height: 1.2;
        cursor: pointer;
        user-select: none;
        border: 1px solid #2b374a;
    }
    .clone-toggle .toggle-btn:hover { background: #334155; }
    .clone-toggle .toggle-btn.active { background: #0ea5e9; border-color: #0ea5e9; }

    .header-bar {
        width: 100%;
        background: #1a2332;
        padding: 18px 0 0 0;
        margin-bottom: 24px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
        display: flex;
        flex-direction: column;
        align-items: stretch;
        min-height: 140px;
        position: relative;
    }

    .header-top {
        display: flex;
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
        width: 100%;
    }

    .header-title {
        margin: 0 auto;
        font-size: 2em;
        color: #fff;
        font-weight: 700;
        letter-spacing: 1px;
        text-align: center;
        vertical-align: top;
        flex: 1;
        padding-top: 8px;
    }

    .nav-links {
        display: flex;
        gap: 32px;
        align-items: center;
        justify-content: center;
        width: 100%;
        margin: 0 auto 0 auto;
        padding-bottom: 8px;
    }

    .nav-btn {
        background: none;
        color: #fff;
        border: none;
        padding: 10px 24px;
        font-size: 1.1em;
        cursor: pointer;
        border-radius: 6px;
        transition: background 0.2s, color 0.2s;
    }

    .nav-btn:hover {
        background: #283a5b;
        color: #ffd700;
    }

    .active-link {
        background: #ffd700;
        color: #1a2332 !important;
        font-weight: bold;
        text-decoration: none;
    }

    .character-bar {
        margin-right: 32px;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        justify-content: flex-end;
        min-width: 220px;
    }

    #characterName {
        font-size: 1.2em;
        margin-bottom: 2px;
    }

    #lastRefreshed {
        font-size: 1.1em;
        margin-bottom: 2px;
    }

    #linkCharacter {
        background-color: #007bff;
        color: white;
        border: none;
        padding: 8px 16px;
        text-align: center;
        text-decoration: none;
        display: inline-block;
        font-size: 14px;
        margin: 4px 0 0 0;
        cursor: pointer;
        border-radius: 4px;
    }

    .module-select-modal {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 9999;
    }

    .module-select-modal-content {
        background: #222;
        color: #fff;
        padding: 2em;
        border-radius: 8px;
        min-width: 300px;
        max-width: 90vw;
    }

    .module-select-modal-content h2 {
        margin-top: 0;
    }

    .module-select-modal-content form {
        margin-bottom: 0;
    }

    .module-select-modal-content button {
        margin-right: 1em;
    }

    .module-select-modal-content .module-select-actions {
        margin-top: 1em;
        text-align: right;
    }
    
    #discordConfigBox {
        background: #222;
        color: #eee;
        padding: 18px 24px;
        border-radius: 10px;
        margin: 32px 24px 0 auto;
        /* align right, add right margin */
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
        max-width: 30%;
        /* allow two cards per row */
        font-size: 0.97em;
        text-align: left;
    }
    
    .config-card {
        font-size: 0.92em;
        width: 48%;
        display: inline-block;
        margin: 0 1% 8px 0;
        vertical-align: top;
        box-sizing: border-box;
        border: 1px solid #ccc;
        padding: 10px;
        border-radius: 6px;
        background: #222;
        min-width: 160px;
        max-width: 40vw;
    }

    .config-card button {
        margin-top: 10px;
    }

    .container {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        max-width: 100vw;
        margin: 32px 0;
        padding-right: 32px;
        /* more space on right edge */
        position: relative;
        align-items: flex-start;
        gap: 32px;
    }

    #healthStatusBox {
        min-width: 260px;
        max-width: 400px;
        flex: 1 1 320px;
        margin: 0;
    }

    #discordConfigBox {
        flex: 2 1 400px;
        max-width: 600px;
        margin: 0;
    }

    @media (max-width: 900px) {
        .container {
            flex-direction: column;
            gap: 0;
        }

        #healthStatusBox,
        #discordConfigBox {
            max-width: 100%;
            margin-bottom: 24px;
        }
    }

    #discordAccountLinkContainer {
        background: none;
        color: inherit;
        padding: 0;
        border-radius: 0;
        margin: 18px 0 0 0;
        box-shadow: none;
        max-width: none;
        font-size: inherit;
    }

    #discordAccountLinkContainer h3 {
        color: #fff;
        margin-top: 0;
    }

    #discordAccountLinkContainer button {
        background: #5865F2;
        color: #fff;
        border: none;
        padding: 8px 16px;
        border-radius: 6px;
        margin-top: 8px;
        margin-right: 8px;
        cursor: pointer;
    }

    #discordAccountLinkContainer button#verifyDiscordAccountBtn {
        background: #4a8;
        margin-left: 0;
    }

    /* Calendar Styles */
    .calendar-table {
      margin-left: auto;
      margin-right: 32px;
      width: 32vw;
      max-width: 900px;
      border-collapse: separate;
      border-spacing: 0;
      background: rgba(20, 24, 32, 0.95);
      box-shadow: 0 4px 24px rgba(0,0,0,0.3);
      border-radius: 12px;
    }
    .calendar-table th, .calendar-table td {
      width: calc(100% / 7);
      height: 80px;
      text-align: center;
      vertical-align: top;
      font-size: 1.1em;
      position: relative;
      box-sizing: border-box;
    }
    .calendar-table th {
      background: #232b3a;
      color: #fff;
      font-weight: 600;
      padding: 12px 0;
    }
    .calendar-table td {
      background: #232b3a;
      border: 1px solid #2c3446;
      transition: background 0.2s;
    }
    .calendar-table td:nth-child(even),
    .calendar-table tr:nth-child(even) td {
      background: #1a1f2b;
    }
    .calendar-table td:hover {
      background: #2c3446;
    }
    .calendar-day-events {
      list-style: none;
      padding: 0;
      margin: 6px 0 0 0;
      font-size: 0.95em;
    }
    #calendarGrid {
      display: block;
      margin-top: 24px;
    }
    #calendarModuleContainer {
      display: block;
    }
