/* Basic styling for main.html - under development page */
:root {
  --bg-black: #000000;
  --charcoal-dark: #0b0b0c; 
  --charcoal: #121416; 
  --gold: #d4af37;
  --text: #e6e7e8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

html, body {
  height: 100%;
}

body {
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  background: var(--bg-black);
  color: var(--text);
  margin: 0;
  height: 100vh;
}

/* Main header */
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: var(--bg-black);
  z-index: 130; /* Positioned higher than the toolbar layer */
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px 0 8px;
  overflow: visible !important; /* CRITICAL: Allows dropdown lists to spill out of the 64px header frame */
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap; /* Keeps branding and menu triggers on a singular rigid horizon line */
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  color: var(--gold);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
}

.title-field {
  display: inline-flex;
  align-items: center;
  min-width: 180px;
  width: calc(2.5 * 40px);
  padding: 6px 10px;
  border: 2px solid var(--gold);
  border-radius: 4px;
  background: transparent;
}

.title-field input {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--gold);
  font-size: 0.95rem;
  font-weight: 600;
}

.menu-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.menu-tab {
  background: transparent;
  border: none;
  color: var(--gold);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 6px;
  transition: color 0.1s ease;
}

.profile-badge {
  width: 40px;
  height: 40px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  font-weight: 700;
  font-size: 1rem;
  background: transparent;
}

/* ----------------------------------------------------
   TOP BAR DROPDOWN CONFIGURATIONS
   ---------------------------------------------------- */

/* Wraps individual triggers within the navigation tabs */
.menu-tabs .menu-item {
  position: relative;
  display: inline-block;
}

/* Keeps trigger button visually stable and white when menu state stays active */
.menu-tabs .menu-item.active .menu-trigger.menu-tab {
  background: var(--charcoal);
  color: #ffffff !important;
  border-radius: 4px;
}

/* Hover rule: Gold text cleanly flips to white on pointer intersection */
.menu-tabs .menu-trigger.menu-tab:hover {
  color: #ffffff !important;
}

/* Floating Dropdown Card Context for Top Header Options */
.menu-tabs .menu-dropdown {
  display: none; 
  position: absolute;
  top: 100%;
  left: 0;
  background-color: var(--charcoal-dark);
  min-width: 200px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  border: 1px solid #222;
  border-radius: 4px;
  padding: 4px 0;
  margin-top: 6px;
  z-index: 9999 !important; /* Forces layout context onto the absolute outermost visual layer */
}

/* Links/Actions inside the top menus */
.menu-tabs .menu-dropdown .tool-btn {
  display: flex;
  width: 100%;
  background: transparent;
  border: none;
  text-align: left;
  padding: 8px 14px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  box-sizing: border-box;
  height: auto;
  justify-content: flex-start;
  border-radius: 0;
}

.menu-tabs .menu-dropdown .tool-btn:hover {
  background-color: var(--charcoal);
  color: var(--gold);
}

/* Tiny horizontal line break inside top menus */
.menu-tabs .menu-sub-divider {
  height: 1px;
  background-color: #222;
  margin: 4px 0;
}

/* Displays dropdown when container possesses active state handler */
.menu-tabs .menu-item.active .menu-dropdown {
  display: block !important;
}


/* ----------------------------------------------------
   LOWER TOOLBAR STYLING (LEFT COMPLETELY UNTOUCHED)
   ---------------------------------------------------- */
.toolbar {
  position: fixed;
  top: 64px;
  left: 0;
  right: 0;
  height: 40px;
  background: var(--bg-black);
  border-bottom: 1px solid #1a1a1a;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  user-select: none;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
}

.toolbar-group::-webkit-scrollbar {
  display: none;
}

.tool-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 28px;
}

.tool-btn:hover {
  background: var(--charcoal);
  color: var(--gold);
}

.tool-btn.bold { font-weight: 800; font-size: 0.9rem; }
.tool-btn.italic { font-style: italic; font-size: 0.9rem; }
.tool-btn.strike { text-decoration: line-through; font-size: 0.9rem; }
.tool-btn.font-numeric { font-family: monospace; font-size: 0.85rem; }
.tool-btn.format-btn { font-size: 0.95rem; font-weight: 700; }

.tool-select {
  background: var(--charcoal);
  border: 1px solid #333;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  height: 28px;
  outline: none;
  cursor: pointer;
}

.tool-select:focus {
  border-color: var(--gold);
}

.tool-divider {
  width: 1px;
  height: 18px;
  background: #252525;
  margin: 0 4px;
  flex-shrink: 0;
}

.overflow-btn {
  margin-left: auto;
  flex-shrink: 0;
  color: #555;
}
.overflow-btn:hover {
  color: var(--gold);
}

