/* === OFFSHORE 経理 アプリケーションCSS ===
   ベース: design/sample/_shared.css (Notion-inspired)
*/
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #ffffff;
  --bg-alt: #f6f5f4;
  --bg-sidebar: #fafaf9;
  --text: rgba(0,0,0,0.9);
  --text-secondary: #615d59;
  --text-muted: #a39e98;
  --accent: #0075de;
  --accent-hover: #005bab;
  --accent-bg: #f2f9ff;
  --accent-text: #097fe8;
  --success: #1aae39;
  --success-bg: #f0fdf4;
  --danger: #e03e3e;
  --danger-bg: #fef2f2;
  --warning: #dd5b00;
  --warning-bg: #fff7ed;
  --border: rgba(0,0,0,0.1);
  --border-input: #dddddd;
  --sidebar-width: 240px;
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-pill: 9999px;
  --shadow-card: rgba(0,0,0,0.04) 0px 4px 18px, rgba(0,0,0,0.027) 0px 2px 8px, rgba(0,0,0,0.02) 0px 0.8px 3px;
}

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

html { overflow-x: hidden; }

body {
  font-family: 'Inter', -apple-system, system-ui, sans-serif;
  background: var(--bg-alt);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
  max-width: 100vw;
}

/* ===== App Layout ===== */
.app-layout { display: flex; min-height: 100vh; }

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform 0.25s ease;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo-mark {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: var(--radius-xs);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-logo-mark svg { width: 18px; height: 18px; fill: #fff; }
.sidebar-logo-text { font-size: 13px; font-weight: 700; letter-spacing: -0.1px; }
.sidebar-logo-sub  { font-size: 11px; color: var(--text-muted); }

.sidebar-section { padding: 8px 8px 0; }
.sidebar-section-title {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 8px 8px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-xs);
  font-size: 13px; font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.nav-item:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.nav-item svg { width: 16px; height: 16px; opacity: 0.7; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; }

.sidebar-sub-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 32px;
  border-radius: var(--radius-xs);
  font-size: 13px; color: var(--text-secondary);
  text-decoration: none; cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.sidebar-sub-item:hover { background: rgba(0,0,0,0.05); color: var(--text); }
.sidebar-sub-item.active { color: var(--accent); font-weight: 600; }

.sidebar-footer {
  margin-top: auto;
  padding: 12px 8px;
  border-top: 1px solid var(--border);
}
.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background 0.1s;
}
.sidebar-user:hover { background: rgba(0,0,0,0.05); }

.avatar {
  width: 28px; height: 28px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 11px; color: var(--text-muted); }

/* ===== Main Wrapper ===== */
.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1; min-width: 0;
  max-width: calc(100vw - var(--sidebar-width));
  display: flex; flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
}
.top-bar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 24px; height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.top-bar-left { display: flex; align-items: center; gap: 12px; }
.hamburger {
  display: none; border: none; background: none;
  cursor: pointer; padding: 4px; color: var(--text-secondary);
}
.breadcrumb {
  font-size: 13px; color: var(--text-secondary);
  display: flex; align-items: center; gap: 6px;
}
.breadcrumb-sep     { color: var(--text-muted); }
.breadcrumb-current { font-weight: 600; color: var(--text); }

.content { padding: 28px 24px; flex: 1; }

/* ===== Page Header ===== */
.page-header   { margin-bottom: 24px; }
.page-title    { font-size: 22px; font-weight: 700; letter-spacing: -0.25px; margin-bottom: 4px; }
.page-subtitle { font-size: 14px; color: var(--text-secondary); }

/* ===== Cards ===== */
.card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-card);
  padding: 20px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text); }

/* ===== Stat Cards ===== */
.stat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-card);
  padding: 20px;
}
.stat-label {
  font-size: 12px; font-weight: 600; color: var(--text-secondary);
  margin-bottom: 8px; display: flex; align-items: center; gap: 6px;
}
.stat-value {
  font-size: 28px; font-weight: 700; letter-spacing: -0.5px;
  color: var(--text); line-height: 1.1;
}
.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }
.stat-meta { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  font-family: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn svg { width: 15px; height: 15px; }

.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: rgba(0,0,0,0.06); color: var(--text); }
.btn-secondary:hover { background: rgba(0,0,0,0.1); }
.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border-input);
}
.btn-ghost:hover { background: var(--bg-alt); color: var(--text); }
.btn-danger {
  background: var(--danger-bg); color: var(--danger);
  border: 1px solid rgba(224,62,62,0.2);
}
.btn-danger:hover { background: #fee2e2; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 10px 20px; font-size: 14px; }

/* ===== Forms ===== */
.form-group   { margin-bottom: 18px; }
.form-label   { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.form-label .required { color: var(--danger); margin-left: 2px; font-size: 11px; }
.form-control {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-xs);
  font-family: inherit; font-size: 16px; color: var(--text);
  background: var(--bg); outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  /* iOS Safari: min-width:0 でグリッド内はみ出しを防ぐ */
  min-width: 0; max-width: 100%;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,117,222,0.12); }
