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

  html, body {
    overflow-x: hidden; 
    width: 100%;
    margin: 0;
    padding: 0;
    background: var(--bg); 
  }

  :root {
    --bg: #6b806f;          
    --surface: #e8e8e8;     
    --border: #999999;
    --border-strong: #444444;
    --text: #000000;
    --text-muted: #444444;
    --text-hint: #666666;
    --accent: #000000;
    --danger: #b33939;
    --success: #218c53;
    --shared-color: #fff176;
  }

  body, input, button, select, textarea { font-family: 'Racing Sans One', sans-serif; }
  
  .app-container {
    color: var(--text); padding: 20px; max-width: 1200px; margin: 0 auto; letter-spacing: 0.5px; min-height: 100vh;
  }

  header {
    display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;
    border: 3px solid var(--text); padding: 15px 20px; background: var(--surface); box-shadow: 4px 4px 0px var(--text);
  }
  .logo { font-size: 32px; letter-spacing: 1px; color: var(--text); }

  .actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

  button, .btn {
    font-weight: normal; background: var(--surface); border: 2px solid var(--text);
    padding: 8px 12px; cursor: pointer; box-shadow: 2px 2px 0px var(--text);
    display: inline-flex; align-items: center; gap: 5px; color: var(--text); font-size: 14px; text-transform: uppercase;
  }
  button:hover, .btn:hover { background: var(--border); box-shadow: 1px 1px 0px var(--text); transform: translate(1px, 1px); }
  button:active, .btn:active { box-shadow: 0px 0px 0px var(--text); transform: translate(2px, 2px); }

  .btn-user-active { background: var(--text) !important; color: var(--surface) !important; box-shadow: 2px 2px 0px var(--border-strong) !important; }

  .dropdown { position: relative; display: inline-block; }
  .dropdown-menu {
    position: absolute; top: 100%; right: 0; margin-top: 6px; background: var(--surface);
    border: 2px solid var(--text); box-shadow: 4px 4px 0px var(--text); display: none; flex-direction: column; min-width: 220px; z-index: 1000;
  }
  .dropdown-menu button { background: transparent; border: none; box-shadow: none; padding: 10px 14px; text-align: left; width: 100%; transform: none !important; }
  .dropdown-menu button:hover { background: var(--border); }
  .dropdown-menu hr { border: none; border-top: 2px solid var(--text); margin: 0; }
  .dropdown-menu .text-danger { color: var(--danger); }
  .dropdown-menu .text-danger:hover { background: #fde8e8; }

  .row-menu-btn { background: transparent; border: none; box-shadow: none; padding: 2px; color: var(--text-hint); }
  .row-menu-btn:hover { background: transparent; color: var(--text); box-shadow: none; transform: none; }

  .nav-container {
    display: flex; align-items: center; margin-bottom: 20px; border: 3px solid var(--text);
    background: var(--surface); box-shadow: 4px 4px 0px var(--text); padding: 10px; gap: 10px; max-width: 100%;
  }
  .month-tabs { 
    display: flex; gap: 8px; overflow-x: auto; flex: 1 1 0%; padding-bottom: 4px; scrollbar-width: thin; scrollbar-color: var(--border-strong) var(--bg); min-width: 0; 
  }
  .month-tabs::-webkit-scrollbar { height: 8px; }
  .month-tabs::-webkit-scrollbar-thumb { background: var(--border-strong); border: 1px solid var(--text); }
  .month-tab { white-space: nowrap; font-size: 16px; flex-shrink: 0; }
  .month-tab.active { background: var(--text); color: var(--surface); box-shadow: none; transform: none; }

  .grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }

  .table-responsive { width:100%; overflow-x:hidden; padding-bottom:5px; }
  .table-min-width { min-width: 480px; width: 100%; }
  .table-min-width-extras { min-width: 520px; width: 100%; }

  .panel { border: 3px solid var(--text); background: var(--surface); padding: 20px; box-shadow: 4px 4px 0px var(--text); margin-bottom: 20px; }
  .panel-title { font-size: 20px; margin-bottom: 15px; border-bottom: 2px solid var(--text); padding-bottom: 5px; display: flex; justify-content: space-between; align-items: center; text-transform: uppercase; flex-wrap: wrap; gap: 10px;}

  .budget-box { display: flex; align-items: center; gap: 15px; }
  .budget-box label { font-size: 18px; }
  .budget-box input { font-size: 20px; padding: 5px 10px; border: 2px solid var(--text); background: #ffffff; width: 100%; max-width: 200px; }

  .table-header { display: grid; grid-template-columns: 30px 40px minmax(0, 1fr) 80px 100px 30px; gap: 8px; margin-bottom: 8px; padding-bottom: 4px; border-bottom: 2px solid var(--border-strong); font-size: 14px; text-transform: uppercase; }
  .row-item { display: grid; grid-template-columns: 30px 40px minmax(0, 1fr) 80px 100px 30px; gap: 8px; margin-bottom: 8px; align-items: center; font-size: 16px; }
  .row-item.paid, .row-item-cards.paid, .row-item-extras.paid { opacity: 0.6; text-decoration: line-through; }

  .cc-tag { font-size: 11px; background: #e0e0e0; color: #000; border: 1px solid var(--text); padding: 1px 4px; margin-left: 5px; border-radius: 4px; white-space: nowrap; }

  .table-header-cards { display: grid; grid-template-columns: 15px minmax(0, 1fr) 80px 120px; gap: 10px; margin-bottom: 8px; padding-bottom: 4px; border-bottom: 2px solid var(--border-strong); font-size: 14px; text-transform: uppercase; }
  .row-item-cards { display: grid; grid-template-columns: 15px minmax(0, 1fr) 80px 120px; gap: 10px; margin-bottom: 8px; align-items: center; font-size: 16px; overflow:hidden; }

  .table-header-extras { display: grid; grid-template-columns: 110px minmax(0, 1fr) 80px 100px 30px; gap: 8px; margin-bottom: 8px; padding-bottom: 4px; border-bottom: 2px solid var(--border-strong); font-size: 14px; text-transform: uppercase; }
  .row-item-extras { display: grid; grid-template-columns: 110px minmax(0, 1fr) 80px 100px 30px; gap: 8px; margin-bottom: 8px; align-items: center; font-size: 16px; }

  .cat-badge { color: #000000; padding: 2px 6px; font-size: 12px; text-align: center; border: 2px solid var(--text); font-weight: bold; display: inline-block; box-shadow: 1px 1px 0px var(--text); width: 100%; text-overflow: ellipsis; overflow: hidden; white-space: nowrap; }
  .friend-badge { background: var(--shared-color); color:#000;border:1px solid var(--text);font-size:11px;padding:2px 5px;margin-left:5px;box-shadow:1px 1px 0px var(--text);display:inline-flex;align-items:center;vertical-align:middle;line-height:1.2; }
  .color-swatch-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
  .color-swatch { width: 32px; height: 32px; border: 2px solid var(--text); cursor: pointer; box-shadow: 1px 1px 0px var(--text); flex-shrink: 0; }
  .color-swatch.selected { outline: 3px solid var(--text); outline-offset: 2px; }
  .color-swatch-custom { display: inline-flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }

  .switch-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--border-strong); }
  .switch-row:last-of-type { border-bottom: none; }
  .switch-label { font-size: 15px; font-weight: bold; }
  .switch-desc { font-size: 12px; color: var(--text-hint); font-weight: normal; margin-top: 2px; line-height: 1.4; }
  .switch { position: relative; display: inline-block; width: 52px; height: 28px; flex-shrink: 0; }
  .switch input { opacity: 0; width: 0; height: 0; }
  .switch-slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background: #ffffff; border: 2px solid var(--text); box-shadow: 2px 2px 0px var(--text); transition: .15s; }
  .switch-slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 2px; bottom: 2px; background: var(--text); transition: .15s; }
  .switch input:checked + .switch-slider { background: var(--success); }
  .switch input:checked + .switch-slider:before { transform: translateX(22px); background: #ffffff; }
  .switch input:disabled + .switch-slider { opacity: 0.4; cursor: not-allowed; }
  .friend-online-badge { background: #218c53; color: #fff; border: 1px solid var(--text); font-size: 10px; padding: 1px 4px; margin-left: 5px; border-radius: 4px; }

  .checkbox-btn { cursor: pointer; background: transparent; border: none; box-shadow: none; padding: 0; display: flex; align-items: center; justify-content: center; color: var(--text); }
  .checkbox-btn:hover { background: transparent; transform: scale(1.1); box-shadow: none; }
  .checkbox-btn.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

  input, select, textarea { padding: 8px 10px; border: 2px solid var(--text); background: #ffffff; color: #000000; font-size: 16px; width: 100%;}
  input:focus, select:focus, textarea:focus { outline: none; background: #ffffcc; }

  .summary-box { display: flex; flex-direction: column; gap: 10px; margin-bottom: 15px; }
  .summary-row { display: flex; justify-content: space-between; font-size: 16px; border-bottom: 1px dashed var(--border-strong); padding-bottom: 5px; }
  .summary-row.total-spent { border-bottom: none; font-size: 18px; color: var(--danger); margin-top: 10px; }
  .summary-row.available { border-bottom: none; border: 3px solid var(--text); background: #ffffff; padding: 15px; font-size: 24px; box-shadow: 3px 3px 0px var(--text); margin-top: 10px; }
  .summary-row.available.negative { color: #ffffff; background: var(--danger); }

  .progress-container { border: 2px solid var(--text); background: #ffffff; height: 20px; margin-bottom: 15px; box-shadow: 2px 2px 0px var(--text); position: relative; overflow: hidden; }
  .progress-bar { height: 100%; background: var(--success); width: 0%; transition: width 0.3s; }
  .progress-bar.danger { background: var(--danger); }
  
  .chart-container { margin-top: 15px; display: flex; justify-content: center; min-height: 200px; }
  .chart-legend-container { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 15px; border-top: 1px dashed var(--border-strong); padding-top: 15px; }
  .legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; border: 2px solid var(--text); background: #ffffff; padding: 3px 8px; box-shadow: 2px 2px 0px var(--text); }
  .legend-color { display: inline-block; width: 12px; height: 12px; border: 1px solid var(--text); }

  .modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6); display: none; justify-content: center; align-items: center; z-index: 2000; padding: 10px; }
  .modal-content { background: var(--surface); border: 4px solid var(--text); padding: 25px; width: 100%; max-width: 420px; box-shadow: 8px 8px 0px var(--text); display: flex; flex-direction: column; gap: 15px; max-height: 90vh; overflow-y: auto;}
  .modal-title { font-size: 22px; border-bottom: 2px solid var(--text); padding-bottom: 10px; text-transform: uppercase; margin-bottom: 5px; }
  .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }
  .form-group { display: flex; flex-direction: column; gap: 5px; }

  .cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .cat-btn { display: flex; flex-direction: column; align-items: center; padding: 15px 5px; text-align: center; font-weight: bold; text-transform: uppercase; box-shadow: 2px 2px 0px var(--text); }
  .config-card-item { display: flex; justify-content: space-between; align-items: center; padding: 8px; border: 2px solid var(--text); background: #ffffff; margin-bottom: 5px;}
  
  .friends-share-list { display: flex; flex-direction: column; gap: 8px; background: #fff; border: 2px solid var(--text); padding: 10px; max-height: 120px; overflow-y: auto; }
  .friend-check-item { display: flex; align-items: center; gap: 8px; font-size: 15px; }

  @media (max-width: 900px) { .grid { grid-template-columns: 1fr; } }
  
  @media (max-width: 600px) {
    .table-min-width, .table-min-width-extras { min-width: 0 !important; width: 100%; }
    .app-container { padding: 10px; } 
    header { flex-direction: column; align-items: stretch; text-align: center; gap: 15px; padding: 10px; }
    .actions { justify-content: center; gap: 8px; }
    .logo { font-size: 26px; }
    button, .btn { padding: 6px 8px; font-size: 12px; }
    .panel { padding: 12px 10px; margin-bottom: 15px; }
    .panel-title { font-size: 15px; margin-bottom: 10px; flex-wrap: nowrap; }
    .budget-box label { font-size: 15px; }
    .budget-box input { max-width: 120px; font-size: 15px; padding: 4px 6px; }

    .table-header, .row-item { grid-template-columns: 20px 20px minmax(0, 1fr) 50px 65px 20px; gap: 4px; font-size: 11px; }
    .table-header-cards, .row-item-cards { grid-template-columns: 10px minmax(0, 1fr) 35px 75px; gap: 4px; font-size: 12px; }
    .table-header-extras, .row-item-extras { grid-template-columns: 55px minmax(0, 1fr) 50px 65px 20px; gap: 4px; font-size: 11px; }

    .cat-badge { font-size: 10px; padding: 2px; }
    .material-symbols-outlined { font-size: 18px !important; }
    .summary-row { font-size: 13px; }
    .summary-row.total-spent { font-size: 15px; }
    .summary-row.available { font-size: 18px; padding: 10px; }
    .modal-content { padding: 15px; }
    .modal-title { font-size: 18px; }
    .form-group label { font-size: 14px; }
    input, select, textarea { font-size: 14px; padding: 6px 8px; }
  }

  @media print {
    body, .app-container { background: #ffffff !important; color: #000000 !important; padding: 0 !important; margin: 0 !important; max-width: 100% !important; }
    .app-container > *:not(.print-target) { display: none !important; }
    .print-target { display: block !important; position: absolute !important; top: 0; left: 0; width: 100% !important; height: auto !important; background: #ffffff !important; opacity: 1 !important; z-index: 99999 !important; }
    .print-target .modal-content { border: none !important; box-shadow: none !important; width: 100% !important; max-width: 100% !important; padding: 0 !important; background: #ffffff !important; max-height: none !important; overflow: visible !important; color: #000000 !important; }
    .print-target .modal-header-actions { display: none !important; }
    #comp-chart { max-height: 250px !important; }
  }
