def compile_scss(
    data: GTData, id: str | None, compress: bool = True, all_important: bool = False
) -> str:
    """Return CSS for styling a table, based on options set."""

    # Obtain the SCSS options dictionary
    options = {field.name: getattr(data._options, field.name) for field in fields(data._options)}

    # Get collection of parameters that pertain to SCSS ----
    params = {k: opt.value for k, opt in options.items() if opt.scss and opt.value is not None}
    scss_defaults = {k: params.get("table_background_color") for k in DEFAULTS_TABLE_BACKGROUND}
    scss_params = {**scss_defaults, **params}

    # font color variables
    # TODO: at this stage, the params below (e.g. table_font_color) have to exist, right?
    p_font_color = partial(
        font_color,
        dark_option=params["table_font_color"],
        light_option=params["table_font_color_light"],
    )

    font_params = {f"font_color_{k}": p_font_color(scss_params[k]) for k in FONT_COLOR_VARS}

    final_params = {
        **scss_params,
        **font_params,
        "heading_subtitle_padding_top": css_add(scss_params["heading_padding"], -1),
        "heading_subtitle_padding_bottom": css_add(scss_params["heading_padding"], 1),
        "heading_padding_bottom": css_add(scss_params["heading_padding"], 1),
    }

    # Handle table id ----
    # Determine whether the table has an ID
    has_id = id is not None

    # Obtain the `table_id` value (might be set, might be None)
    # table_id = data._options._get_option_value(option="table_id")

    # TODO: need to implement a function to normalize color (`html_color()`)

    # Handle fonts ----
    # Get the unique list of fonts from `gt_options_dict`
    _font_names = data._options.table_font_names.value
    if _font_names is not None:
        font_list = OrderedSet(_font_names).as_list()
    else:
        font_list = None

    # Generate a `font-family` string
    if font_list is not None:
        font_family_attr = _as_css_font_family_attr(fonts=font_list)
    else:
        font_family_attr = ""

    # Generate styles ----
    gt_table_open_str = f"#{id} table" if has_id else ".gt_table"

    # Prepend any additional CSS ----
    additional_css = data._options.table_additional_css.value

    # Determine if there are any additional CSS statements
    has_additional_css = (
        additional_css is not None and isinstance(additional_css, list) and len(additional_css) > 0
    )

    # Ensure that list items in `additional_css` are unique and then combine statements while
    # separating with `\n`; use an empty string if list is empty or value is None
    if has_additional_css:
        additional_css_unique = OrderedSet(additional_css).as_list()
        table_additional_css = "\n".join(additional_css_unique) + "\n"
    else:
        table_additional_css = ""

    gt_table_class_str = f"""{table_additional_css}{gt_table_open_str} {{
          {font_family_attr}
          -webkit-font-smoothing: antialiased;
          -moz-osx-font-smoothing: grayscale;
        }}"""

    gt_styles_default = (files("great_tables") / "css/gt_styles_default.scss").read_text()

    if compress:
        gt_styles_default = re.sub(r"\s+", " ", gt_styles_default, count=0, flags=re.MULTILINE)
        gt_styles_default = re.sub(r"}", "}\n", gt_styles_default, count=0, flags=re.MULTILINE)

    compiled_css = Template(gt_styles_default).substitute(final_params)

    if has_id:
        compiled_css = re.sub(r"\.gt_", f"#{id} .gt_", compiled_css, count=0, flags=re.MULTILINE)
        compiled_css = re.sub(r"thead", f"#{id} thead", compiled_css, count=0, flags=re.MULTILINE)
        compiled_css = re.sub(
            r"^( p|p) \{", f"#{id} p {{", compiled_css, count=0, flags=re.MULTILINE
        )

    if all_important:
        compiled_css = re.sub(r";", " !important;", compiled_css, count=0, flags=re.MULTILINE)

    finalized_css = f"{gt_table_class_str}\n\n{compiled_css}"

    return finalized_css
Return CSS for styling a table, based on options set.
great_tables/_scss.py