:root {
  --amber-50: #fffbeb;
  --amber-100: #fef3c6;
  --amber-200: #fee685;
  --amber-500: #f69e00;
  --amber-600: #da7700;
  --amber-700: #b55200;
  --cyan-200: #a2f4fd;
  --cyan-300: #53eafd;
  --cyan-400: #00d1ec;
  --emerald-50: #ecfdf5;
  --emerald-100: #d0fae5;
  --emerald-200: #a4f4cf;
  --emerald-400: #00d294;
  --emerald-500: #00b981;
  --emerald-600: #009669;
  --emerald-700: #007857;
  --custom-green-600: #009966;
  --orange-100: #ffedd5;
  --orange-400: #ff8b1f;
  --orange-500: #fc7100;
  --orange-600: #ec5600;
  --orange-700: #c43e00;
  --red-50: #fef2f2;
  --red-100: #ffe2e2;
  --red-200: #ffcaca;
  --red-400: #ff6568;
  --red-500: #fb2c36;
  --red-600: #e40016;
  --sky-50: #f0f9ff;
  --sky-100: #dff2fe;
  --sky-200: #b8e6fe;
  --sky-400: #00bbfd;
  --sky-500: #00a5ea;
  --sky-600: #0284c7;
  --sky-700: #0069a2;
  --sky-800: #005986;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --custom-slate-250: #d6dfe9;
  --slate-300: #cad5e2;
  --slate-400: #90a1b9;
  --color-placeholder: #adbbce;
  --slate-500: #62748e;
  --slate-600: #45556c;
  --slate-700: #314158;
  --slate-800: #1d293d;
  --violet-50: #f5f3ff;
  --violet-100: #ede9fe;
  --violet-200: #ddd6ff;
  --violet-400: #a686ff;
  --violet-500: #8d56ff;
  --violet-600: #7f22fe;
  --yellow-600: #ca8a00;
  --white: #ffffff;
  --black: #000000;

  --color-page-bg: var(--slate-50);
  --color-surface: var(--white);
  --color-border: #d6deea;
  --color-border-light: var(--slate-200);
  --color-input-border: var(--custom-slate-250);
  --color-text-default: #243041;
  --color-text-heading: var(--slate-800);
  --color-text-label: var(--slate-600);
  --color-text-muted: var(--slate-400);
  --color-primary: #00a6f4;
  --color-primary-hover: #0084d1;
  --color-link: #00a6f4;
  --color-link-hover: #0069a8;
  --color-focus: #00bcff;
  --color-focus-ring: #74d4ff;
  --color-hover-background: var(--slate-200);
  --color-selected-background: var(--sky-100);
  --color-selected-left-line: var(--sky-500);

  --input-focus-outline: 2px solid var(--color-focus-ring);
  --width-selected-left-line: 3px;
  --control-height: 38px;
  --gradient-brand-primary: linear-gradient(135deg, #0084d1 0%, #00a6f4 50%, #00d3f2 100%);
  --transition-hover-duration: .15s;
  --detail-transition-duration: .15s;
  --popup-enter-offset: 4px;
  --popup-enter-duration: .15s;
  --dialog-backdrop-duration: .2s;
  --dialog-enter-duration: .2s;
  --dialog-exit-duration: .15s;
  --dialog-enter-offset: 8px;
}

a:not(.logo):not(.chat-trigger):not(.dashboard-widget-link) {
  color: var(--color-link);
  &:hover,
  &:focus-visible { color: var(--color-link-hover); }
}

.date-input-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  vertical-align: middle;

  > .date-input-text {
    box-sizing: border-box;
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
    height: var(--control-height, 38px);
    min-height: var(--control-height, 38px);
    padding: 8px 42px 8px 12px !important;
    border: 1px solid var(--color-input-border);
    border-radius: 8px;
    background: var(--white, #fff);
    color: var(--slate-700, #334155);
    &:focus { border-color: var(--color-focus); outline: var(--input-focus-outline); outline-offset: 0; }
  }

  > .date-input-picker-button {
    position: absolute;
    top: 50%;
    right: 8px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 24px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    transform: translateY(-50%);

    > img { width: 16px; height: 16px; filter: grayscale(1) brightness(.55); }
    &:disabled { cursor: not-allowed; opacity: .55; }
  }

  > .date-input-native-picker {
    position: absolute !important;
    top: 0 !important;
    right: 0 !important;
    left: auto !important;
    z-index: 1;
    width: 38px !important;
    height: 38px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    opacity: 0;
    pointer-events: none;
  }
}

#user-settings-overlay {
  .user-settings-checkbox-row { display: block; > .user-settings-checkbox-label { width: 100%; } }
  .user-settings-dashboard-customize { width: 100%; grid-column: 1 / -1; }
}

input::placeholder,
textarea::placeholder {
  color: var(--color-placeholder);
  opacity: 1;
}

@keyframes popup-enter {
  from {
    opacity: 0;
    transform: translateY(calc(0px - var(--popup-enter-offset)));
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

:where(
  .menu-popup:not([hidden]),
  .user-dropdown,
  .data-browser-context-menu,
  .data-browser-tag-popup:not([hidden]),
  .data-browser-card-tag-popup:not([hidden]),
  .data-browser-related-matches-popover,
  .mail-item-menu:not([hidden])
) {
  animation: popup-enter var(--popup-enter-duration) ease-out both;
}

* {
  font-weight: 500;
}

/* 共通ローディング */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 47, 107, 0.16);

  &.is-open {
    display: flex;
  }

  .loading-spinner {
    width: 44px;
    height: 44px;
    border: 4px solid #dbe7ff;
    border-top-color: #2050a4;
    border-radius: 50%;
    animation: common-spinner 0.8s linear infinite;
  }
}

.common-checkbox {
  appearance: none;
  flex: 0 0 13px;
  width: 13px;
  height: 13px;
  min-width: 13px;
  min-height: 13px;
  margin: 0;
  border: 1px solid var(--color-input-border);
  border-radius: 4px;
  background: var(--white);
}
.common-checkbox:checked {
  border-color: #0EA5E9;
  background: #0EA5E9 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='9' height='9' viewBox='0 0 9 9'%3E%3Cpath d='m1 4.5 2 2L8 1.5' fill='none' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 9px 9px no-repeat;
}

.primary-btn,
.secondary-btn,
.cancel-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: auto;
  min-height: 38px;
  height: auto;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--transition-hover-duration) ease-out, border-color var(--transition-hover-duration) ease-out, color var(--transition-hover-duration) ease-out;

  &:disabled { opacity: .45; cursor: default; }
  &:focus-visible { outline: 2px solid var(--color-focus-ring); outline-offset: 2px; }
}