/* Dedicated full-width black row container for the selection box */
.sub-header-bar {
  position: fixed;
  top: 104px;
  left: 0;
  right: 0;
  height: 34px;
  background: var(--bg-black);
  border-bottom: 1px solid #1a1a1a;
  display: flex;
  align-items: center;
  padding: 0 18px;
  z-index: 115;
}

/* Writable/Editable Selection Reference input field box */
.selection-box {
  width: 100px;
  height: 22px;
  background: var(--charcoal-dark);
  border: 1px solid var(--gold);
  border-radius: 2px;
  color: var(--gold);
  font-family: monospace;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0 8px;
  box-sizing: border-box;
  outline: none;
}

.selection-box:focus {
  border-color: var(--text);
  background: #151618;
}

/* Stage shown before grid generation */
.stage {
  position: fixed;
  inset: 0;
  background: var(--bg-black);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

/* Parent container utilizing CSS Grid Layout */
.grid-root {
  position: fixed;
  top: 158px; 
  left: 18px;
  right: 20px;
  bottom: 0;
  display: none;
  overflow: auto;
  z-index: 10;
  border: 3px solid var(--gold);
  box-shadow: 0 0 0 1px #000 inset;
}

.grid-root::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: var(--grid-width, 1px);
  height: var(--grid-height, 1px);
  pointer-events: none;
}

/* Prevents browser string highlight artifacts while dragging across cell layouts */
.grid-root.selecting-cells {
  user-select: none;
}

/* Highlighting color for multiple selected blocks */
.cell.data-cell.selected {
  background: rgba(212, 175, 55, 0.18) !important;
  outline: 1px solid var(--text);
  z-index: 2;
}

/* Decorative edge lines: Three parallel gold bars with exactly 3px thickness */
.edge {
  position: fixed;
  z-index: 100;
  pointer-events: none;
}

.edge-left {
  top: 138px;
  bottom: 0;
  left: -1px;
  width: 21px;
  background: linear-gradient(to right, 
    var(--gold) 0px, var(--gold) 3px, 
    transparent 3px, transparent 9px, 
    var(--gold) 9px, var(--gold) 12px, 
    transparent 12px, transparent 18px, 
    var(--gold) 18px, var(--gold) 21px
  );
}

.edge-right {
  top: 138px;
  bottom: 0;
  right: 0px;
  width: 21px;
  background: linear-gradient(to right, 
    var(--gold) 0px, var(--gold) 3px, 
    transparent 3px, transparent 9px, 
    var(--gold) 9px, var(--gold) 12px, 
    transparent 12px, transparent 18px, 
    var(--gold) 18px, var(--gold) 21px
  );
}

.edge-top {
  top: 138px;
  left: 0;
  right: 0;
  height: 21px;
  background: linear-gradient(to bottom, 
    var(--gold) 0px, var(--gold) 3px, 
    transparent 3px, transparent 9px, 
    var(--gold) 9px, var(--gold) 12px, 
    transparent 12px, transparent 18px, 
    var(--gold) 18px, var(--gold) 21px
  );
}

/* Standard data and label boxes */
.cell {
  width: 100%;
  height: 100%;
  background: var(--charcoal);
  border: 1px solid var(--gold);
  box-sizing: border-box;
  position: relative;
  transition: border 0.05s ease;
}

/* Data input properties */
.data-cell {
  color: var(--text);
  font-size: 0.85rem;
  padding: 6px;
  outline: none;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

/* Visual cue when interacting with data entry points */
.data-cell:focus {
  background: #191b1f;
  border: 2px solid var(--text) !important;
  z-index: 5;
}

/* Separates edge header boxes with precise black lines */
.cell.edge-top-cell,
.cell.edge-left-cell {
  background: var(--gold) !important;
  border-color: var(--bg-black) !important;
  position: relative;
  user-select: none;
}

/* Base Resize Handle Styles */
.resize-handle {
  position: absolute;
  background-color: #000000;
  z-index: 10;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.resize-handle:hover {
  opacity: 1;
}

/* Vertical Handle (Column Resize) */
.col-resize-handle {
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  cursor: col-resize;
}

/* Horizontal Handle (Row Resize) */
.row-resize-handle {
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  cursor: row-resize;
}

/* Label typography adjustments */
.cell-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--bg-black);
  font-weight: 700;
  font-size: 0.9rem;
  user-select: none;
  pointer-events: none;
}
.col-label { letter-spacing: 0.06em; }
.row-label { letter-spacing: 0.02em; }

/* Custom Dark Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-black); }
::-webkit-scrollbar-thumb { background: var(--charcoal); }

/* Prevent text selection cursor artifacts while filling cells */
.grid-root.filling-cells {
  user-select: none;
  cursor: crosshair;
}

