    /* Arabic fonts for canvas rendering */
    @font-face {
      font-family: 'Amiri';
      src: url('../fonts/Amiri-Regular.ttf') format('truetype');
      font-weight: normal;
      font-style: normal;
    }

    @font-face {
      font-family: 'Noto Sans Arabic';
      src: url('../fonts/NotoSansArabic-Regular.ttf') format('truetype');
      font-weight: normal;
      font-style: normal;
    }

    @font-face {
      font-family: 'Cairo';
      src: url('../fonts/cairo-400.ttf') format('truetype');
      font-weight: 400;
      font-style: normal;
    }

    @font-face {
      font-family: 'Cairo';
      src: url('../fonts/cairo-600.ttf') format('truetype');
      font-weight: 600;
      font-style: normal;
    }

    @font-face {
      font-family: 'Cairo';
      src: url('../fonts/cairo-700.ttf') format('truetype');
      font-weight: 700;
      font-style: normal;
    }

    :root {
      color-scheme: light;
      font-family: "Cairo", "Tajawal", "Inter", "Segoe UI", system-ui, sans-serif;
      line-height: 1.5;
      font-size: 14px;
      
      /* Wedding Classic Colors */
      --bg-primary: #faf8f5;
      --bg-secondary: #f5f1eb;
      --gold: #d4af37;
      --gold-light: #e8d4a0;
      --gold-dark: #b8941f;
      --beige: #e8dcc4;
      --beige-dark: #d4c5a9;
      --white: #ffffff;
      --text-primary: #2c2416;
      --text-secondary: #5c5444;
      --border: rgba(212, 175, 55, 0.2);
      --shadow: rgba(44, 36, 22, 0.08);
      --danger: #c44536;
      --primary: #d4af37;
    }

    * {
      box-sizing: border-box;
    }

    body {
      margin: 0;
      min-height: 100vh;
      background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--beige) 100%);
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 20px 15px;
      color: var(--text-primary);
    }

    /* Login Screen */
    #loginScreen {
      max-width: 450px;
      width: 100%;
    }

    #loginScreen .card {
      text-align: center;
      background: var(--white);
      padding: 32px 28px;
      border-radius: 16px;
      box-shadow: 0 8px 30px var(--shadow);
      border: 2px solid var(--gold-light);
    }

    #loginScreen h1 {
      margin: 0 0 8px;
      font-size: 1.6rem;
      color: var(--gold-dark);
      font-weight: 700;
    }

    #loginScreen p {
      margin: 0 0 24px;
      color: var(--text-secondary);
      font-size: 0.9rem;
    }

    #loginError {
      display: none;
      padding: 12px 16px;
      background: rgba(196, 69, 54, 0.1);
      border: 1px solid rgba(196, 69, 54, 0.3);
      border-radius: 10px;
      color: var(--danger);
      font-size: 0.85rem;
      margin-bottom: 20px;
    }

    /* Main App */
    #appScreen {
      display: none;
      max-width: 1400px;
      width: 100%;
    }

    #appScreen.active {
      display: grid;
      gap: 20px;
    }

    header {
      text-align: center;
      padding: 16px 20px;
      background: var(--white);
      border-radius: 16px;
      box-shadow: 0 3px 15px var(--shadow);
      margin-bottom: 20px;
      border: 2px solid var(--gold-light);
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-wrap: wrap;
      gap: 15px;
    }

    header h1 {
      margin: 0;
      font-size: clamp(1.2rem, 3vw, 1.8rem);
      background: linear-gradient(135deg, var(--gold-dark), var(--gold));
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      background-clip: text;
      font-weight: 700;
      flex: 1;
    }

    header button {
      padding: 8px 16px;
      font-size: 0.85rem;
    }

    /* Tabs System */
    .tabs-container {
      background: var(--white);
      border: 2px solid var(--gold-light);
      border-radius: 16px;
      overflow: hidden;
      box-shadow: 0 3px 15px var(--shadow);
    }

    .tabs-nav {
      display: flex;
      background: var(--beige);
      border-bottom: 2px solid var(--gold-light);
      overflow-x: auto;
      gap: 0;
    }

    .tab-button {
      flex: 1;
      min-width: 140px;
      padding: 14px 18px;
      background: transparent;
      border: none;
      border-bottom: 3px solid transparent;
      color: var(--text-secondary);
      font-size: 0.9rem;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.3s ease;
      white-space: nowrap;
    }

    .tab-button:hover {
      background: rgba(212, 175, 55, 0.1);
      color: var(--gold-dark);
    }

    .tab-button.active {
      background: var(--white);
      color: var(--gold-dark);
      border-bottom-color: var(--gold);
    }

    .tabs-content {
      padding: 20px;
    }

    .tab-panel {
      display: none;
    }

    .tab-panel.active {
      display: block;
    }

    .card {
      background: var(--white);
      backdrop-filter: blur(18px);
      border: 2px solid var(--gold-light);
      border-radius: 16px;
      padding: 20px;
      box-shadow: 0 3px 15px var(--shadow);
    }

    h2 {
      margin-top: 0;
      font-size: 1.2rem;
      color: var(--gold-dark);
      font-weight: 700;
    }

    form {
      display: grid;
      gap: 16px;
    }

    label {
      display: grid;
      gap: 6px;
      font-size: 0.9rem;
      font-weight: 600;
      color: var(--text-primary);
      margin-bottom: 16px;
    }

    input,
    select,
    button {
      font: inherit;
    }

    input[type="url"],
    input[type="number"],
    input[type="text"],
    input[type="password"],
    input[type="color"],
    select,
    textarea {
      padding: 10px 14px;
      border-radius: 10px;
      border: 2px solid var(--border);
      background: var(--white);
      color: var(--text-primary);
      font-size: 0.9rem;
      transition: all 0.3s ease;
    }

    input:focus,
    select:focus,
    textarea:focus {
      outline: none;
      border-color: var(--gold);
      box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.15);
    }

    input[type="color"] {
      height: 40px;
      cursor: pointer;
      padding: 4px;
    }

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

    .field-triple {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
      gap: 12px;
    }

    .file-field input[type="file"] {
      border-radius: 10px;
      border: 2px dashed var(--border);
      padding: 10px;
      background: var(--white);
      cursor: pointer;
      font-size: 0.85rem;
    }

    .file-field small {
      font-weight: 400;
      font-size: 0.75rem;
      color: var(--text-secondary);
    }

    .file-preview {
      margin-top: 6px;
      display: grid;
      place-items: center;
      border-radius: 10px;
      border: 2px dashed var(--border);
      background: var(--beige);
      min-height: 120px;
      padding: 8px;
      font-size: 0.8rem;
      color: var(--text-secondary);
      text-align: center;
      overflow: hidden;
    }

    .file-preview img {
      max-width: 100%;
      max-height: 100%;
      border-radius: 8px;
    }

    button {
      cursor: pointer;
      padding: 10px 24px;
      border-radius: 10px;
      border: none;
      font-weight: 600;
      font-size: 0.9rem;
      background: linear-gradient(135deg, var(--gold), var(--gold-dark));
      color: var(--white);
      transition: all 0.3s ease;
      box-shadow: 0 3px 12px rgba(212, 175, 55, 0.3);
    }

    button:hover {
      transform: translateY(-2px);
      box-shadow: 0 6px 20px rgba(212, 175, 55, 0.4);
    }

    button:active {
      transform: translateY(0);
      box-shadow: 0 2px 8px rgba(212, 175, 55, 0.3);
    }

    .notice {
      padding: 12px 16px;
      border-radius: 10px;
      background: rgba(212, 175, 55, 0.1);
      border: 2px solid var(--border);
      font-size: 0.8rem;
      line-height: 1.6;
      color: var(--gold-dark);
      margin: 16px 0;
    }

    .preview-wrapper {
      display: grid;
      gap: 16px;
      justify-items: center;
      text-align: center;
    }

    #qrPreview {
      width: 280px;
      height: 280px;
      display: grid;
      place-items: center;
      background: var(--white);
      border-radius: 12px;
      border: 2px solid var(--border);
      padding: 24px;
      box-shadow: 0 3px 15px var(--shadow);
      min-height: 250px;
    }

    #qrPreview canvas,
    #qrPreview svg {
      max-width: 100%;
      max-height: 100%;
    }

    table {
      width: 100%;
      border-collapse: collapse;
      font-size: 0.85rem;
      margin-top: 16px;
      background: var(--white);
      border-radius: 10px;
      overflow: hidden;
      box-shadow: 0 2px 8px var(--shadow);
    }

    th,
    td {
      padding: 10px 12px;
      border-bottom: 1px solid var(--border);
      text-align: right;
      vertical-align: top;
    }

    code {
      background: rgba(212, 175, 55, 0.1);
      padding: 2px 6px;
      border-radius: 4px;
      font-family: 'Courier New', monospace;
      font-size: 0.85em;
      color: var(--gold-dark);
      font-weight: 600;
    }

    th {
      font-weight: 700;
      font-size: 0.85rem;
      background: var(--beige);
      color: var(--gold-dark);
    }

    tbody tr:last-child td {
      border-bottom: none;
    }

    tbody tr:hover {
      background: rgba(212, 175, 55, 0.05);
    }

    .entry-actions {
      display: flex;
      gap: 8px;
      flex-wrap: wrap;
    }

    .entry-actions button {
      padding: 6px 12px;
      font-size: 0.8rem;
    }

    .whatsapp-btn {
      background: linear-gradient(135deg, #25D366, #128C7E) !important;
      color: white !important;
    }

    .whatsapp-btn:hover {
      box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4) !important;
    }

    .edit-btn {
      background: linear-gradient(135deg, #2196F3, #1976D2) !important;
      color: white !important;
    }

    .edit-btn:hover {
      box-shadow: 0 6px 20px rgba(33, 150, 243, 0.4) !important;
    }

    .reactivate-btn {
      background: linear-gradient(135deg, #FF9800, #F57C00) !important;
      color: white !important;
    }

    .reactivate-btn:hover {
      box-shadow: 0 6px 20px rgba(255, 152, 0, 0.4) !important;
    }

    /* Modal/Popup Styles */
    .modal-overlay {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(0, 0, 0, 0.6);
      backdrop-filter: blur(4px);
      z-index: 1000;
      align-items: center;
      justify-content: center;
      padding: 20px;
    }

    .modal-overlay.active {
      display: flex;
    }

    .modal-content {
      background: var(--white);
      border-radius: 16px;
      padding: 24px;
      max-width: 500px;
      width: 100%;
      box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
      border: 2px solid var(--gold-light);
      max-height: 90vh;
      overflow-y: auto;
    }

    .modal-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-bottom: 20px;
      padding-bottom: 12px;
      border-bottom: 2px solid var(--border);
    }

    .modal-header h3 {
      margin: 0;
      font-size: 1.2rem;
      color: var(--gold-dark);
      font-weight: 700;
    }

    .modal-close {
      background: transparent;
      border: none;
      font-size: 1.5rem;
      cursor: pointer;
      color: var(--text-secondary);
      padding: 0;
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 50%;
      transition: all 0.3s ease;
    }

    .modal-close:hover {
      background: rgba(196, 69, 54, 0.1);
      color: var(--danger);
      transform: none;
      box-shadow: none;
    }

    .modal-body {
      display: grid;
      gap: 16px;
    }

    .modal-footer {
      display: flex;
      gap: 12px;
      margin-top: 20px;
      padding-top: 16px;
      border-top: 2px solid var(--border);
    }

    .modal-footer button {
      flex: 1;
    }

    .pill {
      display: inline-flex;
      align-items: center;
      gap: 6px;
      padding: 4px 10px;
      border-radius: 16px;
      font-size: 0.75rem;
      font-weight: 600;
      background: rgba(212, 175, 55, 0.15);
      border: 1px solid var(--gold);
      color: var(--gold-dark);
    }

    .pill.active {
      background: rgba(76, 175, 80, 0.15);
      border-color: #4caf50;
      color: #2e7d32;
    }

    .pill.inactive {
      background: rgba(196, 69, 54, 0.1);
      border-color: var(--danger);
      color: var(--danger);
    }

    .empty-state {
      text-align: center;
      padding: 24px 12px;
      color: var(--text-secondary);
      font-size: 0.85rem;
    }

    .secondary {
      background: var(--beige);
      color: var(--text-primary);
      box-shadow: 0 2px 8px rgba(212, 175, 55, 0.2);
    }

    .secondary:hover {
      background: var(--beige-dark);
      box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
    }

    .danger {
      background: linear-gradient(135deg, var(--danger), #a83a2e);
      color: var(--white);
    }

    .danger:hover {
      box-shadow: 0 6px 20px rgba(196, 69, 54, 0.4);
    }

    .helper {
      font-size: 0.8rem;
      color: var(--text-secondary);
      margin-top: 4px;
    }

    .collapsible-section {
      border: 2px solid var(--border);
      border-radius: 12px;
      padding: 14px 18px;
      background: rgba(212, 175, 55, 0.05);
      margin-bottom: 16px;
    }

    .collapsible-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      cursor: pointer;
      user-select: none;
    }

    .collapsible-header h3 {
      margin: 0;
      font-size: 1rem;
      color: var(--gold-dark);
      font-weight: 700;
    }

    .collapsible-content {
      margin-top: 16px;
      display: grid;
      gap: 16px;
    }

    .collapsible-content.collapsed {
      display: none;
    }

    .color-grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
      gap: 12px;
    }

    /* Wedding Groups */
    .wedding-group {
      border: 2px solid var(--gold-light);
      border-radius: 12px;
      margin-bottom: 16px;
      overflow: hidden;
      background: var(--white);
      box-shadow: 0 2px 8px var(--shadow);
    }

    .wedding-group-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 14px 18px;
      background: rgba(212, 175, 55, 0.05);
      cursor: pointer;
      gap: 12px;
      flex-wrap: wrap;
    }

    .wedding-group-header:hover {
      background: rgba(212, 175, 55, 0.1);
    }

    .wedding-info {
      flex: 1;
      min-width: 200px;
    }

    .wedding-info h3 {
      margin: 0 0 4px 0;
      font-size: 1rem;
      color: var(--gold-dark);
      font-weight: 700;
    }

    .wedding-info .helper {
      font-size: 0.75rem;
      color: var(--text-secondary);
      margin: 0;
    }

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

    .wedding-group-content {
      max-height: 600px;
      overflow-y: auto;
      transition: max-height 0.3s ease;
    }

    .wedding-group.collapsed .wedding-group-content {
      max-height: 0;
      overflow: hidden;
    }

    .toggle-btn {
      background: var(--gold);
      color: var(--white);
      border: none;
      border-radius: 50%;
      width: 32px;
      height: 32px;
      display: flex;
      align-items: center;
      justify-content: center;
      cursor: pointer;
      font-size: 0.9rem;
      transition: all 0.3s ease;
      padding: 0;
      box-shadow: 0 2px 6px rgba(212, 175, 55, 0.3);
    }

    .toggle-btn:hover {
      background: var(--gold-dark);
      transform: scale(1.1);
    }

    .wedding-group.collapsed .toggle-btn {
      transform: rotate(180deg);
    }

    /* Image Upload Area */
    .image-upload-area {
      border: 2px dashed var(--gold);
      border-radius: 10px;
      padding: 20px;
      text-align: center;
      background: var(--white);
      cursor: pointer;
      transition: all 0.3s ease;
    }

    .image-upload-area:hover {
      background: rgba(212, 175, 55, 0.05);
      border-color: var(--gold-dark);
    }

    .image-upload-area p {
      margin: 0 0 8px 0;
      color: var(--text-primary);
      font-weight: 600;
    }

    .image-upload-area small {
      color: var(--text-secondary);
    }

    /* Action Buttons Container */
    .action-buttons {
      display: flex;
      gap: 10px;
      flex-wrap: wrap;
      margin-top: 20px;
    }

    .action-buttons button {
      flex: 1;
      min-width: 140px;
    }

    /* Section Titles */
    h2 {
      margin: 0 0 18px;
      font-size: 1.2rem;
      color: var(--gold-dark);
      font-weight: 700;
      border-bottom: 2px solid var(--gold-light);
      padding-bottom: 10px;
    }

    h3 {
      margin: 20px 0 12px;
      font-size: 1rem;
      color: var(--text-primary);
      font-weight: 600;
    }

    #loadingOverlay {
      display: none;
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      background: rgba(44, 36, 22, 0.5);
      backdrop-filter: blur(4px);
      z-index: 9999;
      align-items: center;
      justify-content: center;
    }

    #loadingOverlay.active {
      display: flex;
    }

    .spinner {
      border: 4px solid rgba(212, 175, 55, 0.2);
      border-top: 4px solid var(--gold);
      border-radius: 50%;
      width: 50px;
      height: 50px;
      animation: spin 1s linear infinite;
    }

    @keyframes spin {
      0% { transform: rotate(0deg); }
      100% { transform: rotate(360deg); }
    }

    /* Responsive */
    @media (max-width: 768px) {
      body {
        padding: 15px 10px;
      }

      header {
        padding: 14px 16px;
      }

      .card {
        padding: 16px;
      }

      .tabs-content {
        padding: 16px;
      }

      .tab-button {
        padding: 12px 16px;
        font-size: 0.85rem;
      }

      .wedding-group-header {
        padding: 12px 14px;
      }

      .wedding-actions {
        width: 100%;
        justify-content: flex-start;
      }

      .field-pair {
        grid-template-columns: 1fr;
      }

      h2 {
        font-size: 1.1rem;
      }
    }

    /* Toast Notifications */
    #toastContainer {
      position: fixed;
      top: 20px;
      right: 20px;
      z-index: 9999;
      display: flex;
      flex-direction: column;
      gap: 10px;
      pointer-events: none;
    }

    @media (max-width: 768px) {
      #toastContainer {
        right: 10px;
        left: 10px;
        top: 10px;
      }
    }

    .toast {
      pointer-events: auto;
      padding: 14px 18px;
      border-radius: 10px;
      border-left: 4px solid;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
      animation: slideInRight 0.3s ease-out;
      max-width: 400px;
      font-size: 0.9rem;
      font-weight: 500;
      display: flex;
      align-items: center;
      gap: 10px;
      background: var(--white);
      color: var(--text-primary);
    }

    @media (max-width: 768px) {
      .toast {
        max-width: 100%;
        font-size: 0.85rem;
      }
    }

    .toast.success {
      border-left-color: #4caf50;
      background: #f1f8f4;
      color: #2e7d32;
    }

    .toast.error {
      border-left-color: #f44336;
      background: #fdeae8;
      color: #c44536;
    }

    .toast.warning {
      border-left-color: #ff9800;
      background: #fff8f0;
      color: #e65100;
    }

    .toast.info {
      border-left-color: #2196f3;
      background: #e8f4fd;
      color: #0d47a1;
    }

    .toast-icon {
      flex-shrink: 0;
      font-size: 1.1rem;
    }

    .toast-message {
      flex: 1;
      word-break: break-word;
    }

    .toast-close {
      flex-shrink: 0;
      background: none;
      border: none;
      font-size: 1.2rem;
      cursor: pointer;
      padding: 0;
      width: 24px;
      height: 24px;
      display: flex;
      align-items: center;
      justify-content: center;
      opacity: 0.6;
      transition: opacity 0.2s ease;
    }

    .toast-close:hover {
      opacity: 1;
    }

    @keyframes slideInRight {
      from {
        transform: translateX(400px);
        opacity: 0;
      }
      to {
        transform: translateX(0);
        opacity: 1;
      }
    }

    @keyframes slideOutRight {
      from {
        transform: translateX(0);
        opacity: 1;
      }
      to {
        transform: translateX(400px);
        opacity: 0;
      }
    }

    .toast.hide {
      animation: slideOutRight 0.3s ease-out forwards;
    }