:where(button, a, [role="button"], [role="menuitem"], [role="tab"], [role="option"], [tabindex], tr, article, summary, [class*="-item"], [class*="-card"], [class*="-action"], [class*="-child"], [class*="-row"]) {
  transition: background-color var(--transition-hover-duration) ease-out, border-color var(--transition-hover-duration) ease-out, color var(--transition-hover-duration) ease-out;
}

.primary-btn {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: var(--white);

  &:hover:not(:disabled) { border-color: var(--color-primary-hover); background: var(--color-primary-hover); color: var(--white); }
  &.is-running:disabled { opacity: 1; }
}

.secondary-btn {
  border-color: var(--slate-600);
  background: var(--slate-600);
  color: var(--white);

  &:hover:not(:disabled) { border-color: var(--slate-700); background: var(--slate-700); color: var(--white); }
}

.cancel-btn {
  border-color: var(--slate-200);
  background: var(--white);
  color: var(--slate-700);

  &:hover:not(:disabled) { border-color: var(--slate-300); background: var(--slate-50); color: var(--slate-700); }
}

@keyframes common-spinner {
  to {
    transform: rotate(360deg);
  }
}

/* 共通モーダル */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: background-color var(--dialog-backdrop-duration) ease,
    display var(--dialog-backdrop-duration) allow-discrete;

  &.app-message-modal { z-index: 4000; }
  &#error-modal-overlay { z-index: 5000; }

  &.is-open {
    display: flex;
    background-color: rgba(0, 0, 0, 0.3);

    > [role="dialog"] {
      opacity: 1;
      transform: translateY(0);
      transition-duration: var(--dialog-enter-duration);

      @starting-style {
        opacity: 0;
        transform: translateY(var(--dialog-enter-offset));
      }
    }

    @starting-style {
      background-color: transparent;
    }
  }

  .modal {
    width: min(520px, calc(100vw - 32px));
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    padding: 32px;
    border: 1px solid var(--slate-200);
    background: var(--white);
    border-radius: 16px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.18);

    .modal-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      margin-bottom: 16px;
      padding-bottom: 16px;
      border-bottom: 1px solid var(--slate-200);

      h2 {
        margin: 0;
        color: var(--slate-800);
        font-size: 14px;
        font-weight: 700;
      }

      .modal-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: var(--slate-100);
        color: var(--slate-500);

        > img { display: block; width: 11px; height: 11px; }

        &:not(:has(> img)) {
          font-size: 0;

          &::after {
            width: 11px;
            height: 11px;
            background: currentColor;
            content: "";
            mask: url('/static/img/close.svg') center / contain no-repeat;
          }
        }
      }
    }

    .modal-body {
      margin: 0 0 24px;
    }

    .modal-footer {
      display: flex;
      justify-content: flex-end;
      gap: 0.75rem;
      flex-wrap: wrap;

      > .primary-btn, > .secondary-btn, > .cancel-btn { min-width: 94px; }
    }

    .modal-details {
      display: none;
      padding: 0.5rem;
      border: 1px solid #e0e0e0;
      border-radius: 0.65rem;
      background: #f6f6f6;
      white-space: pre-wrap;
    }
  }

  &:not(.new-form-modal) {
    .modal {
      .modal-body {
        > .form-item {
          display: grid;
          grid-template-columns: 112px minmax(0, 1fr);
          align-items: center;
          gap: 16px;
          margin: 0 0 16px;

          > label { width: auto; color: var(--slate-600); font-size: 14px; }
          > input, > select, > textarea {
            width: 100%;
            min-height: var(--control-height);
            padding: 8px 12px;
            border: 1px solid var(--color-input-border);
            border-radius: 8px;
            background: var(--white);
            color: var(--slate-700);
          }
          > textarea { min-height: 103px; }
          > .password-policy-hint { grid-column: 2; margin: 0; color: var(--slate-400); font-size: 12px; line-height: 17px; }
        }
      }
    }
  }

  > [role="dialog"] {
    opacity: 0;
    transform: translateY(var(--dialog-enter-offset));
    transition: opacity var(--dialog-exit-duration) ease,
      transform var(--dialog-exit-duration) ease;
  }
}