/* OVERLAY FIX: The Fill Handle square behaves as an absolute child of #grid-root */
.fill-handle {
  position: absolute;
  width: 8px;
  height: 8px;
  background-color: #000000;
  border: 1.5px solid var(--gold);
  z-index: 20;
  cursor: crosshair;
}

/* Class Toggles for Typography Engine */
.cell-bold {
  font-weight: bold;
}

.cell-italic {
  font-style: italic;
}

.cell-strike {
  text-decoration: line-through;
}

.data-cell.selected {
  z-index: 2;
}

.help-popup-overlay{
    position:fixed;
    inset:0;
    background:rgba(0,0,0,.65);
    display:flex;
    justify-content:center;
    align-items:center;
    z-index:100000;
}

.help-popup{

    width:700px;
    max-width:92vw;
    max-height:82vh;

    display:flex;
    flex-direction:column;

    background:var(--charcoal-dark);

    border:2px solid var(--gold);

    border-radius:6px;

    box-shadow:0 0 30px rgba(0,0,0,.8);

    overflow:hidden;
}

.help-popup-header{

    display:flex;
    justify-content:space-between;
    align-items:center;

    padding:14px 18px;

    background:var(--charcoal);

    border-bottom:2px solid var(--gold);

    color:var(--gold);

    font-weight:700;

    font-size:1rem;
}

.help-popup-close{

    background:none;
    border:none;

    color:var(--gold);

    cursor:pointer;

    font-size:1.6rem;
}

.help-popup-close:hover{

    color:white;

}

.help-popup-body{

    padding:22px;

    overflow:auto;

    color:var(--text);

    line-height:1.7;
}

.help-popup-body h3{

    color:var(--gold);

    margin-bottom:18px;
}

.help-popup-body p{

    margin-bottom:14px;
}

.help-popup-body ul{

    margin-left:22px;
}

.help-popup-body li{

    margin-bottom:8px;
}

.shortcut-table{

    width:100%;

    border-collapse:collapse;
}

.shortcut-table td{

    padding:10px 12px;

    border-bottom:1px solid #2d2d2d;
}

.shortcut-table td:first-child{

    color:var(--gold);

    font-weight:700;

    width:180px;
}

/* Gmail Authorization Panel */
.auth-panel{

    position:fixed;

    inset:0;

    display:none;

    align-items:center;

    justify-content:center;

    background:rgba(0,0,0,.75);

    z-index:100000;

}

.auth-panel.visible{

    display:flex;

}

.auth-card{

    width:380px;

    max-width:90vw;

    background:var(--charcoal-dark);

    border:2px solid var(--gold);

    border-radius:6px;

    box-shadow:0 0 30px rgba(0,0,0,.8);

    padding:20px;

    display:flex;

    flex-direction:column;

    gap:14px;

}

.auth-card h2{

    color:var(--gold);

    font-size:1rem;

    font-weight:700;

    text-align:center;

    margin:0;

}

.auth-card label{

    display:flex;

    flex-direction:column;

    gap:6px;

}

.auth-card label span{

    color:var(--text);

    font-size:.8rem;

    font-weight:600;

}

.auth-card input{

    background:var(--charcoal);

    border:1px solid #333;

    border-radius:4px;

    color:var(--text);

    padding:8px 10px;

    font-size:.85rem;

    outline:none;

}

.auth-card input:focus{

    border-color:var(--gold);

}

.auth-actions{

    display:flex;

    gap:8px;

    justify-content:space-between;

}

.action-btn{

    flex:1;

    background:var(--charcoal);

    border:1px solid #333;

    color:var(--text);

    font-weight:700;

    font-size:.8rem;

    padding:8px;

    border-radius:4px;

    cursor:pointer;

}

.action-btn.primary{

    border-color:var(--gold);

    color:var(--gold);

}

.action-btn:hover{

    border-color:var(--gold);

    color:var(--gold);

}

.auth-status{

    font-size:.8rem;

    text-align:center;

    min-height:1.2em;

}

.auth-status.success{

    color:#7ee787;

}

.auth-status.error{

    color:#f87171;

}

/* Gmail Auth Overlay Backdrop */
    .gmail-modal-overlay {
      position: fixed;
      inset: 0;
      z-index: 99999;
      background-color: rgba(0, 0, 0, 0.75);
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0;
      visibility: hidden;
      transition: opacity 0.2s ease, visibility 0.2s ease;
    }

    .gmail-modal-overlay.visible {
      opacity: 1;
      visibility: visible;
    }

.unsaved-changes-overlay {
  position: fixed;
  inset: 0;
  z-index: 100001;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(3px);
}

.unsaved-changes-overlay.visible {
  display: flex;
}

.unsaved-changes-card {
  width: min(420px, 100%);
  padding: 28px;
  color: var(--text);
  text-align: center;
  background: var(--charcoal-dark);
  border: 2px solid var(--gold);
  border-radius: 8px;
  box-shadow: 0 0 24px rgba(212, 175, 55, 0.22);
}