.form-control::placeholder { color: var(--text-muted); }
.form-control:disabled, .form-control[readonly] { background: var(--bg-alt); color: var(--text-secondary); cursor: not-allowed; }
select.form-control   { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
/* グリッドアイテムのはみ出し防止（iOS date input 対策） */
.form-row > * { min-width: 0; }

/* ===== Badge ===== */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: var(--radius-pill);
  font-size: 11px; font-weight: 600; letter-spacing: 0.1px;
}
.badge-blue   { background: var(--accent-bg);  color: var(--accent-text); }
.badge-green  { background: var(--success-bg); color: var(--success); }
.badge-orange { background: var(--warning-bg); color: var(--warning); }
.badge-red    { background: var(--danger-bg);  color: var(--danger); }
.badge-gray   { background: var(--bg-alt);     color: var(--text-secondary); }

/* ===== Table ===== */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  box-shadow: var(--shadow-card);
  max-width: 100%;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: var(--bg-alt); padding: 10px 16px;
  text-align: left; font-weight: 600; color: var(--text-secondary);
  font-size: 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-alt); }
.td-right { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td {
  padding: 12px 16px; border-top: 1px solid var(--border);
  font-weight: 700; background: var(--bg-alt);
}

/* ===== Alert ===== */
.alert {
  padding: 12px 16px; border-radius: var(--radius-xs);
  font-size: 13px; display: flex; align-items: flex-start;
  gap: 10px; margin-bottom: 16px;
}
.alert-info    { background: var(--accent-bg);  color: var(--accent-text);  border: 1px solid rgba(0,117,222,0.2); }
.alert-success { background: var(--success-bg); color: var(--success);      border: 1px solid rgba(26,174,57,0.2); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger);       border: 1px solid rgba(224,62,62,0.2); }

/* ===== Divider ===== */
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ===== Month Selector ===== */
.month-selector {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-xs); padding: 2px 4px;
}
.month-selector button,
.month-selector a.month-btn {
  padding: 6px 10px; background: none; border: none;
  cursor: pointer; color: var(--text-secondary);
  font-family: inherit; font-size: 13px;
  border-radius: var(--radius-xs); text-decoration: none;
  transition: background 0.1s;
}
.month-selector button:hover,
.month-selector a.month-btn:hover { background: var(--bg-alt); }
.month-selector .month-label {
  font-size: 14px; font-weight: 600; color: var(--text);
  padding: 0 12px; min-width: 110px; text-align: center;
}

/* ===== Tabs ===== */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 16px; background: none; border: none;
  font-family: inherit; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all 0.15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); font-weight: 600; border-bottom-color: var(--accent); }

/* ===== Filter Bar ===== */
.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; max-width: 100%; }
.filter-select {
  padding: 7px 12px; border: 1px solid var(--border-input);
  border-radius: var(--radius-xs); font-family: inherit; font-size: 13px;
  color: var(--text); background: var(--bg); cursor: pointer; outline: none; max-width: 100%;
}
.filter-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,117,222,0.12); }
.search-wrap { position: relative; flex: 1; min-width: 0; width: 100%; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.search-input {
  width: 100%; padding: 7px 12px 7px 36px;
  border: 1px solid var(--border-input); border-radius: var(--radius-xs);
  font-family: inherit; font-size: 13px; color: var(--text); background: var(--bg); outline: none;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,117,222,0.12); }

/* ===== Login Page ===== */
.login-page {
  min-height: 100vh; display: flex; align-items: center;
  justify-content: center; padding: 24px; background: var(--bg-alt);
}
.login-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-card);
  padding: 40px 36px; width: 100%; max-width: 400px;
}
.login-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 28px;
}
.login-logo-mark {
  width: 36px; height: 36px; background: var(--accent);
  border-radius: var(--radius-xs); display: flex; align-items: center; justify-content: center;
}
.login-logo-mark svg { width: 20px; height: 20px; fill: #fff; }
.login-logo-text { font-size: 15px; font-weight: 700; }
.login-title    { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.login-subtitle { font-size: 13px; color: var(--text-secondary); margin-bottom: 24px; }

/* ===== Responsive ===== */
/* デスクトップではフォームを14pxに戻す（モバイルは16px固定でiOSズーム防止） */
@media (min-width: 769px) {
  .form-control { font-size: 14px; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-wrapper { margin-left: 0; max-width: 100vw; }
  .hamburger { display: flex; }
  .stat-grid { grid-template-columns: 1fr; }
  .form-row  { grid-template-columns: 1fr; }
  .content   { padding: 20px 16px; }
  .top-bar   { padding: 0 16px; overflow: hidden; }
  .breadcrumb { overflow: hidden; white-space: nowrap; }
  .overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.3); z-index: 90;
  }
  .overlay.open { display: block; }
}