.unsaved-changes-mark {
  margin-bottom: 12px;
  color: var(--gold);
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.unsaved-changes-card h2 {
  margin-bottom: 10px;
  color: var(--gold);
  font-size: 1.25rem;
}

.unsaved-changes-card p {
  line-height: 1.55;
}

.unsaved-changes-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.unsaved-changes-actions button {
  min-height: 40px;
  padding: 9px 16px;
  border: 1px solid var(--gold);
  border-radius: 4px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.unsaved-stay-btn {
  color: var(--gold);
  background: transparent;
}

.unsaved-stay-btn:hover,
.unsaved-stay-btn:focus-visible {
  color: var(--bg-black);
  background: var(--gold);
}

.unsaved-leave-btn {
  color: var(--text);
  background: var(--charcoal);
}

.unsaved-leave-btn:hover,
.unsaved-leave-btn:focus-visible {
  color: var(--gold);
  background: #1a1a1a;
}

.save-progress-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100002;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
  padding: 0;
}

.save-progress-toast.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.save-progress-toast-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: auto;
  min-width: 240px;
  max-width: 320px;
  padding: 12px 16px;
  color: var(--text);
  background: var(--charcoal-dark);
  border: 1px solid var(--gold);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4), 0 0 16px rgba(212, 175, 55, 0.15);
}

.save-progress-toast-card p {
  color: var(--gold);
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0;
}

.save-progress-spinner {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border: 2px solid rgba(212, 175, 55, 0.28);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: save-progress-spin 0.8s linear infinite;
}

@keyframes save-progress-spin {
  to { transform: rotate(360deg); }
}
}

    /* Black Popup Box with Glowing Golden Edges */
    .gmail-modal-card {
      position: relative;
      width: 320px;
      height: 200px;
      background-color: #000000;
      border: 2px solid #ffd700;
      border-radius: 8px;
      box-shadow: 0 0 15px rgba(255, 215, 0, 0.6),
                  inset 0 0 10px rgba(255, 215, 0, 0.3);
      display: flex;
      align-items: center;
      justify-content: center;
    }

    /* Black Button with Golden Text */
    .gmail-auth-btn-main {
      background-color: #000000;
      color: #ffd700;
      border: 2px solid #ffd700;
      padding: 12px 28px;
      font-size: 14px;
      font-weight: 700;
      letter-spacing: 1.5px;
      text-transform: uppercase;
      cursor: pointer;
      border-radius: 4px;
      transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
      box-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
    }

    /* Hover Effect: Button turns Golden with Black Text */
    .gmail-auth-btn-main:hover {
      background-color: #ffd700;
      color: #000000;
      box-shadow: 0 0 16px rgba(255, 215, 0, 0.9);
    }

    /* Right-side Action Container & Divider */
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-divider {
  width: 1px;
  height: 24px;
  background-color: #222;
}

/* Header Buttons (Invoice, Import, Export) */
.header-btn {
  background: transparent;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.header-btn:hover {
  background-color: var(--gold);
  color: var(--bg-black);
}

.header-btn-icon {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}



/* ----------------------------------------------------
   MODULES DROPDOWN
   ---------------------------------------------------- */

.modules-dropdown {
  position: fixed;
  min-width: 230px;
  max-width: 300px;
  padding: 6px;
  background: var(--charcoal-dark);
  border: 1px solid var(--gold);
  border-radius: 5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
  z-index: 100000;
}

.modules-dropdown[hidden] {
  display: none;
}

.module-option {
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 0;
  border-radius: 3px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.module-option:hover {
  background: var(--charcoal);
  color: var(--gold);
}

.module-checkbox {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--gold);
  border-radius: 2px;
  color: var(--gold);
  font-size: 11px;
  line-height: 1;
}

.module-option.selected .module-checkbox::before {
  content: "✓";
}

.module-option-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Bottom Sheet Slip Footer Bar */
.bottom-sheet-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 36px;
  background: var(--charcoal-dark);
  border-top: 1px solid var(--gold);
  z-index: 120;
  display: flex;
  align-items: center;
  padding: 0 12px;
  box-sizing: border-box;
}

.sheet-tabs-container {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
}

.sheet-tab {
  background: var(--charcoal);
  border: 1px solid #333;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
}

.sheet-tab.active {
  background: var(--gold);
  color: var(--bg-black);
  border-color: var(--gold);
}

.grid-root {
  position: fixed;
  top: 158px; 
  left: 18px;
  right: 20px;
  bottom: 36px; /* Updated from 0 to prevent covering the sheet slip */
  display: none;
  overflow: auto;
  z-index: 10;
  border: 3px solid var(--gold);
  box-shadow: 0 0 0 1px #000 inset;
}
